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)
# Build the name of the selected sub-object for multiple sub-assembly levels
subObjName = ''
# first look for the linked object of the selected entity:
# Get linked object name that handles sub-sub-assembly
# look for the link to the selected entity.
# 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:
if subObj.TypeId=='App::Link':
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 subObjName == '':
for subObj in objList:
@ -28,11 +32,12 @@ class DocLinkObserver:
# the objList contains also the top-level object, don't count it twice
if subObj.Name != obj:
subObjName = subObjName + subObj.Name + '.'
break
# if we found something, make it the selection
if subObjName != '':
Gui.Selection.removeSelection(doc, obj, sub)
Gui.Selection.addSelection(doc, obj, subObjName)
#FCC.PrintMessage("*"+doc+"*"+obj+"*"+subObjName+"*\n")
#if subObjName != '':
Gui.Selection.removeSelection(doc, obj, sub)
Gui.Selection.addSelection(doc, obj, subObjName)
#FCC.PrintMessage("*"+doc+"*"+obj+"*"+subObjName+"*\n")
# The main document observer (also observes selections)
class DocObserver:

Loading…
Cancel
Save