I have a plugin that defines several output plugs:
output_t_qqq = OpenMaya.MObject()
output_t_rrr = OpenMaya.MObject()
output_t_sss = OpenMaya.MObject()
output_t_ttt = OpenMaya.MObject()
These output plugs get added correctly as an attributes to the class, in the nodeInitializer function:
myClass.output_t_qqq = numericAttributeFn.createPoint( 'qqq_translate_out', 'qqq_t_out' )
numericAttributeFn.setWritable( False )
numericAttributeFn.setStorable( False )
numericAttributeFn.setHidden( True )
numericAttributeFn.setReadable(True)
myClass.addAttribute( myClass.output_t_qqq )
etc...
Here's my question: I want to optimize my compute function by executing a particular block if the plug name is .._qqq, or .._rrr, etc. I thought I could do this :
def compute(self, pPlug, pDataBlock):
params = ['qqq', 'rrr', 'sss', 'ttt']
for param in params:
if (pPlug == myClass + '.output_t_' + param):
# do math for the _qqq output attr.
However Maya complains, at the if statement:
"unsupported operand type(s) for +: 'type' and 'str'"
So.... performing string concatenation in an expression, inside compute() is illegal in some way. What's the legal way of doing this?
Mitch
--
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/e05523fd-ab1f-4832-ad0f-f11ce5e1c010%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
def compute(self, pPlug, pDataBlock):if pPlug == self.output_t_qqq :
# do math for the _qqq output attr.
def compute(self, pPlug, pDataBlock):params = ['qqq', 'rrr', 'sss', 'ttt']for param in params:
if pPlug == getattr(self, 'output_t_%s' % param):
# do math for the _qqq output attr.
def compute(self, pPlug, pDataBlock):params = set([self.output_t_qqq,self.output_t_rrr,self.output_t_sss,self.output_t_ttt,])if pPlug in params:
# do math for the _qqq output attr.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/8ba33fd3-5f04-4421-a8a1-5bdfb8f04cef%40googlegroups.com.