Skip to content

06 - prompts with pymel

Use promptDialog of course! The way this behaves is strange and counter intuitive; its the way the original python-in-maya behaves. Strange that pymel didn't fix this.

python
from pymel.core import *
promptDialog(message='what exposure do you want to add?', text='1')
value = promptDialog(query=True, text=True)
value = float(value)
[ x.exposure.set( x.exposure.get() + value ) for x in ls(type='phxAreaLight') ]
from pymel.core import *
promptDialog(message='what exposure do you want to add?', text='1')
value = promptDialog(query=True, text=True)
value = float(value)
[ x.exposure.set( x.exposure.get() + value ) for x in ls(type='phxAreaLight') ]

What that's doing under the hood is this:

  1. import pymel (obviously)
  2. make a prompt, show it to the user
  3. after the users hits 'confirm', the prompt hangs around in memory
  4. you then query the now invisible prompt for whatever text the user entered, assign it to a variable 'value'
  5. that value is just text, we need it as a number, a floating point number. you can convert variables to float by calling float(variable)
  6. you use that variable in the list comprehension