Ticket #3932 - Selecting solids on interior of CompSolid
Moderator: bernd
Forum rules
and Helpful information for the FEM forum
and Helpful information for the FEM forum
Ticket #3932 - Selecting solids on interior of CompSolid
I have been having some trouble assigning materials to components of a CompSolid that are completely enclosed. I was following this tutorial, but unfortunately I do not get the same result when I select the interior face (my attempt attached). On 0.17 it just selects the outer solid again without complaint. On 0.18, I am told that "Face belongs to more than one solid", and the mesh region/material does not get assigned. Am I doing something wrong, and if not how can I get around it?
A related question: I originally tried to tackle this by using the CompoundFilter type 'specific-items'. This works with BooleanFragments in Standard mode (although it was not automatically recomputing the geometry when the percentages were altered - which I think it probably should). But in CompSolid mode, CompoundFilter does not seem to work in with either 'window-volume' or 'specific item' types, unless 100% of the solids are shown. Is this the intended behaviour?
Thank you!
OS: Debian GNU/Linux buster/sid
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.
Build type: Release
Python version: 2.7.15+
Qt version: 5.11.3
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedKingdom (en_GB)
A related question: I originally tried to tackle this by using the CompoundFilter type 'specific-items'. This works with BooleanFragments in Standard mode (although it was not automatically recomputing the geometry when the percentages were altered - which I think it probably should). But in CompSolid mode, CompoundFilter does not seem to work in with either 'window-volume' or 'specific item' types, unless 100% of the solids are shown. Is this the intended behaviour?
Thank you!
OS: Debian GNU/Linux buster/sid
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.
Build type: Release
Python version: 2.7.15+
Qt version: 5.11.3
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedKingdom (en_GB)
- Attachments
-
- test.fcstd
- (12.92 KiB) Downloaded 98 times
Last edited by Kunda1 on Wed Sep 11, 2019 9:18 pm, edited 1 time in total.
Reason: Added ticket number to thread title
Reason: Added ticket number to thread title
Re: Selecting solids on interior of CompSolid
Use 0.18 dev version there is a clipping tool in FEM which makes it easy to select inner solids.
BTW there have been tons of fixes in the regard of FEM in 0.18 !
BTW there have been tons of fixes in the regard of FEM in 0.18 !
Re: Selecting solids on interior of CompSolid
Thanks bernd. I just tried the clipping tool, but I'm afraid I still have the same problem (see attachment).
As an aside, I'm not sure that the clipping tool is the best long term solution for this. The Selection Tools mod does seem to correctly list sub-objects in its context menu. Is it possible to make these work (I presume there is a good reason why it does not already...), and/or have some way to cycle through sub-objects under the mouse cursor?
Really pleased to hear about the fixes
thanks!
As an aside, I'm not sure that the clipping tool is the best long term solution for this. The Selection Tools mod does seem to correctly list sub-objects in its context menu. Is it possible to make these work (I presume there is a good reason why it does not already...), and/or have some way to cycle through sub-objects under the mouse cursor?
Really pleased to hear about the fixes

- Attachments
-
- clipping_screenshot.png (128.27 KiB) Viewed 4644 times
Re: Selecting solids on interior of CompSolid
ahh the problem is on inner solids all element are shared between the two solids. You could make the BooleanFragment invisible and use the base solids instead. The geometry of them needs to be equal. But be carefull, if more than 2 Solids are involved the geometry of the base solid might not be equal with the solid you would like to select in BooldeanFragment.
hope that helps, bernd
hope that helps, bernd
Re: Selecting solids on interior of CompSolid
some selector would be needed to choose which solid to add. Feel free to add a mantis issue for this ...
- DeepSOIC
- Veteran
- Posts: 7900
- Joined: Fri Aug 29, 2014 12:45 am
- Location: used to be Saint-Petersburg, Russia
Re: Selecting solids on interior of CompSolid
Code: Select all
class AmbiguousSelectionError(ValueError):
pass
def pickSolid(subelement, shape):
element_extractor = {
'Vertex': (lambda sh: sh.Vertexes),
'Edge': (lambda sh: sh.Edges ),
'Face': (lambda sh: sh.Faces ),
} [subelement.ShapeType]
matches = [] # list of tuples: (solid, index_of_shell)
for solid in shape.Solids:
for index, shell in enumerate(solid.childShapes()):
for el in element_extractor(shell):
if el.isSame(subelement):
matches.append((solid, index))
if len(matches) == 1:
return matches[0][0]
elif len(matches) == 2:
# face belongs to two solids. If one is inside another, we should pick the inner solid.
# The difference is, for the inner solid, the selected element is on the outer shell (index 0),
# but for the other one it is on an inner shell (index > 0)
solid1, index1 = matches[0]
solid2, index2 = matches[1]
if index1 == index2 == 0:
raise AmbiguousSelectionError()
elif index1 > 0 and index2 > 0:
#compsolids can't share inner shells, this shouldn't happen
raise AmbiguousSelectionError()
elif index1 > 0 and index2 == 0:
return solid2
elif index1 == 0 and index2 > 0:
return solid1
else:
assert(False)
else:
#three or more solids share this element. Can't sort out.
raise AmbiguousSelectionError()
#try it!
Part.show(pickSolid(Gui.Selection.getSelectionEx()[0].SubObjects[0], Gui.Selection.getSelectionEx()[0].Object.Shape))
- DeepSOIC
- Veteran
- Posts: 7900
- Joined: Fri Aug 29, 2014 12:45 am
- Location: used to be Saint-Petersburg, Russia
Re: Selecting solids on interior of CompSolid
Okay, that code above can only work if the inner solid is completely buried inside of another solid. There is a more difficult case (and also more "practical"):
that can't be sorted out by the piece of code above. I'm thinking on how to improve/redesign it to treat this case too.