Ok. firstly - I'm new to Python in Maya and my English is not so great
either so pardon me that ^^
While I was learning MEL and Python I came across this problem which I
can't figure out. So to be more clear I'll show my MEL code first and then
it's Python equivalent.
string $objAligner;
if (`window -ex $objAligner`) {
deleteUI -window $objAligner;
}
string $objAligner = `window -t "Object Alignment Tool" -s false -wh 300 100
-ret`;
columnLayout -adj true;
text -l "Instructions: select targets then affected object";
button -l "Execute" -w 300 -h 40 -c "aligner";
showWindow $objAligner;
proc aligner() {
string $prntCnstr = `parentConstraint`;
delete $prntCnstr;
}
import maya.cmds as mc
if mc.window(objAligner, ex=True) :
mc.deleteUI(objAligner, window=True)
objAligner = mc.window(title='Object Alignment Tool', s=False, wh=(300, 100),
ret=True)
mc.columnLayout(adj=True)
mc.text(l='Instructions: select targets then affected object')
mc.button(l='Execute', w=300, h=40, c='aligner()')
mc.showWindow(objAligner)
def aligner() :
prntCnstr = mc.parentConstraint()
mc.delete(prntCnstr)
So what I want to achieve is checking if window I have created is open and if
it is then I want to close it and create new one in the same place.
In MEL everything is ok because I can execute the first line of code without
anny errors: *string $objAligner;*
In Python though, we create variable when we assign value to a name so if I
open Maya and execute script shown above I get an error of undefined name
"objAligner".
Is there any way to solve this?
--
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/2a6f3bd4-a4e2-487b-96af-29b6fdae18f7%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.