Hello, everyone. I have just finished Robert Galanakis' "*Practical Maya 
Programming with Python*" book, where in its Chapter 8 a Dependency Graph 
plugin is developed. My problem is, I don't know how it can be used or 
invoked inside Maya; using plugins for this software is new for me. I will 
provide some code from the book to try to expose where my doubtfulness 
resides, but the questions basically reside at the bottom of this post.

In Chapter 7, he teaches us a* Command plugin* can be called with 
pymel.core's loadPlugin in the Script Editor, and then a plugin_name 
variable that was defined inside the Python plugin file can be used as a 
method that invokes the plugin.

This is what it would look like in the Script Editor's Python tab, for a 
Command plugin to be used :

import pymel.core as pmc                  
pmc.loadPlugin('playsoundplugin.py')   
pmc.playSound()                                

Inside 'playsoundplugin.py', that variable called plugin_name is defined as 
the method you invoke to play a Sound in Maya, by using a creator function 
and initializing the plugin with registerCommand.

plugin_name = 'playSound'

def create_plugin():
    return OpenMayaMPx.asMPxPtr(SoundPlayer())

def initializePlugin(mobject):
   plugin = OpenMayaMPx.MFnPlugin(mobject)
   plugin.registerCommand(plugin_name, create_plugin)

It's very straightforward, and it all makes sense with has been taught in 
the book; he even offers a very interesting way to add flags to the command 
call.
For Chapter 8, though, he doesn't show how we can use the quite complex 
*Dependency 
Graph plugin* where he creates a node and its attributes with 
specifications and concrete subclasses. The plugin takes three input 
values, and a compute function takes care of determining two output 
attributes.

Similar to the Command plugin creation, the node plugin also uses similar 
creator and initialization functions; but this time, a new type with the 
'circler' name is created:

def register_circler(fnplugin):
    inputnames = ['input', 'scale', 'frames']
    reg, dereg = create_node(NT_DEPENDSNODE, 'circler', 0x60005, [ value1, 
value2, value3 ])
    reg(fnplugin)

def initializePlugin(mobject):
    register_circler(OpenMayaMPx.MFnPlugin(mobject))

And here is where my question is; Command plug-ins can be called with the 
plugin_name variable, but how can I use a Dependency Graph plugin then? How 
can I create this dependency node with input and output attributes inside 
Maya? Do all Dependency Node plugins share the same procedure to be used?

I hope the question is not too vague or non understandable. Thank you for 
reading.

-- 
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/630efc25-46b7-4da9-bf6c-d9285cd77f6d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to