Now I want to get the linked vertex in the execute method to move the box to the location of that linked vertex.
Code: Select all
obj.Shape = Part.makeBox(obj.Length, obj.Width, obj.Height)
# something like this:
# obj.Shape = Part.makeBox(obj.Length, obj.Width, obj.Height, App.Vector(vertex.X, vertex.Y, vertex.Z))
Because PropertyLinkSub only stores the vertex name, it doesnt seem obvious to me how I can retrieve the vertex object to get its x, y and z.
I know that this is potentially unstable and might need to be reassigned, due to the changing topo names, but thats a tradeoff that I am willing to take.
Code: Select all
class Box():
def __init__(self, obj):
"""
Default constructor
"""
self.Type = 'box'
obj.Proxy = self
obj.addProperty('App::PropertyString', 'Description', 'Base', 'Box description').Description = "Just a simple box"
obj.addProperty('App::PropertyLength', 'Length', 'Dimensions', 'Box length').Length = 10.0
obj.addProperty('App::PropertyLength', 'Width', 'Dimensions', 'Box width').Width = 5.0
obj.addProperty('App::PropertyLength', 'Height', 'Dimensions', 'Box height').Height = 10.0
obj.addProperty("App::PropertyLinkSub", "LinkSub", "Subsection", "Description for tooltip")
def execute(self, obj):
"""
Called on document recompute
"""
obj.Shape = Part.makeBox(obj.Length, obj.Width, obj.Height)