How to store an object by its type on creation?

100 views
Skip to first unread message

Kevin C. Burke

unread,
Oct 23, 2016, 6:23:13 PM10/23/16
to Python Programming for Autodesk Maya
Hello,
I'm missing something fundamental about retrieving objects by their node type and I could really use some guidance.

When I instantiate an object, I'll create the object and assign it a variable like so:

my_curve = mc.curve(name="my_curve",d=1,p=[(0,0,0),(1,1,1),(2,2,2)])

#print my_curve.getCVs(space="world") <-----my_curve is seen as a Transform, so getCVs doesn't work
curveList = pm.ls("my_curve")
print curveList[0].getCVs(space="world")

For some reason, the variable my_curve isn't seen as a NurbsCurve node (it's seen as a Transform), but when I use the PyMel list command, it returns an indexed object that is recognized as a NurbsCurve.

What am I missing? This would clear up a lot of my thinking about PyMel scripting.

Thank you!

Justin Israel

unread,
Oct 23, 2016, 6:43:35 PM10/23/16
to python_in...@googlegroups.com
Is "mc" in this case "maya.cmds"? If so, you are getting back a string and not a PyMel object.

I am guessing what you really wanted is this:
 
my_curve = pm.curve(name="my_curve",d=1,p=[(0,0,0),(1,1,1),(2,2,2)])

... where you are calling the pymel curve() command and not the Maya commands module. This returns a Pymel object as you wanted.

Justin



Thank you!

--
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/253da47c-a9fa-492b-a533-2bb23f8fbabb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kevin C. Burke

unread,
Oct 23, 2016, 6:48:31 PM10/23/16
to Python Programming for Autodesk Maya
Wow. Very observant. That fixed it.

Thank you!!!


On Sunday, October 23, 2016 at 3:43:35 PM UTC-7, Justin Israel wrote:
On Mon, Oct 24, 2016 at 11:23 AM Kevin C. Burke <kevin...@gmail.com> wrote:
Hello,
I'm missing something fundamental about retrieving objects by their node type and I could really use some guidance.

When I instantiate an object, I'll create the object and assign it a variable like so:

my_curve = mc.curve(name="my_curve",d=1,p=[(0,0,0),(1,1,1),(2,2,2)])

#print my_curve.getCVs(space="world") <-----my_curve is seen as a Transform, so getCVs doesn't work
curveList = pm.ls("my_curve")
print curveList[0].getCVs(space="world")

For some reason, the variable my_curve isn't seen as a NurbsCurve node (it's seen as a Transform), but when I use the PyMel list command, it returns an indexed object that is recognized as a NurbsCurve.

What am I missing? This would clear up a lot of my thinking about PyMel scripting.

Is "mc" in this case "maya.cmds"? If so, you are getting back a string and not a PyMel object.

I am guessing what you really wanted is this:
 
my_curve = pm.curve(name="my_curve",d=1,p=[(0,0,0),(1,1,1),(2,2,2)])

... where you are calling the pymel curve() command and not the Maya commands module. This returns a Pymel object as you wanted.

Justin



Thank you!

--
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_maya+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages