-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FreeCADGui.Selection results with linked parts #41
Comments
|
Thanks. It returns more "logical" response now, but it looks like I don't understand something in the naming... I want to use that information to get the selected object from the Gui.ActiveDocument using the getObject method. Didn't check yet all the Selection code, but there might be "getSelected" method, or something similar that returns the selected object. Want to understand how can I handle the returned name in case I won't find the needed method |
On of the problems with the callback is that all the parameters are names of the objects and not a reference to them, so I can't call any of the methods, such as obj.getSubObjectList(sub) |
Something like this def addSelection(self, doc, obj, sub, pos):
App.getDocument(doc).getObject(obj).getObjectList(sub) |
print(App.getDocument(doc).getObject(obj).getObjectList(sub)) The returned 'doc' is the active document, the 'obj' is the "Model" branch in Assemby4 tree, getObject returns Part, which doesn't have the getObjectList... |
oops, sorry, should be getSubObjectList() |
Thanks! |
It returns the entire hierarchy of the current selected object. So if there are more nested parts, you'll get longer list. |
ok, understand. |
@realthunder , will appreciate your help with the followup regarding that. What is the meaning of the "." at the end of the name? I get to the proper object name, try to pass it to the setSelection method, that doesn't find the sub-object. |
Because the hierarchical selection capability is added later. Originally |
Ok, thanks for the answers, I was able to implement the feature I wanted with your help. |
Hello @realthunder ,
I think the FreeCADGui.Selection doesn't work properly with linked parts.
Lets say I have the same part linked to the document several times with different names.
the addSelection callback is called with the following parameters:
doc - document name
obj - object name
sub - part of the object name
pnt - coordinates of the click (not interesting for that case)
I'm trying to add a feature to Assembly4 and try to use Selection callbacks.
When I click on the part link in the tree view, I get expected results:
doc - current document name
obj - the linked part name as appearing in the tree view
When I click on a body object of the the same part I get results that will not allow me to determine what part the body belongs to:
doc - name of the linked document (the original document, not the linked name)
obj - "Part__Feature" string
I understand that the body belongs to the linked part, but without getting the name of the linked part in current document, the callback is useless in that case...
Is there a workaround for that? Or a fix will be needed?
Thanks.
The text was updated successfully, but these errors were encountered: