SimplyMaya Forums

Welcome to the forum, feel free to ask questions here.


SM Forums / Maya Questions / Programming / Condition command

Programming MEL Scripts, Expressions & Programming Related Topics

Join the conversation. Reply to post
 
Thread Tools
05-11-2011, 09:22 AM   #1
Gen
Super Moderator
 
Gen's Avatar
 
Join Date: Dec 2006
Location: South FL
Posts: 3,514
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 ||::
  Reply with quote
05-11-2011, 01:17 PM   #2
stwert
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?
  Reply with quote
05-11-2011, 04:40 PM   #3
Gen
Super Moderator
 
Gen's Avatar
 
Join Date: Dec 2006
Location: South FL
Posts: 3,514
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 ||::
  Reply with quote
05-11-2011, 04:50 PM   #4
NextDesign
Technical Director
 
NextDesign's Avatar
 
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.
  Reply with quote
05-11-2011, 09:56 PM   #5
Gen
Super Moderator
 
Gen's Avatar
 
Join Date: Dec 2006
Location: South FL
Posts: 3,514
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 ||::
  Reply with quote
06-11-2011, 11:31 PM   #6
NextDesign
Technical Director
 
NextDesign's Avatar
 
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.
  Reply with quote
07-11-2011, 06:24 AM   #7
Gen
Super Moderator
 
Gen's Avatar
 
Join Date: Dec 2006
Location: South FL
Posts: 3,514
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 ||::
  Reply with quote
07-11-2011, 03:28 PM   #8
NextDesign
Technical Director
 
NextDesign's Avatar
 
Join Date: Feb 2004
Posts: 2,988
Or pass an array
__________________
Imagination is more important than knowledge.
  Reply with quote
07-11-2011, 10:38 PM   #9
Gen
Super Moderator
 
Gen's Avatar
 
Join Date: Dec 2006
Location: South FL
Posts: 3,514
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 ||::
  Reply with quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
MEL Command (MakeROLL) Ataraxy Maya Basics & Newbie Lounge 3 23-01-2010 11:18 PM
Maya->Indigo0.5.3/0.5.4 Exporter Script MattTheMan Programming 186 19-06-2008 09:10 AM
The MEL "alias" command and how you can use it skywola Programming 1 04-03-2006 07:06 AM
command line rendering lights problem tiz Lighting & Rendering 2 22-03-2005 08:36 PM
dos command line rendering tiz Maya Basics & Newbie Lounge 4 21-03-2005 10:06 PM