Pardon me if this is a beginner question..
# optionVar name: (type, default value, corresponding class attribute)
# The class methods only check for 'iv' and 'fv' types while looping thru
spOptionVars = {"spTransformRotate": ("iv", 1, "transform_rotate"),
"spPaintDistance": ("fv", 10, "paint_distance")}
class spToolOption (object):
def __init__ (self):
self.transform_rotate = True
self.paintDist = 10
...
...
def commitVars(self):
"""
Updates the change in value of the variables if any
"""
for name, info in spOptionVars.iteritems():
type, value, varname = info
if (type == 'iv'):
mc.optionVar(iv=(name, int(self.__dict__[varname])))
elif (type == 'fv'):
mc.optionVar(fv=(name, self.__dict__[varname]))
print ">>> 1. ", name
print ">>> 2. ", self.__dict__[varname]
print ">>> 3. ", varname
While I am using a text field which triggers this 'paint_distance', as soon
as there is a change in value in that text field, it will updates the
values in the dict accordingly.
However as its initial variable name is 'paintDistance', I changed it to
'paint_distance' and this updating is no longer working.
I did a double/triple check to make sure that all 'paintDistance' names are
changed to 'paint_distance' and only in the above code, only
'spPaintDistance' exists in that
code portion above.
Also. any changes in the naming such as 'paintDist' etc will simply not
work.
# Before any value change
>>> 1. spPaintDistance
>>> 2. 10
>>> 3. paint_distance
Suppose I am changing the value from 10 to 5, it still reflects as 10.
# After any value change
>>> 1. spPaintDistance
>>> 2. 10
>>> 3. paint_distance
It will only change to value of 5 unless I remove the underscores and
change it to 'paintDistance' which is its default name that was given in
the first place.
Suppose I am changing the value from 10 to 5, it still reflects as 10.
# After any value change
>>> 1. spPaintDistance
>>> 2. 5
>>> 3. paintDistance
Anyone can enlighten me on this part?
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/4cecdfe8-6c8d-4d2f-9a4c-995dd64f8d0c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.