BaseFeature: add assureProperties method
This commit is contained in:
parent
c3bb345c3f
commit
22925c8187
|
@ -128,13 +128,19 @@ class LatticeFeature(object):
|
||||||
obj.addProperty("App::PropertyBool",prop,"Lattice","Makes the placement syncronized to Placement property. This will often make this object unmoveable. Not applicable to arrays.")
|
obj.addProperty("App::PropertyBool",prop,"Lattice","Makes the placement syncronized to Placement property. This will often make this object unmoveable. Not applicable to arrays.")
|
||||||
|
|
||||||
#ReferencePlacement: added/removed dynamically. Abscence = global origin. The placement
|
#ReferencePlacement: added/removed dynamically. Abscence = global origin. The placement
|
||||||
# value is treated "under Placement" if not exposing placement, else as "absolute".
|
# value is treated "under selfobj.Placement" if not exposing placement, else as "absolute".
|
||||||
# Use getReferencePlm/setReferencePlm methods to work with reference placement in a expose-placement-invariant method.
|
# Use getReferencePlm/setReferencePlm methods to work with reference placement in a expose-placement-invariant method.
|
||||||
|
|
||||||
|
self.assureProperties(obj)
|
||||||
self.derivedInit(obj)
|
self.derivedInit(obj)
|
||||||
|
|
||||||
obj.Proxy = self
|
obj.Proxy = self
|
||||||
|
|
||||||
|
def assureProperties(self, selfobj):
|
||||||
|
"""#overrideme Method to reconstruct missing properties, that appeared as new functionality was introduced.
|
||||||
|
Auto called from __init__ (and before derivedInit), and from execute (before derivedExecute)."""
|
||||||
|
pass
|
||||||
|
|
||||||
def assureProperty(self, selfobj, proptype, propname, defvalue, group, tooltip, readonly = False, hidden = False):
|
def assureProperty(self, selfobj, proptype, propname, defvalue, group, tooltip, readonly = False, hidden = False):
|
||||||
"""assureProperty(selfobj, proptype, propname, defvalue, group, tooltip): adds
|
"""assureProperty(selfobj, proptype, propname, defvalue, group, tooltip): adds
|
||||||
a property if one is missing, and sets its value to default. Does nothing if property
|
a property if one is missing, and sets its value to default. Does nothing if property
|
||||||
|
@ -178,6 +184,8 @@ class LatticeFeature(object):
|
||||||
def execute(self,obj):
|
def execute(self,obj):
|
||||||
# please, don't override. Override derivedExecute instead.
|
# please, don't override. Override derivedExecute instead.
|
||||||
|
|
||||||
|
self.assureProperties(obj)
|
||||||
|
|
||||||
plms = self.derivedExecute(obj)
|
plms = self.derivedExecute(obj)
|
||||||
|
|
||||||
if plms is not None:
|
if plms is not None:
|
||||||
|
|
|
@ -51,14 +51,11 @@ class LatticeInvert(lattice2BaseFeature.LatticeFeature):
|
||||||
obj.OrientMode = ['invert', 'keep', 'reset']
|
obj.OrientMode = ['invert', 'keep', 'reset']
|
||||||
obj.OrientMode = 'invert'
|
obj.OrientMode = 'invert'
|
||||||
|
|
||||||
self.assureProperties(obj)
|
|
||||||
|
|
||||||
def assureProperties(self, selfobj):
|
def assureProperties(self, selfobj):
|
||||||
|
super(LatticeInvert, self).assureProperties(selfobj)
|
||||||
self.assureProperty(selfobj, 'App::PropertyEnumeration', 'Referencing', ['Origin', 'Array\'s reference'], "Lattice Invert", "Sets which placement to use as origin")
|
self.assureProperty(selfobj, 'App::PropertyEnumeration', 'Referencing', ['Origin', 'Array\'s reference'], "Lattice Invert", "Sets which placement to use as origin")
|
||||||
|
|
||||||
def derivedExecute(self,obj):
|
def derivedExecute(self,obj):
|
||||||
self.assureProperties(obj)
|
|
||||||
|
|
||||||
# cache stuff
|
# cache stuff
|
||||||
placements = lattice2BaseFeature.getPlacementsList(obj.Base)
|
placements = lattice2BaseFeature.getPlacementsList(obj.Base)
|
||||||
|
|
||||||
|
|
|
@ -80,8 +80,6 @@ class LinearArray(lattice2BaseFeature.LatticeFeature):
|
||||||
obj.Step = 3.0
|
obj.Step = 3.0
|
||||||
obj.Count = 5.0
|
obj.Count = 5.0
|
||||||
|
|
||||||
self.assureProperties(obj)
|
|
||||||
|
|
||||||
def updateReadonlyness(self, obj):
|
def updateReadonlyness(self, obj):
|
||||||
link = screen(obj.Link)
|
link = screen(obj.Link)
|
||||||
obj.setEditorMode("Dir", 1 if (link and obj.DirIsDriven) else 0)
|
obj.setEditorMode("Dir", 1 if (link and obj.DirIsDriven) else 0)
|
||||||
|
@ -104,6 +102,8 @@ class LinearArray(lattice2BaseFeature.LatticeFeature):
|
||||||
valuestype= "App::PropertyDistance")
|
valuestype= "App::PropertyDistance")
|
||||||
|
|
||||||
def assureProperties(self, selfobj):
|
def assureProperties(self, selfobj):
|
||||||
|
super(LinearArray, self).assureProperties(selfobj)
|
||||||
|
|
||||||
assureProperty(selfobj, "App::PropertyLinkSub", "SubLink", sublinkFromApart(screen(selfobj.Link), selfobj.LinkSubelement), "Lattice Array", "Mirror of Object+SubNames properties")
|
assureProperty(selfobj, "App::PropertyLinkSub", "SubLink", sublinkFromApart(screen(selfobj.Link), selfobj.LinkSubelement), "Lattice Array", "Mirror of Object+SubNames properties")
|
||||||
|
|
||||||
created = self.assureProperty(selfobj,
|
created = self.assureProperty(selfobj,
|
||||||
|
@ -119,7 +119,6 @@ class LinearArray(lattice2BaseFeature.LatticeFeature):
|
||||||
|
|
||||||
def derivedExecute(self,obj):
|
def derivedExecute(self,obj):
|
||||||
self.assureGenerator(obj)
|
self.assureGenerator(obj)
|
||||||
self.assureProperties(obj)
|
|
||||||
self.updateReadonlyness(obj)
|
self.updateReadonlyness(obj)
|
||||||
|
|
||||||
# Apply links
|
# Apply links
|
||||||
|
|
|
@ -75,8 +75,6 @@ class PolarArray(lattice2BaseFeature.LatticeFeature):
|
||||||
obj.EndInclusive = False
|
obj.EndInclusive = False
|
||||||
obj.Count = 5
|
obj.Count = 5
|
||||||
|
|
||||||
self.assureProperties(obj)
|
|
||||||
|
|
||||||
def assureGenerator(self, obj):
|
def assureGenerator(self, obj):
|
||||||
'''Adds an instance of value series generator, if one doesn't exist yet.'''
|
'''Adds an instance of value series generator, if one doesn't exist yet.'''
|
||||||
if hasattr(self,"generator"):
|
if hasattr(self,"generator"):
|
||||||
|
@ -97,12 +95,13 @@ class PolarArray(lattice2BaseFeature.LatticeFeature):
|
||||||
self.generator.updateReadonlyness()
|
self.generator.updateReadonlyness()
|
||||||
|
|
||||||
def assureProperties(self, selfobj):
|
def assureProperties(self, selfobj):
|
||||||
|
super(PolarArray, self).assureProperties(selfobj)
|
||||||
|
|
||||||
assureProperty(selfobj, "App::PropertyLinkSub", "AxisSubLink", sublinkFromApart(screen(selfobj.AxisLink), selfobj.AxisLinkSubelement), "Lattice Array", "Mirror of Object+SubNames properties")
|
assureProperty(selfobj, "App::PropertyLinkSub", "AxisSubLink", sublinkFromApart(screen(selfobj.AxisLink), selfobj.AxisLinkSubelement), "Lattice Array", "Mirror of Object+SubNames properties")
|
||||||
|
|
||||||
|
|
||||||
def derivedExecute(self,obj):
|
def derivedExecute(self,obj):
|
||||||
self.assureGenerator(obj)
|
self.assureGenerator(obj)
|
||||||
self.assureProperties(obj)
|
|
||||||
self.updateReadonlyness(obj)
|
self.updateReadonlyness(obj)
|
||||||
|
|
||||||
# Apply links
|
# Apply links
|
||||||
|
|
|
@ -77,7 +77,6 @@ class PolarArray(APlm.AttachableFeature):
|
||||||
selfobj.addProperty('App::PropertyBool', 'FlipX', "Polar Array", "Reverses x axis of every placement.")
|
selfobj.addProperty('App::PropertyBool', 'FlipX', "Polar Array", "Reverses x axis of every placement.")
|
||||||
selfobj.addProperty('App::PropertyBool', 'FlipZ', "Polar Array", "Reverses z axis of every placement.")
|
selfobj.addProperty('App::PropertyBool', 'FlipZ', "Polar Array", "Reverses z axis of every placement.")
|
||||||
|
|
||||||
self.assureProperties(selfobj)
|
|
||||||
self.assureGenerator(selfobj)
|
self.assureGenerator(selfobj)
|
||||||
|
|
||||||
selfobj.ValuesSource = 'Generator'
|
selfobj.ValuesSource = 'Generator'
|
||||||
|
@ -88,6 +87,8 @@ class PolarArray(APlm.AttachableFeature):
|
||||||
selfobj.Count = 7
|
selfobj.Count = 7
|
||||||
|
|
||||||
def assureProperties(self, selfobj):
|
def assureProperties(self, selfobj):
|
||||||
|
super(PolarArray, self).assureProperties(selfobj)
|
||||||
|
|
||||||
# upgrades older versions of the feature
|
# upgrades older versions of the feature
|
||||||
created = self.assureProperty(selfobj,
|
created = self.assureProperty(selfobj,
|
||||||
'App::PropertyEnumeration',
|
'App::PropertyEnumeration',
|
||||||
|
|
|
@ -99,11 +99,12 @@ class LatticePopulateCopies(lattice2BaseFeature.LatticeFeature):
|
||||||
obj.addProperty("App::PropertyLink","PlacementsTo","Lattice PopulateCopies", "Placement or array of placements, containing target locations.")
|
obj.addProperty("App::PropertyLink","PlacementsTo","Lattice PopulateCopies", "Placement or array of placements, containing target locations.")
|
||||||
obj.addProperty("App::PropertyLink","PlacementsFrom", "Lattice PopulateCopies","Placement or array of placements to be treated as origins for PlacementsTo.")
|
obj.addProperty("App::PropertyLink","PlacementsFrom", "Lattice PopulateCopies","Placement or array of placements to be treated as origins for PlacementsTo.")
|
||||||
|
|
||||||
self.assureProperties(obj)
|
|
||||||
obj.OutputCompounding = "(autosettle)" # this is default value for new features.
|
obj.OutputCompounding = "(autosettle)" # this is default value for new features.
|
||||||
|
|
||||||
def assureProperties(self, obj):
|
def assureProperties(self, obj):
|
||||||
'''Adds properties that might be missing, because of loaded project made with older version. Handles version compatibility.'''
|
'''Adds properties that might be missing, because of loaded project made with older version. Handles version compatibility.'''
|
||||||
|
super(LatticePopulateCopies, self).assureProperties(obj)
|
||||||
|
|
||||||
propname = 'OutputCompounding'
|
propname = 'OutputCompounding'
|
||||||
if not hasattr(obj,propname):
|
if not hasattr(obj,propname):
|
||||||
obj.addProperty("App::PropertyEnumeration", propname, "Lattice PopulateCopies","In case single object copy is made, this property controls, if it's packed into compoud or not.")
|
obj.addProperty("App::PropertyEnumeration", propname, "Lattice PopulateCopies","In case single object copy is made, this property controls, if it's packed into compoud or not.")
|
||||||
|
@ -114,8 +115,6 @@ class LatticePopulateCopies(lattice2BaseFeature.LatticeFeature):
|
||||||
|
|
||||||
|
|
||||||
def derivedExecute(self,obj):
|
def derivedExecute(self,obj):
|
||||||
self.assureProperties(obj)
|
|
||||||
|
|
||||||
# cache stuff
|
# cache stuff
|
||||||
objectShape = screen(obj.Object).Shape
|
objectShape = screen(obj.Object).Shape
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user