Skip to content

Commit

Permalink
Draft: set the properties of PathArray through functions
Browse files Browse the repository at this point in the history
  • Loading branch information
vocx-fc authored and yorikvanhavre committed Jun 5, 2020
1 parent 9dd1c2e commit 572788e
Showing 1 changed file with 43 additions and 35 deletions.
78 changes: 43 additions & 35 deletions src/Mod/Draft/draftobjects/patharray.py
Expand Up @@ -126,6 +126,11 @@ def set_properties(self, obj):
else:
properties = []

self.set_general_properties(obj, properties)
self.set_align_properties(obj, properties)

def set_general_properties(self, obj, properties):
"""Set general properties only if they don't exist."""
if "Base" not in properties:
_tip = _tr("The base object that will be duplicated")
obj.addProperty("App::PropertyLinkGlobal",
Expand Down Expand Up @@ -160,38 +165,22 @@ def set_properties(self, obj):
_tip = _tr("Number of copies to create")
obj.addProperty("App::PropertyInteger",
"Count",
"General",
"Objects",
_tip)
obj.Count = 4

if "Align" not in properties:
_tip = _tr("Orient the copies along the path depending "
"on the 'Align Mode'.\n"
"Otherwise the copies will have the same orientation "
"as the original Base object.")
if self.use_link and "ExpandArray" not in properties:
_tip = _tr("Show the individual array elements "
"(only for Link arrays)")
obj.addProperty("App::PropertyBool",
"Align",
"Alignment",
_tip)
obj.Align = False

if "AlignMode" not in properties:
_tip = _tr("Method to orient the copies along the path.\n"
"- Original, X is curve tangent, Y is normal, "
"and Z is the cross product.\n"
"- Frenet uses a local coordinate system along "
"the path.\n"
"- Tangent is similar to 'Original' but the local X "
"axis is pre-aligned to 'Tangent Vector'.\n"
"To get better results with 'Original' and 'Tangent' "
"you may have to set 'Force Vertical' to true.")
obj.addProperty("App::PropertyEnumeration",
"AlignMode",
"Alignment",
"ExpandArray",
"Objects",
_tip)
obj.AlignMode = ['Original', 'Frenet', 'Tangent']
obj.AlignMode = 'Original'
obj.ExpandArray = False
obj.setPropertyStatus('Shape', 'Transient')

def set_align_properties(self, obj, properties):
"""Set general properties only if they don't exist."""
if "Xlate" not in properties:
_tip = _tr("Additional translation "
"that will be applied to each copy.\n"
Expand All @@ -212,8 +201,8 @@ def set_properties(self, obj):
obj.TangentVector = App.Vector(1, 0, 0)

if "ForceVertical" not in properties:
_tip = _tr("Force use of 'Vertical Vector' as Z direction "
"when using 'Original' or 'Tangent' align mode")
_tip = _tr("Force use of 'Vertical Vector' as local Z direction "
"when using 'Original' or 'Tangent' alignment mode")
obj.addProperty("App::PropertyBool",
"ForceVertical",
"Alignment",
Expand All @@ -229,15 +218,34 @@ def set_properties(self, obj):
_tip)
obj.VerticalVector = App.Vector(0, 0, 1)

if self.use_link and "ExpandArray" not in properties:
_tip = _tr("Show the individual array elements "
"(only for Link arrays)")
if "AlignMode" not in properties:
_tip = _tr("Method to orient the copies along the path.\n"
"- Original: X is curve tangent, Y is normal, "
"and Z is the cross product.\n"
"- Frenet: aligns the object following the local "
"coordinate system along the path.\n"
"- Tangent: similar to 'Original' but the local X "
"axis is pre-aligned to 'Tangent Vector'.\n"
"\n"
"To get better results with 'Original' or 'Tangent' "
"you may have to set 'Force Vertical' to true.")
obj.addProperty("App::PropertyEnumeration",
"AlignMode",
"Alignment",
_tip)
obj.AlignMode = ['Original', 'Frenet', 'Tangent']
obj.AlignMode = 'Original'

if "Align" not in properties:
_tip = _tr("Orient the copies along the path depending "
"on the 'Align Mode'.\n"
"Otherwise the copies will have the same orientation "
"as the original Base object.")
obj.addProperty("App::PropertyBool",
"ExpandArray",
"General",
"Align",
"Alignment",
_tip)
obj.ExpandArray = False
obj.setPropertyStatus('Shape', 'Transient')
obj.Align = False

def linkSetup(self, obj):
"""Set up the object as a link object."""
Expand Down

0 comments on commit 572788e

Please sign in to comment.