Much better, unless I am misunderstanding your need: import pymel.core as pm
# Create locator locPN = pm.spaceLocator(n="myLocator") # Get its shape node locShapePN = locPN.getShape() # Print out name of shape node print locShapePN.name() A lot (not all) of OpenMaya's functionality is integrated into pymel. But whether pymel is a good path or not depends on what kind of tool you're writing. On Wednesday, December 18, 2013, Eric Thivierge wrote: > Not much better there either no? > > -------------------------------------------- > Eric Thivierge > http://www.ethivierge.com > > > On Wed, Dec 18, 2013 at 6:26 PM, Count Zer0 <[email protected]> wrote: > > That's why everybody uses maya.cmds and/or pymel. > > > On Wednesday, December 18, 2013 2:34:54 PM UTC-8, Eric Thivierge wrote: > > Yeah I am in line 13. Just seems an insane amount of code just to get at > the shape node. > > -------------------------------------------- > Eric Thivierge > http://www.ethivierge.com > > > On Wed, Dec 18, 2013 at 5:17 PM, <[email protected]> wrote: > > You could use extendToShape() method from the MDagPath Class > > -brian > > -------- Original Message -------- > Subject: [Maya-Python] OpenMaya accessing shape node after creation > From: Eric Thivierge <[email protected]> > Date: Wed, December 18, 2013 10:34 am > To: [email protected] > > Hey all, > > Been lurking here for a long time but just now picking up some Maya > programming for some rigging tools here at work. I've been a long time > Softimage user and am used to the OM they have there so it's a bit of an > uphill battle trying to make heads or tails of some of the stuff in > OpenMaya. > > Is this the simplest way to get to the shape node after it's created from > the transform node? > > # Sample Python > import maya.OpenMaya as om > > dagModifier = om.MDagModifier() > > locator = dagModifier.createNode('transform') > dagModifier.renameNode(locator, "myLocator") > dagModifier.createNode('locator', locator) # create locator shape under > transform > dagModifier.doIt() > > locatorDagPath = om.MDagPath() > locatorDag = om.MFnDagNode(locator) > locatorDag.getPath(locatorDagPath) > locatorDagPath.extendToShape() > > shapeDag = om.MFnDagNode() > shapeDag.setObject(locatorDagPath.node()) > shapeNode = om.MObject() > shapeNode = locatorDagPath.node() > > dagModifier.renameNode(shapeNode, "myLocatorShape") > dagModifier.doIt() > > -------------------------------------------- > Eric Thivierge > http://www.ethivierge.com > -- > 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/CAAjrnHvxetT_CMeQzqBqH- > JaJnwDB2eqr6q5TKArb-82ZiC8Rg%40mail.gmail.com. > For more options, visit https://groups.google.com/groups/opt_out. > > -- > 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/20131218151756.4b67a657<https://groups.google.com/d/msgid/python_inside_maya/20131218151756.4b67a6573d13e8dd18091ea81788b1e6.fada4aded7.wbe%40email06.secureserver.net> > > -- > 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/CAAjrnHtWjwW9ePJs1B%2Bjtu%3Dv0xjbcpvk6O_x%3Ddrj4rW1inS%2B5g%40mail.gmail.com > . > For more options, visit https://groups.google.com/groups/opt_out. > -- 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/CA%2Bhu4MzQGhx53473O1%3DQTxD%3D-7y_BRt8ZOibg0xa7oP3PJ%3DAYQ%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
