Maya 2020 fundamentals - modelling the real world
Get halfway through a model and find it's an unworkable mess? Can't add edge loops where you need them? Can't subdivide a mesh properly? If any of this sounds familiar check this course out.
# 1 05-11-2011 , 09:22 AM
Gen's Avatar
Super Moderator
Join Date: Dec 2006
Location: South FL
Posts: 3,522

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*


- Genny
__________________
::|| My CG Blog ||::
::|| My Maya FAQ ||::
# 2 05-11-2011 , 01:17 PM
EduSciVis-er
Join Date: Dec 2005
Location: Toronto
Posts: 3,374
Not sure I understand exactly what you're going for, can you give a pseudocode example?

# 3 05-11-2011 , 04:40 PM
Gen's Avatar
Super Moderator
Join Date: Dec 2006
Location: South FL
Posts: 3,522
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.


- Genny
__________________
::|| My CG Blog ||::
::|| My Maya FAQ ||::
# 4 05-11-2011 , 04:50 PM
NextDesign's Avatar
Technical Director
Join Date: Feb 2004
Posts: 2,988
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.


Imagination is more important than knowledge.

Last edited by NextDesign; 05-11-2011 at 05:06 PM.
# 5 05-11-2011 , 09:56 PM
Gen's Avatar
Super Moderator
Join Date: Dec 2006
Location: South FL
Posts: 3,522
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.


- Genny
__________________
::|| My CG Blog ||::
::|| My Maya FAQ ||::
# 6 06-11-2011 , 11:31 PM
NextDesign's Avatar
Technical Director
Join Date: Feb 2004
Posts: 2,988
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.


Imagination is more important than knowledge.
# 7 07-11-2011 , 06:24 AM
Gen's Avatar
Super Moderator
Join Date: Dec 2006
Location: South FL
Posts: 3,522
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.


- Genny
__________________
::|| My CG Blog ||::
::|| My Maya FAQ ||::
# 8 07-11-2011 , 03:28 PM
NextDesign's Avatar
Technical Director
Join Date: Feb 2004
Posts: 2,988
Or pass an array user added image


Imagination is more important than knowledge.
# 9 07-11-2011 , 10:38 PM
Gen's Avatar
Super Moderator
Join Date: Dec 2006
Location: South FL
Posts: 3,522
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.


- Genny
__________________
::|| My CG Blog ||::
::|| My Maya FAQ ||::
Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

Similar Threads