|
Hello, I’ve been codding python in maya for a while, and its quiet messy.
The thing is… I don’t know what library you are using, but my best guess is how to use it with the basic maya.cmds.
By the way thanx for posting it, I’ve learned more of maya python in the process, so be my guest and post things like this, as many as you can.
You helped my develop a new very usefull tool!
Ok my interpetation of what I said is this, tell me if it helped:
impot maya.cmds as mc
#get the list of selected objects, will only return the transform nodes sel=mc.ls(sl=True)
#iterate list of selectd objects for i in range(0,len(sel),1):
#this is for clarity you could have gone with sel[i] insted of curr objects
currObj=sel[i]
#selecte each item's hierarchy
mc.select(currObj,hi=True)
#from this selction, keep only the first shape node
currShape = mc.ls( sl=True, shapes=True)[0]
print currShape
#print the shape and its type, for clarity as well
print mc.ls(currShape,showType=True)
#compare the type of shape that it is
if(mc.objectType(currShape, isType="locator")):
print currShape+" is a locator "
elif(mc.objectType(currShape, isType="mesh")):
print currShape+" is a Mesh"
#if it is neither a locator nor a mesh, i don't know what it is
else:
print "No idea of the type of the damned shape"
print"\n-------------------------"
#return to inicial conditions of selection mc.select(sel)
I hope my explanationts in the code are helpfull for you, else tell me and I’ll be happy to explain my self further
|