The question left is how did bernd the trick in FEM-wb mesh-Groups (e.g. selectionParser in _TaskPanelFemMeshGroup.py)?
I did study his code a bit but could not find the final clue.
selection = FreeCADGui.Selection.getSelection()
print('selection element changed to Solid: ', selection[0].Shape.ShapeType, ' ', selection[0].Name)
for i, s in enumerate(selection[0].Shape.Solids):
for e in s.Edges:
print e
print
for i, s in enumerate(selection[0].Shape.Solids):
for e in s.Faces:
print e
selection = FreeCADGui.Selection.getSelection()
print('selection element changed to Solid: ', selection[0].Shape.ShapeType, ' ', selection[0].Name)
for i, s in enumerate(selection[0].Shape.Solids):
for e in s.Edges:
print e
print
for i, s in enumerate(selection[0].Shape.Solids):
for e in s.Faces:
print e
mario
Hi mario,
This 'only' lists only all Edges and Fases of all Solids. It does not give a clue how the Solids 's' are named.
>>> selection = FreeCADGui.Selection.getSelection()
>>> print('selection element changed to Solid: ', selection[0].Shape.ShapeType, ' ', selection[0].Name)
('selection element changed to Solid: ', 'Compound', ' ', 'BooleanFragments')
>>>
>>> for i, s in enumerate(selection[0].Shape.Solids):
... for e in s.Edges:
... print e
...
<Edge object at 0x28ba760>
<Edge object at 0x2930cd0>
<Edge object at 0x2931810>
<Edge object at 0x292ddb0>
<Edge object at 0x2932640>
<Edge object at 0x292e2b0>
<Edge object at 0x28a00b0>
<Edge object at 0x29243f0>
<Edge object at 0x2821080>
<Edge object at 0x275fb70>
<Edge object at 0x1b91140>
<Edge object at 0x28c7da0>
<Edge object at 0x2931cb0>
<Edge object at 0x289de20>
<Edge object at 0x29326f0>
<Edge object at 0x2936860>
<Edge object at 0x2932ab0>
<Edge object at 0x281d2b0>
<Edge object at 0x292d7f0>
<Edge object at 0x292dcb0>
<Edge object at 0x289d9e0>
<Edge object at 0x289e0c0>
<Edge object at 0x28b9160>
<Edge object at 0x2936ee0>
<Edge object at 0x289c500>
<Edge object at 0x291a040>
<Edge object at 0x28c22f0>
<Edge object at 0x29bd0c0>
<Edge object at 0x2930c00>
<Edge object at 0x2931d90>
<Edge object at 0x2929c80>
<Edge object at 0x292dbe0>
<Edge object at 0x28bc6b0>
>>> for i, s in enumerate(selection[0].Shape.Solids):
... for e in s.Faces:
... print e
...
<Face object at 0x1d1ac10>
<Face object at 0x28c5810>
<Face object at 0x2929260>
<Face object at 0x28acd20>
<Face object at 0x2a537d0>
<Face object at 0x28bc6b0>
<Face object at 0x28d8a00>
<Face object at 0x292bcf0>
<Face object at 0x29378f0>
<Face object at 0x28b5c00>
<Face object at 0x2933d50>
<Face object at 0x2939290>
<Face object at 0x2929260>
<Face object at 0x28d65e0>
<Face object at 0x28e40b0>
<Face object at 0x28adfc0>
<Face object at 0x28ae290>
>>>
BR,
HoWil
ps.: I removed the single print in the middle without output.
The name of Solid[0] is Solid1 same name system as for Vertexes, Edges and Faces! The problem is how to get the solid, becaus getElement does not return the solid (see my last post), thus I implemented some own get_element in FemMeshTools which returns solids too.
The name of Solid[0] is Solid1 same name system as for Vertexes, Edges and Faces! The problem is how to get the solid, becaus getElement does not return the solid (see my last post), thus I implemented some own get_element in FemMeshTools which returns solids too.
Hi Bernd,
So you search through all solids in Fusion and look for the generic names 'Solid1', 'Solid2', ... ?
I don't like it... but if this is the only solution than I take it .
BR,
HoWil
I might have not 100% understood what exactly your problem is about.
HoWil wrote:So you search through all solids in Fusion and look for the generic names 'Solid1', 'Solid2', ... ?
I don't like it... but if this is the only solution than I take it .
To select an solid out of an CompSolid or an Compound I activate a solid selection mode. In this mode the user has to select an edge or vertex which only belongs to one solid. Thus the solid is found. The reason is, there is no solid selection mode in FreeCAD selection system. See post viewtopic.php?f=10&t=18937#p147550 To save the solid in the reference shape list for later use I use the position in the solids list of the shape. Solids[0] is 'Solid1', Solids[1] is 'Solid2'
Just realized the system might not work if a solid is inside another solid, because all elements of the inner solid belong to the outer solid too. I need to try this on the mesh region object.
bernd wrote:Just realized the system might not work if a solid is inside another solid, because all elements of the inner solid belong to the outer solid too.
Then I can suggest this approach: "if in doubt, choose one with the smaller volume".
bernd wrote:Just realized the system might not work if a solid is inside another solid, because all elements of the inner solid belong to the outer solid too.
Then I can suggest this approach: "if in doubt, choose one with the smaller volume".
Good idea, but could return the wrong one, because the inner could have less volume than the outer (the outer solid has not the volume of the inner, in case of a CompSolid). The bbox might be better approach. I really need to test ...