using getattr to set value of checkbox in mel

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  10 October 2012
Question using getattr to set value of checkbox in mel

isnt it supposed to be like this
cmds.checkBox(onc=cmds.setattr("miDefaultFramebuffer.contourEnable", 0), value=cmds.getattr('miDefaultFramebuffer.contourEn  able'))
I am trying to get the value of miDefaultFramebuffer.contourEnable and pass the value to checkbox

I keep getting error saying AttributeError: 'module' object has no attribute 'getattr' #

Last edited by DEVILSAN : 10 October 2012 at 05:32 AM.
 
  10 October 2012
The "a" in your getAttr and setAttr should be capitalized.
 
  10 October 2012
strange behaviour by checkbox even label not working as expected

aaww , coz i am using an IDE and instead of tying cmds i typed getattr that brought up this !!

thanks btw now I found strange behavior of checkbox , the label is not showing up aand onc and ofc are not working as expected. first of all the value that getAttr gets from miDefaultFramebuffer.contourEnable doesnt gets reflected in the checkbox I am making then even if its checbox is drawn as unchecked , so if i turn it on nothing happens but if I turn it of it sets the value to false for miDefaultFramebuffer.contourEnable ...
I tried to do it with change command(cc) instead of using onc or ofc state change but still got the same problem
 
  10 October 2012
Maybe you show a portion of your code to get usefull help?
 
  10 October 2012
there it is...

cmds.checkBox(label='Enable Contour Rendering' , onc='cmds.setAttr("miDefaultFramebuffer.contourEnable", 0)', value=cmds.getAttr('miDefaultFramebuffer.contourEn  able'))

Last edited by DEVILSAN : 10 October 2012 at 10:21 AM.
 
  10 October 2012
Talking

here, this should work, you just set the false argument for enable, must be "1" ;]
cmds.checkBox(label='Enable Contour Rendering' , onc='cmds.setAttr("miDefaultFramebuffer.contourEnable", 1)', ofc='cmds.setAttr("miDefaultFramebuffer.contourEnable", 0)', 
 value=cmds.getAttr('miDefaultFramebuffer.contourEn  able'))

The label is displayed correctly, but if it shows up depends if your parent layout gives it enough space to be drawn by the UI. Also you should know that the miDefaultFramebuffer node wont exist until you open the quality tab of the RenderGlobals the first time.
PS you can make your UI reflect the change of the state inside the RenderGlobals by setting up a scriptJob that gets triggered if the attribute "miDefaultFramebuffer.contourEnable" changes, the script job then could be removeds if the UI of your tool is deleted.
 
  10 October 2012
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 12:13 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.