realthunder wrote: ↑Wed Feb 12, 2020 9:33 am
Slight difference than the one described above. appLinkExecute() will not be called on array element object, only on the parent array link, with additional third (index) and fourth (element object) argument. In case the array is collapsed, fourth element will be None. If linkElement is not None, you can change its placement directly. If it is None, you can change the placement with linkObj.PlacementList[index]. Anyway, handling array is kind of tricky. I suggest you try normal link first.
Noting the PR had been merged, thanks!, finally I am testing (normal Link first as suggested) to implement a method to calculate its Placement in the Linked Feature Python
To enable that, I need a few parameters to be input by Users, so in original Feature Python, there are a few App::PropertyString added. For the Link objects, these are repeated in the appLinkExecute(). Whilst it works (screencapture), these lines would be run everytime appLinkExecute() is run ...
[EDIT - LinkObj rather than Obj ]
Code: Select all
class ArchSketch():
def __init__(self, obj):
if not hasattr(obj,"Test"):
obj.addProperty("App::PropertyString","Test","TestLink","Testing - appLinkExecute")
...
def appLinkExecute(self, obj, linkObj, index, linkElement):
if not hasattr(linkObj,"Test"):
linkObj.addProperty("App::PropertyString","Test","TestLink","Testing - appLinkExecute")
print ("linkObj.Test is - " , linkObj.Test)
print (self)
print (obj.Name)
print (linkObj.Name)
print (index)
print (linkElement)
Wondering if similar to appLinkExecute(), an appLinkInit() be added so whenever a Link is created, it looks if there is appLinkInit() and to run it for once ?
[EDIT - LinkObj rather than Obj ]
Code: Select all
class ArchSketch():
def __init__(self, obj):
if not hasattr(obj,"Test"):
obj.addProperty("App::PropertyString","Test","TestLink","Testing - appLinkExecute")
...
def appLinkInit(self, obj, linkObj, index, linkElement):
if not hasattr(linkObj,"Test"):
linkObj.addProperty("App::PropertyString","Test","TestLink","Testing - appLinkExecute")
def appLinkExecute(self, obj, linkObj, index, linkElement):
print ("linkObj.Test is - " , linkObj.Test)
print (self)
print (obj.Name)
print (linkObj.Name)
print (index)
print (linkElement)
Thanks.
[EDIT - LinkObj rather than Obj ]
- Screenshot from 2020-09-06 08-12-00.png (205.87 KiB) Viewed 2254 times
- Screenshot from 2020-09-06 08-11-39.png (212.51 KiB) Viewed 2254 times