Can I pass arguments to plugins while I initialize them? OR the best way to inherit (get) values from initializing class?

38 views
Skip to first unread message

I73

unread,
Nov 22, 2016, 8:47:35 PM11/22/16
to Python Programming for Autodesk Maya
This will be my last post it a while :P 

I am loading in a plugin and I need to be able to pass it some arguments (UI values users input before the plugin is called), is there a way to do this in python? (investigation tells me you can't, but worth a shot)     


def initializePlugin(mobject):
     mplugin = OpenMayaMPx.MFnPlugin(mobject)
       try:
           mplugin.registerNode( kPluginNodeTypeName)
    except:
        sys.stderr.write( "Failed to register node: %s\n" % kPluginNodeTypeName )

Or can you suggests a way I can get user input data from a the class that initialized the plugin, in a proper way? 

Worst case scenario I just pull the UI class out and put it in the plugin (I would really like to stay away from this).

Thanks for any help! 

Justin Israel

unread,
Nov 22, 2016, 9:22:43 PM11/22/16
to python_in...@googlegroups.com
On Wed, Nov 23, 2016 at 2:47 PM I73 <wesley....@iugome.com> wrote:
This will be my last post it a while :P 

I am loading in a plugin and I need to be able to pass it some arguments (UI values users input before the plugin is called), is there a way to do this in python? (investigation tells me you can't, but worth a shot)     

Can you clarify this a bit more? When you say you want to pass arguments when loading a plugin, are these arguments meant to control how the Node will be initialised each time? Or is it something the node will access at some point? Are you trying to give the node some default behaviour when it is created? If so, maybe there are a few ways to do this. You could store options as optionsVars so that you node can read them as needed. You could store a static configuration of options that you node can read later. Or you could creator a closure over the option, when you know them at initializePlugin() time, so that the closure will get used to create nodes with those options.
 


def initializePlugin(mobject):
     mplugin = OpenMayaMPx.MFnPlugin(mobject)
       try:
           mplugin.registerNode( kPluginNodeTypeName)
    except:
        sys.stderr.write( "Failed to register node: %s\n" % kPluginNodeTypeName )

Or can you suggests a way I can get user input data from a the class that initialized the plugin, in a proper way? 

Worst case scenario I just pull the UI class out and put it in the plugin (I would really like to stay away from this).

Thanks for any help! 

--
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/0120cc1b-040c-4aac-b6fb-4494e0ec96c2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Wesley Keeling

unread,
Nov 24, 2016, 4:23:34 PM11/24/16
to python_in...@googlegroups.com
Hey Justin, thanks so much man! 

I did end up getting it, just responding to help anyone else: 
I am registering a node to update my attributes on update, but to pass values I just register a command that I just pass flags to to update:

mplugin.registerCommand('commandToCall', MethodName)

On Tue, Nov 22, 2016 at 6:22 PM, Justin Israel <justin...@gmail.com> wrote:
On Wed, Nov 23, 2016 at 2:47 PM I73 <wesley....@iugome.com> wrote:
This will be my last post it a while :P 

I am loading in a plugin and I need to be able to pass it some arguments (UI values users input before the plugin is called), is there a way to do this in python? (investigation tells me you can't, but worth a shot)     

Can you clarify this a bit more? When you say you want to pass arguments when loading a plugin, are these arguments meant to control how the Node will be initialised each time? Or is it something the node will access at some point? Are you trying to give the node some default behaviour when it is created? If so, maybe there are a few ways to do this. You could store options as optionsVars so that you node can read them as needed. You could store a static configuration of options that you node can read later. Or you could creator a closure over the option, when you know them at initializePlugin() time, so that the closure will get used to create nodes with those options.
 


def initializePlugin(mobject):
     mplugin = OpenMayaMPx.MFnPlugin(mobject)
       try:
           mplugin.registerNode( kPluginNodeTypeName)
    except:
        sys.stderr.write( "Failed to register node: %s\n" % kPluginNodeTypeName )

Or can you suggests a way I can get user input data from a the class that initialized the plugin, in a proper way? 

Worst case scenario I just pull the UI class out and put it in the plugin (I would really like to stay away from this).

Thanks for any help! 

--
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_maya+unsub...@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/b5NqS1mIpPE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0NjbAWYPYVf34mo%2BiO6igUqgD9EH-qXZFsxgyP0Q_7wA%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages