Community
I'm not good at English.
It can be difficult to read. excuse me.
I'm learning Python using MAYA.
what i want to do
I want to change the thickness of NurbsCurve all at once.
Please have a look at the code and tell me what is wrong.
Thank you for watching.
from maya import cmds
nodes = cmds.ls(selection=True)
for node in nodes:
if cmds.window(ram, exists =True):
cmds.deleteUI(ram)
ram = cmds.window( w=300, h=300 )
cmds.columnLayout( adj=True )
cmds.getAttr(node + ".lineWidth")
cubW = cmds.floatField(pre=1, editable = True, value = 1,)
cmds.button(l= "Apply", c="LW()" )
cmds.showWindow(ram)
def LW():
myCubeWidth = cmds.floatField(cubW , q = True, value = True)
finalThickness = cmds.setAttr(node + ".lineWidth", n= "LW")
Hi!
There were quite a few problems,
1) You were setting a new window for each curve, changing all their values at once would not have been possible.
2) you were referencing the attribute node, in a function that did not know about it
3) you didn't provide a value in the setAttr command
And probably some more.
Here is how I would suggest your code should look like.
from maya import cmds
if cmds.window("ram", exists =True):
cmds.deleteUI(ram)
ram = cmds.window("ram", w=300, h=300 )
cmds.columnLayout( adj=True )
cmds.getAttr(cmds.ls(sl= True)[0] + ".lineWidth")
cubW = cmds.floatField(pre=1, editable = True, value = 1,)
cmds.button(l= "Apply", c="LW()" )
cmds.showWindow(ram)
def LW():
lineWidth = cmds.floatField(cubW , q = True, value = True)
nodes = cmds.ls(selection=True)
for node in nodes:
cmds.setAttr(node + ".lineWidth", lineWidth)
I hope it helps!
Can't find what you're looking for? Ask the community or share your knowledge.