Copy constraint properties when multiply and expand

This commit is contained in:
Zheng, Lei 2018-08-02 21:05:18 +08:00
parent 234df236b4
commit 58a6ad6752
3 changed files with 15 additions and 1 deletions

View File

@ -1666,7 +1666,10 @@ class AsmConstraint(AsmGroup):
Assembly = assembly,
Constraint = None,
Elements = info)
AsmConstraint.make(typeid,sel,undo=False)
newCstr = AsmConstraint.make(typeid,sel,undo=False)
Constraint.copy(cstr,newCstr)
for element,target in zip(elements,newCstr.Group):
target.Offset = element.Offset
cstr.Document.removeObject(cstr.Name)
FreeCAD.closeActiveTransaction()
return True

View File

@ -471,6 +471,10 @@ class Constraint(ProxyType):
def canMultiply(mcs,obj):
return getattr(obj,mcs.propMultiply(),None)
@classmethod
def copy(mcs,obj,target):
mcs.getProxy(obj).__class__.copyProperties(obj,target)
@classmethod
def setDisable(mcs,obj):
return setattr(obj,mcs._disabled,True)

View File

@ -246,6 +246,13 @@ class ProxyType(type):
def getPropertyInfoList(cls):
return []
def copyProperties(cls,obj,target):
mcs = cls.__class__
for key in cls.getPropertyInfoList():
prop = mcs.getPropertyInfo(key)
if not prop.Internal:
setattr(target,prop.Name,prop.get(obj))
def getName(cls):
return cls.__name__