Simply Maya User Community

Simply Maya User Community (https://simplymaya.com/forum/index.php)
-   Programming (https://simplymaya.com/forum/forumdisplay.php?f=32)
-   -   Condition command (https://simplymaya.com/forum/showthread.php?t=36664)

Gen 05-11-2011 09:22 AM

Condition command
 
Has anyone successfully made their own user defined condition or event?

Basically I'm trying to make a cute little editor to quickly tweak MR settings and I'm trying to create custom events in order to dim/enable controls based on whether or not certain MR features are on/off like FG, caustics etc.

I made a global proc that queries and returns a boolean value but I'm having trouble getting the condition command to use that script.

The documentation uses pre-defined dependency conditions in the example (and I can't find those to find out exactly how they went about writing them, like "SomethingSelected" and "UndoAvailable" etc). This is so frustrating because I really thought it would be simple enough, maybe I need a break. Sigh*

stwert 05-11-2011 01:17 PM

Not sure I understand exactly what you're going for, can you give a pseudocode example?

Gen 05-11-2011 04:40 PM

Let's say I want my condition to be based on whether or not final gathering is on/off
and I create a global proc to query and return if it's true or false.
Code:

global proc int getFG_orWhatever(){
       
        int $state = `getAttr "miDefaultOptions.finalGather"`;
        return $state;
}

And then create a condition based on that script...

Code:

condition -i -st getFG_orWhatever isFG_enabled;
This is from the help files.

Code:

//    Create a new condition, called "UndoNorRedo", which is true if
//    and only if undo is not available and redo is not available:

global proc int isUndoNorRedo()
{
    return (!`isTrue UndoAvailable` && !`isTrue RedoAvailable`);
}

condition
    -initialize
    -d UndoAvailable
    -d RedoAvailable
    -s "isUndoNorRedo"
    UndoNorRedo;

I don't have any dependency conditions(-d UndoAvailable) which is the problem I think but I can't find the code for UndoAvailable and such to see how they're written.

NextDesign 05-11-2011 04:50 PM

Once I get my license reactivated, I'll take a look into it for you.

Try executing:
Code:

whatIs UndoAvailable;
If something comes up, it's been defined as a script; and you can create your own. If it doesn't you're going to have to find another way around it.

Gen 05-11-2011 09:56 PM

Thanks ^^. Trying to look that up was actually one of the first things I tried, I even tried the 'SomethingSelected' since the docs used that in the example for the dimWhen command, which is really why I need this condition to work.

NextDesign 06-11-2011 11:31 PM

Hey Genny, sorry, I took a look around and found that it's defined in the core of Maya, so you can't define your own.

Gen 07-11-2011 06:24 AM

Aww lame, I had a feeling but I was holding out hope, thanks a ton for the help though. I was trying to be stingy with the global variables, guess I have to smear some more of those around and thrown in some scriptJobs.

NextDesign 07-11-2011 03:28 PM

Or pass an array :)

Gen 07-11-2011 10:38 PM

Hmm and have the script nab the various values from the array? Maybe I'm not looking at that right or even how it applies here so could you elaborate?

I was thinking, since I have a checkBox connected to say MR's fg attr, I would create a global var for the layout containing other ui elements that are fg related and create a scriptJob that's based on a change in the fg attr and enables/disables the layout and thus all its child controls. The custom condition would have allowed me to do that without having to define a global var but that's a no go. In this case I guess the global vars shouldn't be too much because there are really only so many Mr features, GI, FG, Caustics, AO and last but not least Raytrace which will have final say on whether all their controls will be enabled or not. Argh I'm babbling on.


All times are GMT. The time now is 07:52 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Simply Maya 2018