Browse Source

fixed bug when selecting linked objects

pull/1/head
Youen 2 years ago
parent
commit
dd3044dbb6
  1. 17
      ahb_document_observer.py

17
ahb_document_observer.py

@ -16,11 +16,15 @@ class DocLinkObserver:
objList = App.getDocument(doc).getObject(obj).getSubObjectList(sub) objList = App.getDocument(doc).getObject(obj).getSubObjectList(sub)
# Build the name of the selected sub-object for multiple sub-assembly levels # Build the name of the selected sub-object for multiple sub-assembly levels
subObjName = '' subObjName = ''
# first look for the linked object of the selected entity: # look for the link to the selected entity.
# Get linked object name that handles sub-sub-assembly # We select the first link we find (removing the "break" statement would instead select the bottom-most sub-sub-...-sub-assembly)
for subObj in objList: for subObj in objList:
if subObj.TypeId=='App::Link': if subObj.TypeId=='App::Link':
subObjName = subObjName + subObj.Name + '.' subObjName = subObjName + subObj.Name + '.'
break
elif subObj.TypeId == 'Part::FeaturePython' and hasattr(subObj, 'LinkedObject'): # variant link
subObjName = subObjName + subObj.Name + '.'
break
# if no App::Link found, let's look for other things: # if no App::Link found, let's look for other things:
if subObjName == '': if subObjName == '':
for subObj in objList: for subObj in objList:
@ -28,11 +32,12 @@ class DocLinkObserver:
# the objList contains also the top-level object, don't count it twice # the objList contains also the top-level object, don't count it twice
if subObj.Name != obj: if subObj.Name != obj:
subObjName = subObjName + subObj.Name + '.' subObjName = subObjName + subObj.Name + '.'
break
# if we found something, make it the selection # if we found something, make it the selection
if subObjName != '': #if subObjName != '':
Gui.Selection.removeSelection(doc, obj, sub) Gui.Selection.removeSelection(doc, obj, sub)
Gui.Selection.addSelection(doc, obj, subObjName) Gui.Selection.addSelection(doc, obj, subObjName)
#FCC.PrintMessage("*"+doc+"*"+obj+"*"+subObjName+"*\n") #FCC.PrintMessage("*"+doc+"*"+obj+"*"+subObjName+"*\n")
# The main document observer (also observes selections) # The main document observer (also observes selections)
class DocObserver: class DocObserver:

Loading…
Cancel
Save