Heya
Just wanted to say MAN this just saved my ass !
Thanks!!! :)
On Wednesday, 1 August 2012 18:59:33 UTC+1, Justin Israel wrote:
>
> You can just check from within your callbacks. The checkboxes can stay the
> same. You have a number of ways to do that.
>
> 1) Check if mental ray is the current renderer
>
> def enablePRE(*args):
> if not cmds.getAttr('defaultRenderGlobals.ren') == 'mentalRay':
> return
>
> 2) Check if mental ray plugin is loaded
>
> if not cmds.pluginInfo('Mayatomr', q=True, loaded=True):
> return
> # This could still fail if they have never opened the render settings
> yet
>
> 3) Just try and catch the exception
>
> try:
> cmds.getAttr('miDefaultFramebuffer.premultiply')
> except ValueError:
> pass
>
>
> On Wed, Aug 1, 2012 at 5:48 AM, Daz <[email protected] <javascript:>>wrote:
>
>> Heya
>>
>> Thanks for answer and help ! I thought I failed to post this topic as it
>> did not appear for a while...
>>
>> Anyway I postponed for now text fields because I'm too weak in maya UI
>> and started from something simpler... well not so simpler as I hit a wall
>> already...
>>
>> In any case here is the core of script that works just fine:
>>
>> import maya.cmds as cmds
>>
>> Cbox = cmds.getAttr('miDefaultFramebuffer.premultiply')
>> def enablePRE(*args):
>> cmds.editRenderLayerAdjustment('miDefaultFramebuffer.premultiply')
>> cmds.setAttr ('miDefaultFramebuffer.premultiply',1)
>> def disPRE(*args):
>> cmds.editRenderLayerAdjustment('miDefaultFramebuffer.premultiply')
>> cmds.setAttr ('miDefaultFramebuffer.premultiply',0)
>> cmds.window()
>>
>>
>> cmds.showWindow()
>> mainLayout = cmds.columnLayout(w=300, h=100)
>>
>> w= 75
>> h= 20
>>
>> cmds.text('Basic Render Settings',fn='boldLabelFont')
>> cmds.separator(h=5)
>>
>> cmds.gridLayout( numberOfColumns=4, cellWidthHeight=(w, h))
>>
>> cmds.checkBox(label='Premultiply', onc=enablePRE,ofc=disPRE,value = Cbox)
>> cmds.checkBox(label='Disp', onc=enableDIS,ofc=disDIS,value = Dbox)
>> cmds.checkBox(label='Exp Texture', onc=enableTEX,ofc=disTEX,value = Tbox)
>> cmds.checkBox(label='Post Effect', onc=enablePOS,ofc=disPOS,value = Pbox)
>>
>> cmds.setParent('..')
>> cmds.separator(h=5)
>>
>>
>> Now this is just a part of bigger standalone UI that works just fine when
>> Mental Ray is open.
>>
>> The problem starts if Mental Ray is not in use and script try to Cbox =
>> cmds.getAttr('miDefaultFramebuffer.premultiply')
>> Then he give me an error he cant find module or something like that.. no
>> wonders its not loaded.
>>
>> I fixed it by using 'if' module and then asking if MR is loaded.
>>
>> if cmds.setAttr('defaultRenderGlobals.ren', 'mentalRay', type='string'):
>> Cbox = cmds.getAttr('miDefaultFramebuffer.premultiply')
>> def enablePRE(*args):
>> cmds.editRenderLayerAdjustment('miDefaultFramebuffer.premultiply')
>> cmds.setAttr ('miDefaultFramebuffer.premultiply',1)
>> def disPRE(*args):
>> cmds.editRenderLayerAdjustment('miDefaultFramebuffer.premultiply')
>> cmds.setAttr ('miDefaultFramebuffer.premultiply',0)
>>
>> (now that I look at it I'm not sure if that worked either...)
>>
>> Now this works but it stops again when it try to create checkbox (xxxx,
>> value=Cbox) - at this point he crash because there is no Cbox defined
>> because command never run because MR was not loaded.
>>
>> How can I 'if' that command again so that it will create checkbox but not
>> run strings inside it... ? :s
>>
>> Thanks, bye.
>>
>>
>>
>>
>>
>>
>>
>>
>> Ast o text field I'm trying to get value from Min/Max/Refl/Refl samples
>> in MR and then type them in text field as default and then be able to just
>> change it there and click enter + creating override if its on render layer
>> sooo ignore that question for now I gotta do more python study to grasp the
>> idea how to do it 1st, posting here and annoying you pros wont get me
>> learning anything...
>>
>>
>> Thanks !
>>
>>
>> On Wednesday, 1 August 2012 00:01:14 UTC+1, Justin Israel wrote:
>>
>>> cmds.textField( name, edit=True, enterCommand=('x'))
>>>
>>>
>>> enterCommand requires a callable function, similar to how you are doing
>>> it already with your button. Right now you are effectively just setting the
>>> enterCommand to the string value 'x' which it will then try to run a
>>> callable called x(). I see you have some global values set. Where do you
>>> ultimately want to derive your x value from? A gui widget?
>>>
>>>
>>>
>>> On Mon, Jul 23, 2012 at 2:20 AM, Daz wrote:
>>>
>>>> Hello
>>>>
>>>> I have a bit of a problem with python atm. Not sure if I'm missing 1
>>>> value or everything is wrong but I cant get it to work...
>>>>
>>>> I want to create a simple memu to be able control render settings and
>>>> other values using my UI... here is what I got so far...
>>>>
>>>>
>>>>
>>>> import maya.cmds as cmds
>>>>
>>>> x=4
>>>> y=0
>>>> d=0
>>>> f=0
>>>>
>>>>
>>>> if cmds.window('DazTools', exists=True):
>>>> cmds.deleteUI('DazTools', window=True)
>>>>
>>>> cmds.window ('DazTools', h=50, w=100)
>>>> cmds.showWindow('DazTools')
>>>>
>>>> cmds.rowColumnLayout( numberOfColumns=2, columnAttach=(1, 'right', 0),
>>>> columnWidth=[(1, 100), (2, 250)] )
>>>>
>>>> def st(*args):
>>>> cmds.setAttr('miDefaultOptions.maxSamples', x)
>>>>
>>>>
>>>> cmds.text( label='name' )
>>>> name = cmds.textField()
>>>> cmds.textField( name, edit=True, enterCommand=('x'))
>>>>
>>>> cmds.button('Standard', c=st)
>>>>
>>>>
>>>>
>>>> I'm not sure how it should be but I thought that I have to create
>>>> overall 'x' value for python to be able to call back to the 'x' and know
>>>> what to type in my settings. I initially will preset it to how I want
>>>> using
>>>> master 'x' at the top but let user change it as he go deep in to the
>>>> settings...
>>>>
>>>> Any hints what I'm doing wrong here?
>>>> --
>>>> view archives: http://groups.google.com/group/python_inside_maya
>>>> change your subscription settings:
>>>> http://groups.google.com/group/python_inside_maya/subscribe
>>>>
>>>
>>> --
>> view archives: http://groups.google.com/group/python_inside_maya
>> change your subscription settings:
>> http://groups.google.com/group/python_inside_maya/subscribe
>>
>
>
--
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings:
http://groups.google.com/group/python_inside_maya/subscribe