UI Window to Translate Points of a Lattice Deformer

19 views
Skip to first unread message

Anca B

unread,
Jul 14, 2016, 9:30:24 AM7/14/16
to Python Programming for Autodesk Maya

Hello! I'm pretty new to python and I have this problem with a UI Window in order to translate the points of a Lattice Deformer using a Slider. Here is what I've been doing till now. I would really need some help connecting the slider with the selected vertexes. This is in face where I get the error.

 

#Select vertices to translate on x
all_vertices=cmds.ls(selection=True, flatten=True)
print all_vertices

for vertex in all_vertices:
current_vertexposition = cmds.getAttr('{0}'.format(vertex))
print current_vertexposition
#Make window
if cmds.window("chWin", exists=True):
cmds.deleteUI("chWin")

def close_window(*args):
window.destroy(args[0].LatticeWindow, LatticeWindow=True)
#Var1=range(-2.5, 2.5)
# get Lattice deformer atributes in order to change position of selected vertices
LatticeWindow = cmds.window("LattWindow", title="Make your OWN SeaUrchin", widthHeight=(300,300))
cmds.columnLayout(adj=True)
imagePath=cmds.internalVar(userPrefDir=True)+"icons/seaurchin_maya.jpg"
cmds.image(w=300, h=113, image=imagePath)
cmds.separator(h=10)
cmds.text("Transform Lattice")
cmds.separator(h=10)
cmds.attrFieldSliderGrp( min=-2.50, max=2.50, at='%s.tx' % vertex[0])
cmds.showWindow(LatticeWindow)

 

# Error: line 1: Could not find attribute named f.tx
# Traceback (most recent call last):
# File "<maya console>", line 8, in <module>
# RuntimeError: Could not find attribute named f.tx #

 

In fact I would like the UI window to also have a button to Apply and Close but I just cannot understand what the command of this button should look like. 

Justin Israel

unread,
Jul 14, 2016, 2:52:55 PM7/14/16
to Python Programming for Autodesk Maya
Hi and welcome to python! Answers inline... 
First, can you make sure that when you post code longer than a few lines, that it has good formatting so we can read it? This would mean to use pastebin.com or if it's somewhat short, to format it in the mail. 

You may want to try using the option long=True in your ls() command. Your components may not have a unique name when you go to getAttr on them. 

In fact I would like the UI window to also have a button to Apply and Close but I just cannot understand what the command of this button should look like. 

You would just point the callback at a python function that does what you need

--
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/26022f57-95b0-4ac6-bf6c-ebfec72d4e82%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages