Draft: separate target into object and subelements in make_label
Before, the `make_label` function had a `target` parameter that had to be a `LinkSub`, `[Part::Feature, "Edge1"]`. However, it is easier to pass the individual components separately using two parameters, `target_object` and `subelements`, which can then be assembled into `[target_object, subelements]`. The second element is optional, so it can be set to `None`, and then the second element will be converted to an empty list, `[target_object, []]`, as required by the Label's underlying `Target` property.
This commit is contained in:
@@ -133,16 +133,14 @@ class Label(gui_base_original.Creator):
|
||||
dist = -dist
|
||||
|
||||
tp = DraftVecUtils.toString(targetpoint)
|
||||
sel = ""
|
||||
sel = None
|
||||
if self.sel:
|
||||
sel = "FreeCAD.ActiveDocument." + self.sel.Object.Name
|
||||
|
||||
if self.sel.SubElementNames:
|
||||
sub = "'" + self.sel.SubElementNames[0] + "'"
|
||||
else:
|
||||
sub = "[]"
|
||||
sel = "["
|
||||
sel += "FreeCAD.ActiveDocument." + self.sel.Object.Name + ", "
|
||||
sel += sub
|
||||
sel += "]"
|
||||
sub = "None"
|
||||
|
||||
pl = "FreeCAD.Placement"
|
||||
pl += "("
|
||||
@@ -156,7 +154,8 @@ class Label(gui_base_original.Creator):
|
||||
_cmd += "target_point=" + tp + ", "
|
||||
_cmd += "placement=" + pl + ", "
|
||||
if sel:
|
||||
_cmd += "target=" + sel + ", "
|
||||
_cmd += "target_object=" + sel + ", "
|
||||
_cmd += "subelements=" + sub + ", "
|
||||
_cmd += "label_type=" + "'" + self.labeltype + "'" + ", "
|
||||
# _cmd += "custom_text=" + "'Label'" + ", "
|
||||
_cmd += "direction=" + "'" + direction + "'" + ", "
|
||||
|
||||
Reference in New Issue
Block a user