View Full Version : Get worldMatrix idx w/Python?
01-09-2013, 12:43 AM
I'm working with instances and I want to determine which worldMatrix they are linked to.
cmds.ls('transform34|fridgeDoor|fridgeDoorShape', dag=True, ap=True)
returns 3 instances, how do I find out which worldMatrix each is connected to?
01-09-2013, 01:16 AM
I think you want
cmds.listRelatives('transform34|fridgeDoor|fridgeDoorShape', f=True, ap=True)
this should return the list of unique transform nodes
01-09-2013, 02:54 AM
That does return the transform nodes, but I need shapeNode. worldMatrix[X] so I can connect it to a pfxToonShape along the lines of this:
cmds.connectAttr (shapeTmp+'.outMesh', 'pfxToonShape.inputSurface[' + str(nextToonIdx) + '].surface')
cmds.connectAttr (shapeTmp+'.worldMatrix[X]', 'pfxToonShape.inputSurface[' + str(nextToonIdx) + '].inputWorldMatrix')
01-09-2013, 08:41 AM
So get the name of the shapes by listing relatives of type mesh, and connect their worldMatirx attribute/plug in an eval command.
01-09-2013, 02:52 PM
The cmds.ls() command in the OP returns the shapeNodes.
Do you have code for "connect their worldMatirx attribute/plug in an eval command"?
01-09-2013, 03:11 PM
Sorry, I don't follow. The connectAttr in your second post should do it, you asked how to get the shapes. What exactly are you missing? Can you supply a full example / code (e.g. use a sphere mesh) that construct the objects (use the echo all in the script editor), and tell us exactly what's not working?
01-09-2013, 05:14 PM
The connectAttr requires a .worldMatrix index. In my post I used .worldMatrix[X], because that's what I'm trying to figure out.
However, following your suggestion, I created a simple test scene and discovered that there is a better way(?) to connect an instance to the pfxToonShape:
instanceTransform.worldMatrix to the pfxToonShape.inputSurface[X].inputWorldMatrix
and connect the
shape node.outMesh to pfxToonShape.inputSurface[X].surface
In fact, it doesn't appear that the shapeNode contains a worldMatrix attr for each instance.
Thanks for the suggestion.
01-09-2013, 05:14 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2014, Jelsoft Enterprises Ltd.