I thought 'MapMode' is Sketch's 'inherent' function so no need to addExtension, following the example and added that code. Not sure if linkFp.positionBySupport() is needed.
In any rate, it seem really need PR to merge, currently anything try to alter Link's 'Attachment attributes' become changing Linked object's 'Attachment attributes'. So the Linked Object move instead of the Links. Seems this problem affect adding Attacher to Links only, adding Attacher to other objects has been working right ?
Have to wait. Thanks !
Code: Select all
import FreeCAD
class ArchSketchObject:
def __init__(self, obj):
pass
class ArchSketch(ArchSketchObject):
def __init__(self, obj):
ArchSketchObject.__init__(self, obj)
def setProperties(self, fp):
fp.Proxy = self
if not hasattr(self,"Type"):
self.Type = "ArchSketch"
def execute(self, fp):
updateAttachmentOffset(fp)
def onChanged(self, fp, prop):
pass
def setPropertiesLinkCommon(self, orgFp, linkFp=None):
if linkFp:
fp = linkFp
print (" It is linFp")
else:
fp = orgFp
print (" It is fp")
prop = fp.PropertiesList
if not fp.hasExtension('Part::AttachExtension'):
print (" debug - Part::AttachExtension NOT in prop")
fp.addExtension('Part::AttachExtensionPython', None)
else:
print (" debug - Part::AttachExtension in prop")
def appLinkExecute(self, fp, linkFp, index, linkElement):
self.setPropertiesLinkCommon(fp, linkFp)
updateAttachmentOffset(fp, linkFp)
#linkFp.positionBySupport() # need this ?
def updateAttachmentOffset(fp, linkFp=None):
if linkFp:
fp = linkFp
print (" fp = linkFp, fp.Name is ... ", fp.Name)
tempAttachmentOffset = FreeCAD.Placement(FreeCAD.Vector(2000,500,0),FreeCAD.Rotation(FreeCAD.Vector(0,0,1),0))
print (" tempAttachmentOffset is ... ", tempAttachmentOffset)
fp.MapMode = "ObjectXY"
support = FreeCAD.ActiveDocument.getObject("ArchSketch065")
fp.Support = support
else:
print (" fp is ... ", fp.Name)
tempAttachmentOffset = FreeCAD.Placement(FreeCAD.Vector(0,500,0),FreeCAD.Rotation(FreeCAD.Vector(0,0,1),0))
print (" tempAttachmentOffset is ... ", tempAttachmentOffset)
fp.MapMode = "ObjectXY"
support = FreeCAD.ActiveDocument.getObject("ArchSketch064")
fp.Support = support
fp.AttachmentOffset = tempAttachmentOffset
print (" fp.AttachmentOffset = tempAttachmentOffset" )
print (" (fp / linkfp) fp.AttachmentOffset is ... ", fp.AttachmentOffset)