Hey su, thanks for the note.  Your explanation makes sense from a semantic 
perspective.  My plugin has twelve outputs.  I was looking for a way to 
structure my compute() so that evaluating one output would not mean evaluating 
all of them, for performance reasons.  Your suggested solution would allow that 
I think, but at the cost of my compute() getting pretty bloated with repeated 
blocks of functionally equivalent code.  

It seems to me the trade-off is between inefficient code (in the sense of how 
much ink is being spilled) which provides very efficient compute() execution, 
versus efficient code where one generic compute function can handle every 
output - and evaluate every output, every time some input plug is dirtied and 
the node is evaluated.

So taking this another step further: if dealing with an uninstanced class is a 
necessary condition for referring to a plug, are there any other ways to test 
the identity of the plug passed to compute()?  A quick scan of the API docs 
suggests there is no other way than to refer to it explicitly, but I'd love to 
be proven wrong.

Mitch




On Monday, November 25, 2013 10:07:07 AM UTC-8, su wrote:
> in your compute myClass is a (uninstanced) class not a string.
> 
> anyway, the easiest way is just check the plug like:
> if pPlug == myClass.output_t_qqq:
> 
>     do stuff
> 
> elif pPlug == myClass.output_t_rrr:
> 
>     do other stuff
> 
> ...
> 
> 
> 
> 
> On 25 November 2013 11:26,  <[email protected]> wrote:
> 
> Hello everyone,
> 
> 
> 
> 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 [email protected].
> 
> 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.

-- 
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/8ba33fd3-5f04-4421-a8a1-5bdfb8f04cef%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to