Boolean operation
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Boolean operation
Hi everyone!
How can I do a Boolean operation with keep instrument body (second operand) like in fusion 360 or any other cad?
https://wampi.ru/image/RZFWNRJ
Is the only way out is to make a copy of the body?
I will be glad of any help
How can I do a Boolean operation with keep instrument body (second operand) like in fusion 360 or any other cad?
https://wampi.ru/image/RZFWNRJ
Is the only way out is to make a copy of the body?
I will be glad of any help
-
- Veteran
- Posts: 3179
- Joined: Thu Sep 24, 2020 10:31 pm
- Location: Hawaii
- Contact:
Re: Boolean operation
Since FreeCAD obviously can do this, you'll have to be more explicit about what code you are trying. What workbench are you using?
Re: Boolean operation
Welcome.
Please remember also to tell us what version of FreeCAD are you susing, follow:
http://forum.freecadweb.org/viewtopic.php?f=3&t=2264
Regards
Carlo D.
Please remember also to tell us what version of FreeCAD are you susing, follow:
http://forum.freecadweb.org/viewtopic.php?f=3&t=2264
Regards
Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
Re: Boolean operation
Hello. Sorry, I'm new to FreeCAD, and I'm still not good at it.
I'm using Version: 0.19.24366 (Git) and I work only on standard workbenches (Part and Part design)
I am a student and as part of my educational project I am writing a macro that simulates the cutting process of a cnc grinding machine. I am creating a model of a workpiece and a tool (Grinding wheel). The tool discretely moves along the specified coordinates, and at each step of the combat operation subtracts a circle from the workpiece.
I need the tool to remain in the scene after the boolean operation, and I don't have to constantly create it again. How can I do this?
I'm using Version: 0.19.24366 (Git) and I work only on standard workbenches (Part and Part design)
I am a student and as part of my educational project I am writing a macro that simulates the cutting process of a cnc grinding machine. I am creating a model of a workpiece and a tool (Grinding wheel). The tool discretely moves along the specified coordinates, and at each step of the combat operation subtracts a circle from the workpiece.
I need the tool to remain in the scene after the boolean operation, and I don't have to constantly create it again. How can I do this?
Re: Boolean operation
As here we are dealing with macros, describing thing without some code is hard.
As programmers "speaks through code" probably some code will be more helpful than a bunch of word.
Usually answers are not too far from the what you have already done, so if its possible to post something, maybe a simpler code that explain your problem, probably someone will drive you in the right direction.
Regards
Carlo D.
As programmers "speaks through code" probably some code will be more helpful than a bunch of word.
Usually answers are not too far from the what you have already done, so if its possible to post something, maybe a simpler code that explain your problem, probably someone will drive you in the right direction.
Regards
Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
Re: Boolean operation
My problem is in boolean operation:
App.activeDocument().addObject("Part::Cut","Cut")
App.activeDocument().Cut.Base = App.activeDocument().Body
App.activeDocument().Cut.Tool = App.activeDocument().Body001
After performing the operation, the second operand (tool or Body001) is deleted, and I need it to remain, because this body will still be used further.
App.activeDocument().addObject("Part::Cut","Cut")
App.activeDocument().Cut.Base = App.activeDocument().Body
App.activeDocument().Cut.Tool = App.activeDocument().Body001
After performing the operation, the second operand (tool or Body001) is deleted, and I need it to remain, because this body will still be used further.
Re: Boolean operation
It's eventually hidden, but surely not deleted. In GUI, you'll find the objects nested under the Cut in the Tree view.Klikest wrote: ↑Sun May 29, 2022 7:25 pm My problem is in boolean operation:
App.activeDocument().addObject("Part::Cut","Cut")
App.activeDocument().Cut.Base = App.activeDocument().Body
App.activeDocument().Cut.Tool = App.activeDocument().Body001
After performing the operation, the second operand (tool or Body001) is deleted, and I need it to remain, because this body will still be used further.
-
- Veteran
- Posts: 3179
- Joined: Thu Sep 24, 2020 10:31 pm
- Location: Hawaii
- Contact:
Re: Boolean operation
Works for me:
You can of course keep a reference to the objects by assigning them to a variable.
You can of course keep a reference to the objects by assigning them to a variable.
Code: Select all
App.activeDocument().addObject("Part::Cut","Cut")
body = App.activeDocument().Body
App.activeDocument().Cut.Base = body
tool = App.activeDocument().Body001
App.activeDocument().Cut.Tool = tool
App.activeDocument().recompute()
- Attachments
-
- keeptool.FCStd
- (11.59 KiB) Downloaded 13 times
Re: Boolean operation
This is not a problem, is the way boolean operation will work.Klikest wrote: ↑Sun May 29, 2022 7:25 pm My problem is in boolean operation:
App.activeDocument().addObject("Part::Cut","Cut")
App.activeDocument().Cut.Base = App.activeDocument().Body
App.activeDocument().Cut.Tool = App.activeDocument().Body001
After performing the operation, the second operand (tool or Body001) is deleted, and I need it to remain, because this body will still be used further.
You are using DocumentObjects and operate on them using "Part::Cut" DocumentObject, and this is the way it works.
You could ever copy the object and use a copy to do the cut so is the copy that go under DocumentObject "Cut", or use another approach:
I'm assuming you have two objects referred as Body and Body001 as "Names"
Code: Select all
doc = App.activeDocument()
# we need toposhapes so we are extracting using <.Shape>
body = doc.Body.Shape
tool = doc.Body001.Shape
cut = body.cut(tool).removeSplitter()
cut_dobj = doc.addObject("Part::FeaturePython", "boolean_cut")
cut_dobj.Shape = cut
doc.Recompute()
removeSplitter() is equivalent to put Refine = True in the "Part::Cut" DocumentObject.
NOTE: the code above is not tested, as I've written by hand so probable there are bugs or mistyping, iof anything go wrong please post an example the code, and I will make it work.
Regards
Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
Re: Boolean operation
Thank you so much!