View Full Version : knowing the object type in selection

04 April 2009, 08:50 PM

i was trying to select a render layer using mel to perform an operation if new render layer is created it should be selected, now i learnt how to create a render layer using

createRenderLayer -name "DiffuseLayer" -number 1 -noRecurse `ls -selection`;

and to make it as selected i did this optionVar -intValue renderLayerCurrent 1;
before creating a new layer which makes the newly created layer as selected.

But i want to know (Ques1)how i can perform the operation of selection the newly created layer without optionVar -intValue renderLayerCurrent 1;
or i want to (Ques2)check whether the option of Make new layer selected is true or false
i.e. whether optionVar -intValue renderLayerCurrent 1; or 0;

so that if its 0 i can make it 1 perform my operation and agian set it back to 0 so that user settings remains as they were before....

04 April 2009, 04:17 AM
like this?

// set with query
int $value;
if ( `optionVar -exists cly_renderLayerCurrent ` )
$value = `optionVar -q cly_renderLayerCurrent `;

// explicitly set
optionVar -intValue renderLayerCurrent 1;

// set toggle with query
optionVar -intValue renderLayerCurrent (!`optionVar -q renderLayerCurrent`)

04 April 2009, 05:10 PM
well a little bit diff though i made it work..

new layer is made using
createRenderLayer -name "DiffuseLayer"

how should i query the existence of the DiffuseLayer?

as i dont want to create a duplicate layer..

04 April 2009, 07:33 PM


if (` objExists "DiffuseLayer"` && `nodeType "DiffuseLayer"` == "renderLayer" )

print " the render layer DiffuseLayer exists\n";


04 April 2009, 10:37 PM
`objExists` very imp to remember...

CGTalk Moderation
04 April 2009, 10:37 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.