If this were a class, you would save those full path values from creating
your controls, as member attributes, so that you could reference them again
when you want to use the "edit" mode on the control commands to set a
value.
In your case, you would have to use the "global" keyword to save them to
global scope variables.

For following selection, that would require either a ScripJob, or directly
through the Maya API callback messages. You would also have to handle the
case of ambiguous values when you select 2 or more lights, if they have
different values.

On Sat, 15 Aug 2015 3:36 AM Will Sharkey <[email protected]> wrote:

> I was just having another look at a piece of code I wrote for changing
> certain light parameters.
>
> When I run the code, Id love to be able to read that current value, then
> punch it in the respective field. It would also be cool if the UI Window
> refreshed on light selection, but that might be getting to fancy for my
> python skills!
>
> Here's the code, appreciate any pointers :)
>
> import maya.cmds as cmds
>
> def intensity_value(colour_control):
>     selection = cmds.ls( selection=True )
>     for sel in selection:
>         cmds.setAttr('{0}.intensity'.format(sel),colour_control)
>
> def exposure_value(exposure_control):
>     selection = cmds.ls( selection=True )
>     for sel in selection:
>         cmds.setAttr('{0}.aiExposure'.format(sel),exposure_control)
>
> def sample_value(sample_control):
>     selection = cmds.ls( selection=True )
>     for sel in selection:
>         cmds.setAttr('{0}.aiSamples'.format(sel),sample_control)
>
> def myWindow():
>     if cmds.window('ws_lightParameter', exists = True):
>        cmds.deleteUI('ws_lightParameter')
>
>     cmds.window('ws_lightParameter')
>     cmds.columnLayout()
>     colour_control = cmds.floatSliderGrp(label='Intensity', field=True,
> maxValue=50.0, value=1, cc= intensity_value)
>     exposure_control = cmds.floatSliderGrp(label='Exposure', field=True,
> maxValue=50.0, value=0, cc= exposure_value)
>     sample_control = cmds.intSliderGrp(label='Samples', field=True,
> minValue=1, maxValue=50.0, value=1, cc= sample_value)
>     cmds.showWindow('ws_lightParameter')
>
> myWindow()
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/1b9135b6-f842-4dc2-81dd-1cce6a329396%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/1b9135b6-f842-4dc2-81dd-1cce6a329396%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA3z92a3_Jvig-yrhG-qxmxJ1fE6AJ6__Q-OxyJoabo58w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to