Results 1 to 7 of 7

Thread: Is it possible to automatically execute a method on startup in a C++ plugin?

  1. #1
    variable
    Join Date
    Nov 2016
    Posts
    26

    Default Is it possible to automatically execute a method on startup in a C++ plugin?



    I am trying to display up a dialog box if: (a users env maya path is not set, if the env path to a folder is a correct directory) I have my logic but I need to now run it on startup.

    I have been looking around and I don't know if it's possible to do this with a loaded plugin. The only thing I know of is how to automatically execute python script and I am currently doing that with my userSetup.py in my Maya documents script path. I know I could check my condition in python then call `cmds.MyPlugin()` but I would like to keep it in C++ because I will need to see if my serialized data is saved or not, I don't want to make 2 data loaders.

    Can I do this for an already loaded c++ plugin? and if so can you point me in the direction I need to go in.
    Thanks!

  2. #2
    struct btribble's Avatar
    Join Date
    Feb 2009
    Location
    SF Bay Area, US
    Posts
    367

    Default

    Can you add code to initializePlugin() to do this? You probably don't want to bring up a dialog in that method, but you could register a scriptJob -idleEvent -runOnce from the plugin that calls back into the plugin when Maya is done loading.

  3. #3
    variable
    Join Date
    Nov 2016
    Posts
    26

    Default

    Thanks @btribble, I was using init plugin but I did not know I had flags that I can use to get a call back when done loading, the main problem I am having is a service is failing because of load order. I am giving this a try!

  4. #4

    Default

    Either case, sounds like a pretty bad idea to show "UI at startup". You cannot guarantee order, and you're certain to annoy users. Maybe something like "show UI on first use" is a much better alternative.

  5. #5
    variable
    Join Date
    Nov 2016
    Posts
    26

    Default

    Quote Originally Posted by uiron View Post
    Either case, sounds like a pretty bad idea to show "UI at startup". You cannot guarantee order, and you're certain to annoy users. Maybe something like "show UI on first use" is a much better alternative.
    I'm not showing it every startup, I am checking to see if they have input the path and the tool has serialized it (Checking first if the path is serialized then checking if that path exists), if either of those fail I with then show the dialog for them to input the path I need to save. I'm not too sure what you mean by order, since the dialog will pop up on Maya init.

  6. #6

    Default

    It's just that it's really, really, really annoying to have startup popups, just a general user experience. At most, show a warning in the log that the configuration is missing something and you're reverting to some kind of default behavior (like, "path X is not configured, feature Y is disabled"). Really hard to suggest something more specific as I don't know what your tool does.

  7. #7
    variable
    Join Date
    Nov 2016
    Posts
    26

    Default

    Quote Originally Posted by uiron View Post
    It's just that it's really, really, really annoying to have startup popups, just a general user experience. At most, show a warning in the log that the configuration is missing something and you're reverting to some kind of default behavior (like, "path X is not configured, feature Y is disabled"). Really hard to suggest something more specific as I don't know what your tool does.
    Artists don't read logs, and since they won't be able to use the tools without these directories it's a necessity.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •