assembly: fix make constraint on linked assembly

Related #159
This commit is contained in:
Zheng, Lei 2018-12-10 13:45:46 +08:00
parent 69544199fd
commit 8f4d39e126

View File

@ -1892,6 +1892,7 @@ class AsmConstraint(AsmGroup):
def make(typeid,sel=None,name='Constraint',undo=True): def make(typeid,sel=None,name='Constraint',undo=True):
if not sel: if not sel:
sel = AsmConstraint.getSelection(typeid) sel = AsmConstraint.getSelection(typeid)
assembly = resolveAssembly(sel.Assembly)
if sel.Constraint: if sel.Constraint:
if undo: if undo:
FreeCAD.setActiveTransaction('Assembly change constraint') FreeCAD.setActiveTransaction('Assembly change constraint')
@ -1899,7 +1900,7 @@ class AsmConstraint(AsmGroup):
else: else:
if undo: if undo:
FreeCAD.setActiveTransaction('Assembly create constraint') FreeCAD.setActiveTransaction('Assembly create constraint')
constraints = sel.Assembly.Proxy.getConstraintGroup() constraints = assembly.getConstraintGroup()
cstr = constraints.Document.addObject("App::FeaturePython", cstr = constraints.Document.addObject("App::FeaturePython",
name,AsmConstraint(constraints),None,True) name,AsmConstraint(constraints),None,True)
ViewProviderAsmConstraint(cstr.ViewObject) ViewProviderAsmConstraint(cstr.ViewObject)
@ -1933,7 +1934,7 @@ class AsmConstraint(AsmGroup):
subname = sel.SelSubname subname = sel.SelSubname
else: else:
subname = '' subname = ''
subname += sel.Assembly.Proxy.getConstraintGroup().Name + \ subname += assembly.getConstraintGroup().Name + \
'.' + cstr.Name + '.' '.' + cstr.Name + '.'
FreeCADGui.Selection.addSelection(sel.SelObject,subname) FreeCADGui.Selection.addSelection(sel.SelObject,subname)
FreeCADGui.Selection.pushSelStack() FreeCADGui.Selection.pushSelStack()