I need to improve the following script which allows for listing all elements below a cursor-click: https://forum.freecadweb.org/viewtopic. ... or#p151950
The goal is to click on e.g. a Face of a Fusion of two Solids and get all elements/objects below the click. I want to list the Faces below the cursor, the Fusion itself, and the two Solids, at least the one below the cursor.
I get the Faces and the Compound from element_list in the script below. The Solids inside the Compound can also be listed.
The only thing I miss is how can I identify these solids. How do I get their Label/Name to select them... in the case below the Label/Name of 's'.
Code: Select all
pos = (0, 0) # The compound in question has to be positioned at the lower left corner of the 3D-view-Window !!!!!!!!
element_list = FreeCADGui.ActiveDocument.ActiveView.getObjectsInfo((int(pos[0]), int(pos[1])))
e = element_list[0]
label_object = str(e["Object"]) # the label of e.g. the compound
label_component = str(e["Component"]) # the label of e.g. a face
compound = FreeCAD.ActiveDocument.getObject(label_object)
solids = compound.Shape.Solids
s = solids[0] # How do I identify this solid; how do I get its label???
HoWil