I’m trying to create a function for some buttons. I don’t want to create one for each button so wrote this
def setSmValue (self, attr):
selection = mc.ls(sl=True)
lightShapes = [mc.pickWalk(shape, direction="down")[0] for shape in selection if mc.nodeType(mc.pickWalk(shape, direction="down")) in ['directionalLight','pointLight','spotLight','areaLight']]
mc.select(selection, r=True)
value = mc.textFieldButtonGrp(self.smapResolutionField, q=True, text=True)
for l in lightShapes:
mc.setAttr('%s.%s' % (l, attr), float(value))
This is working but is not good for all the buttons. I would like to change
self.smapResolutionField
to something like
('self.%s' % attr)
I tryed all I could think about but seems like I don’t understand too clearly the use of self 🙂
Any hint?
Thanks
EDIT: I probably forgot to mention that I’m using that command to query a textField (the user put the value there and I need to read it back)
You can use:
to get it 🙂