关于“Part”的函数?

Chinese forum

Moderator: paullee

Forum rules
论坛规矩 / 論壇規矩 , 有用的资讯 / 有用的資訊
重要:寻求帮助之前,请先看看这里 /
重要:尋求幫助之前,請先看看這裡

另外,对论坛用户 友善!阅读FreeCAD 行为准则!
/ 另外,對論壇用戶 友善! 閱讀FreeCAD
行為準則
Post Reply
muzilier
Posts: 26
Joined: Tue Feb 22, 2022 1:58 am

关于“Part”的函数?

Post by muzilier »

想咨询一下,代码中如何一下子实现两个三维构件的 布尔操作呢,`Part`的哪个函数能直接实现呢?
而不是像 gui中的 两个构件那样。

我暂时的代码如下:

Code: Select all

    def execute(self, obj):
        """
        Called during document recomputes;
        Do not call recompute() from this method (or any method called from execute()) as this causes a nested recompute.
        """

        Box1 = Part.makeBox(obj.Length, obj.Width, obj.Height)
        Box2 = Part.makeBox(obj.Length, obj.Width_inside, obj.Height_inside) 

        # obj.Shape = Part.CompSolid([Box1, Box2])  # 如何进行 Cut?
Snipaste_2022-10-16_20-59-43.png
Snipaste_2022-10-16_20-59-43.png (29.52 KiB) Viewed 2360 times
muzilier
Posts: 26
Joined: Tue Feb 22, 2022 1:58 am

Re: 关于“Part”的函数?

Post by muzilier »

根据『Topological data scripting』[https://wiki.freecadweb.org/Topological_data_scripting]中所述,
makeBox生成的对象是 有`Cut`属性的,所以直接利用Cut属性就可以了
Snipaste_2022-10-17_10-52-45.png
Snipaste_2022-10-17_10-52-45.png (27.3 KiB) Viewed 2312 times

Code: Select all

obj.Shape = Box1.cut(Box2)
如上就能实现了。
muzilier
Posts: 26
Joined: Tue Feb 22, 2022 1:58 am

Re: 关于“Part”的函数?

Post by muzilier »

能请教一下,"Part"行成的构件,可以指定一条 线段(圆弧)等来"extrude"延伸。
现在"extrude"只能沿一个 向量,不知道对圆弧的延伸线这种,能有现成的简单实现的方法吗?
paullee
Veteran
Posts: 5098
Joined: Wed May 04, 2016 3:58 pm

Re: 关于“Part”的函数?

Post by paullee »

不大明白問題,可以圖示嗎 ?
Post Reply