Why does the Part --> booleans returns Compounds

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Why does the Part --> booleans returns Compounds

Post by bernd »

Hi,

Does someone know why the part --> booleans (cut, union, intersection) on solids returns compound containing the resulting solid?

Is there a possiblility to return solids instead of compounds, or is there a parametric way to get the solid out of the compound?

Bernd
User avatar
NormandC
Veteran
Posts: 18589
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Why does the Part --> booleans returns Compounds

Post by NormandC »

I'm not sure why it does that, but one of the devs (maybe Werner?) told me that if the compound contains a single solid, you are fine. I stopped caring after that advice. :D

The Fillet operation also quite often produces a compound.
wmayer
Founder
Posts: 20324
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Why does the Part --> booleans returns Compounds

Post by wmayer »

Up to my knowledge boolean operations always returned a compound independent of whether it's a single solid or a million. Thus it's up to the caller of the function to unpack a single solid if this is what he expects.

In Python it's very easy:

Code: Select all

result = ...
solid = result.Solids[0]
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Why does the Part --> booleans returns Compounds

Post by bernd »

wmayer wrote:Up to my knowledge boolean operations always returned a compound independent of whether it's a single solid or a million. Thus it's up to the caller of the function to unpack a single solid if this is what he expects.

Code: Select all

result = ...
solid = result.Solids[0]
This python snippets is exactly what I would like to get rid off because it is not parametric and it is not in user GUI.

Does it make sense to create a mantis for a new preference for part. A small wrapper around the part booleans. If a boolean returns one solid in a compound the solid is returned instead of the compound. The resulting object in FreeCAD tree would than be a solid.
jmaustpc
Veteran
Posts: 11207
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: Why does the Part --> booleans returns Compounds

Post by jmaustpc »

bernd wrote:
wmayer wrote:Up to my knowledge boolean operations always returned a compound independent of whether it's a single solid or a million. Thus it's up to the caller of the function to unpack a single solid if this is what he expects.

Code: Select all

result = ...
solid = result.Solids[0]
This python snippets is exactly what I would like to get rid off because it is not parametric and it is not in user GUI.

Does it make sense to create a mantis for a new preference for part. A small wrapper around the part booleans. If a boolean returns one solid in a compound the solid is returned instead of the compound. The resulting object in FreeCAD tree would than be a solid.
At one time in FreeCAD, a Part Fuse output would be invalid if the Fuse did not create a single solid. My understanding was that the creation of a Compound from a fuse is so that a fuse of more than one non-intersecting solids would be able to give a valid output.

If you are going to do something with the solid from a Fuse, you would need to first check that there is only one solid in the Fuse output compound.
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Why does the Part --> booleans returns Compounds

Post by bernd »

jmaustpc wrote:At one time in FreeCAD, a Part Fuse output would be invalid if the Fuse did not create a single solid. My understanding was that the creation of a Compound from a fuse is so that a fuse of more than one non-intersecting solids would be able to give a valid output.

If you are going to do something with the solid from a Fuse, you would need to first check that there is only one solid in the Fuse output compound.
Sure I'm only talking about the cases when the result is valid and only one solid. Ahh thats exactly the problem how to distinguish. I see ...
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Why does the Part --> booleans returns Compounds

Post by bernd »

Found it !!! Lattice2 has exact the tool I need, hopefully! It is called "CompoundFilter remove some childs from a Compound!
Attachments
parametric_get_solid_from_boolean.fcstd
(8.32 KiB) Downloaded 60 times
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Why does the Part --> booleans returns Compounds

Post by bernd »

For the last two month I have been using the tool CompoundFilter from lattice2 really really a lot. I would vote for integrating this tool in FreeCAD master? How about others?

@DeepSOIC:
What do you think about this?

bernd
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Why does the Part --> booleans returns Compounds

Post by DeepSOIC »

bernd wrote:For the last two month I have been using the tool CompoundFilter from lattice2 really really a lot. I would vote for integrating this tool in FreeCAD master? How about others?

@DeepSOIC:What do you think about this?
Actually, that was the second tool added to Lattice, and I was considering to merge this tool into FreeCAD from the very beginning.

Do you have a good suggestion as to where the tool should be? What workbench?
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Why does the Part --> booleans returns Compounds

Post by triplus »

As workbench is more or less organizational structure and the basic unit is the tool itself i guess choose one of the Python based workbenches or just add Lattice to FreeCAD by default.
Post Reply