gui: support AsmElement(Link) in command GotoLinkedFinal
This commit is contained in:
parent
2e8146f756
commit
656fcdd2bd
54
gui.py
54
gui.py
|
@ -700,11 +700,65 @@ class AsmCmdGotoLinked(AsmCmdBase):
|
||||||
FreeCADGui.Selection.clearSelection()
|
FreeCADGui.Selection.clearSelection()
|
||||||
FreeCADGui.Selection.addSelection(sels[0].Object,subname)
|
FreeCADGui.Selection.addSelection(sels[0].Object,subname)
|
||||||
FreeCADGui.Selection.pushSelStack()
|
FreeCADGui.Selection.pushSelStack()
|
||||||
|
FreeCADGui.runCommand('Std_TreeSelection')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def IsActive(cls):
|
def IsActive(cls):
|
||||||
return FreeCADGui.isCommandActive('Std_LinkSelectLinked')
|
return FreeCADGui.isCommandActive('Std_LinkSelectLinked')
|
||||||
|
|
||||||
|
class AsmCmdGotoLinkedFinal(AsmCmdBase):
|
||||||
|
_id = 23
|
||||||
|
_menuText = 'Select linked final'
|
||||||
|
_tooltip = 'Select the deepest linked object'
|
||||||
|
_accel = 'A, F'
|
||||||
|
_toolbarName = ''
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def getIconName(cls):
|
||||||
|
return 'LinkSelectFinal'
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def Activated(cls):
|
||||||
|
from .assembly import isTypeOf, AsmElement, AsmElementLink
|
||||||
|
sels = FreeCADGui.Selection.getSelectionEx('',0,True)
|
||||||
|
if not sels:
|
||||||
|
return
|
||||||
|
if not sels[0].SubElementNames:
|
||||||
|
FreeCADGui.runCommand('Std_LinkSelectFinal')
|
||||||
|
return
|
||||||
|
subname = sels[0].SubElementNames[0]
|
||||||
|
obj = sels[0].Object.getSubObject(subname,retType=1)
|
||||||
|
if not isTypeOf(obj,(AsmElementLink,AsmElement)):
|
||||||
|
FreeCADGui.runCommand('Std_LinkSelectFinal')
|
||||||
|
return
|
||||||
|
|
||||||
|
if isTypeOf(obj, AsmElementLink):
|
||||||
|
obj = obj.getSubObject(subname,retType=1)
|
||||||
|
|
||||||
|
while isTypeOf(obj,AsmElement):
|
||||||
|
linked,subname = obj.LinkedObject
|
||||||
|
obj = linked.getSubObject(subname,retType=1)
|
||||||
|
|
||||||
|
obj = obj.getLinkedObject(True)
|
||||||
|
|
||||||
|
import Part
|
||||||
|
subname = Part.splitSubname(subname)[-1]
|
||||||
|
|
||||||
|
FreeCADGui.Selection.pushSelStack()
|
||||||
|
FreeCADGui.Selection.clearSelection()
|
||||||
|
FreeCADGui.Selection.addSelection(obj,subname)
|
||||||
|
FreeCADGui.Selection.pushSelStack()
|
||||||
|
FreeCADGui.runCommand('Std_TreeSelection')
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def IsActive(cls):
|
||||||
|
from .assembly import isTypeOf, AsmElement, AsmElementLink
|
||||||
|
sels = FreeCADGui.Selection.getSelectionEx('',0,True)
|
||||||
|
if len(sels)==1 and sels[0].SubElementNames:
|
||||||
|
obj = sels[0].Object.getSubObject(sels[0].SubElementNames[0],1)
|
||||||
|
if isTypeOf(obj, (AsmElementLink,AsmElement)):
|
||||||
|
return True
|
||||||
|
return FreeCADGui.isCommandActive('Std_LinkSelectFinal')
|
||||||
|
|
||||||
class AsmCmdUp(AsmCmdBase):
|
class AsmCmdUp(AsmCmdBase):
|
||||||
_id = 6
|
_id = 6
|
||||||
|
|
|
@ -38,7 +38,8 @@ class Assembly3Workbench(FreeCADGui.Workbench):
|
||||||
cmd.workbenchDeactivated()
|
cmd.workbenchDeactivated()
|
||||||
|
|
||||||
def Initialize(self):
|
def Initialize(self):
|
||||||
from .gui import AsmCmdManager,AsmCmdGotoRelation,AsmCmdGotoLinked
|
from .gui import AsmCmdManager,AsmCmdGotoRelation,\
|
||||||
|
AsmCmdGotoLinked, AsmCmdGotoLinkedFinal
|
||||||
AsmCmdManager.init()
|
AsmCmdManager.init()
|
||||||
cmdSet = set()
|
cmdSet = set()
|
||||||
for name,cmds in AsmCmdManager.Toolbars.items():
|
for name,cmds in AsmCmdManager.Toolbars.items():
|
||||||
|
@ -46,7 +47,7 @@ class Assembly3Workbench(FreeCADGui.Workbench):
|
||||||
self.appendToolbar(name,[cmd.getName() for cmd in cmds])
|
self.appendToolbar(name,[cmd.getName() for cmd in cmds])
|
||||||
self.appendToolbar('Assembly3 Navigation', ["Std_SelBack",
|
self.appendToolbar('Assembly3 Navigation', ["Std_SelBack",
|
||||||
"Std_SelForward",AsmCmdGotoRelation.getName(),
|
"Std_SelForward",AsmCmdGotoRelation.getName(),
|
||||||
AsmCmdGotoLinked.getName(), "Std_LinkSelectLinkedFinal",
|
AsmCmdGotoLinked.getName(), AsmCmdGotoLinkedFinal.getName(),
|
||||||
"Std_LinkSelectAllLinks","Std_TreeSelectAllInstances"])
|
"Std_LinkSelectAllLinks","Std_TreeSelectAllInstances"])
|
||||||
for name,cmds in AsmCmdManager.Menus.items():
|
for name,cmds in AsmCmdManager.Menus.items():
|
||||||
cmdSet.update(cmds)
|
cmdSet.update(cmds)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user