0

I want to write a tool that would analyze selected mesh to see whether they have deformer inputs, and then print the result.

To be honest, I'm not quite sure as to how to approach this. I had an idea of checking objects inputs. Then I'm not sure how, but I need to print the source of deformer, and the destination. in the script editor.

Could somebody help and direct me how to approach this?

Thank you

Update I was able to get it working but have new issue. Here is what I have:

sel = pm.ls(sl=True, fl=True, type='transform')

for s in sel:
    pm.select(s)
    print s
    cn = pm.listConnections(s.inMesh, d=False, s=True)
    pm.select(cn)
    res = pm.listConnections(cn[0].controlMesh, d=False, s=True)
    print('{} : {}'.format(res, s))

Question:

Sometimes it is happens that driver is the same for many driven obj. How can i format the result so that the printed version would look like this:

Result:

'driver':'drivenA','drivenB','drivenC'

Val
  • 11
  • 4
  • Check out `cmds.listConnections` to get an object's given inputs/outputs. You can also check out `cmds.listHistory` which should help too. – Green Cell Jun 03 '19 at 04:48
  • Thank you for your help. It worked! But I have another question. here is the way I wrote it at the moment: sel = pm.ls(sl=True, fl=True, type='transform') for s in sel: pm.select(s) print s cn = pm.listConnections(s.inMesh, d=False, s=True) pm.select(cn) res = pm.listConnections(cn[0].controlMesh, d=False, s=True) print res – Val Jul 18 '19 at 04:45
  • At the moment, it would print in this format: mesh meshInput 1 - Is there a way to 'format' the way it is printing? 2 - also, sometimes it is happens that driver is the same for many driven obj. How can i format the result so that the printed version would look like this: 'driver':'drivenA','drivenB','drivenC' – Val Jul 18 '19 at 04:45
  • Can you edit your question so that your code is in proper format? It's extremely hard to read. You might also want to include specific examples of what you want the output to be. – Green Cell Jul 18 '19 at 06:04
  • Sorry about that. I've edited initial question. – Val Jul 18 '19 at 06:14
  • You're making huge assumptions that the selection has an `.inMesh` attribute and an even bigger assumption that it has a connection with a `.controlMesh` attribute. What are you trying to do exactly? – Green Cell Jul 18 '19 at 06:45
  • I'm writing a script that would analyse the rig and print out the driver cage and the driven mesh. Currently the part with .inMesh and .controlMesh works fine. My issue happens when i have one cage driving multiple meshes. I want my script to print it like ['driver' : 'drivenA','drivenB','drivenC'] Instead it gives me this: 'driver' : 'drivenA'| 'driver' : 'drivenB'| 'driver' : 'drivenC'| – Val Jul 18 '19 at 06:52
  • "cage" isn't a thing in Maya. Are you talking about a lattice driving multiple meshes? `.inMesh` and `.controlMesh` may work for you, but if you try it on different objects it crashes right away because it's assuming all objects it passes will have `.inMesh`, which they won't. – Green Cell Jul 18 '19 at 06:59

0 Answers0