Query if a mesh is deformed

1,000 views
Skip to first unread message

Christian Akesson

unread,
Nov 16, 2010, 4:20:57 PM11/16/10
to python_in...@googlegroups.com
Making a utility method to clean out duplicate shape nodes and I want to check if a mesh is being deformed.
Instead of the if not m.listHistory(type='skinCluster'): I would love if there was a way to check if there is any deformer type on the mesh....
______________________________________________
for m in meshes:
# Filter out bound meshes
if not m.listHistory(type='skinCluster'):
shapes = m.getShapes()
for s in shapes:
if s.intermediateObject.get():
delete(s)
rename(m.getShape(), '%sShape' % m.name())
________________________________________________

Thanks,

/Christian

Viktoras

unread,
Nov 17, 2010, 1:34:20 AM11/17/10
to python_in...@googlegroups.com, Christian Akesson
If I understand correctly, you want to delete all intermediate shapes that are not a part of deformation chain for current shape(s)? then your method fails even when there is a skin cluster on the mesh - there can be multiple intermediate shapes due to mesh duplication and some of them unused.

Normally an intermediate shape can be discarded if it's not being connected anywhere, so just list all outgoing connections from each intermediate shape and delete it if there's no connections.

Ofer Koren

unread,
Nov 17, 2010, 7:19:59 AM11/17/10
to python_in...@googlegroups.com
you can specify a broader node type - 'deformer':

if m.listHistory(type='deformer'):
...

- Ofer
www.mrbroken.com

> --
> http://groups.google.com/group/python_inside_maya

stephenkmann

unread,
Nov 17, 2010, 8:40:33 AM11/17/10
to python_in...@googlegroups.com
You can also run. Delete unused deformers and it basically does the same thing.

Not in front of maya but I stole the code out from the file-optimize- scripts.

> --
> http://groups.google.com/group/python_inside_maya
>

--
Sent from my mobile device

Christian Akesson

unread,
Nov 17, 2010, 10:43:07 AM11/17/10
to python_in...@googlegroups.com
Excellent. Thanks for the input!

/Christian


Christian Akesson

unread,
Nov 17, 2010, 11:04:50 AM11/17/10
to python_in...@googlegroups.com
Viktoras:
I want to remove the intermediate shape nodes, but only if the mesh is not being deformed by any deformer in which case those are needed (meshNameShapeOrig, sometimes meshNameShapeDeformed when referenced). These intermediate shapes are sometimes retained on the mesh when duplicating or delete history to get rid of deformers. They cause some issues in our pipeline....

Ofer:
The m.listHistory(type='deformer') does not work for me, tried it with a combination of various arguments. Tried on both the shapes and the mesh transform. Am I missing something?

Thanks,
/Christian


Viktoras

unread,
Nov 17, 2010, 11:07:11 AM11/17/10
to python_in...@googlegroups.com
On 2010.11.17 18:04, Christian Akesson wrote:
Viktoras:
I want to remove the intermediate shape nodes, but only if the mesh is not being deformed by any deformer in which case those are needed (meshNameShapeOrig, sometimes meshNameShapeDeformed when referenced). These intermediate shapes are sometimes retained on the mesh when duplicating or delete history to get rid of deformers. They cause some issues in our pipeline....

that's exactly what i said. if you list outgoing connections from a shape, which is marked as intermediate, and it does not connect anywhere (usually garbage shapes won't at all) - you can delete it.

Christian Akesson

unread,
Nov 17, 2010, 11:25:41 AM11/17/10
to python_in...@googlegroups.com
I guess this could be a way to go:
m.listHistory(type='deformableShape') always returns 1 shape node if there is no active deformer on it and multiple when deformed....
/Christian

j...@janberger.de

unread,
Nov 17, 2010, 11:31:51 AM11/17/10
to python_in...@googlegroups.com

`can u filter them by checking whether the intermediateObject attribute is set to true?

 

 

Christian Akesson <cake...@dslextreme.com> hat am 17. November 2010 um 17:25 geschrieben:

Christian Akesson

unread,
Nov 17, 2010, 12:18:39 PM11/17/10
to python_in...@googlegroups.com
Gotcha, I misread your original post. Thanks!
/Christian



Christian Akesson

unread,
Nov 17, 2010, 1:43:15 PM11/17/10
to python_in...@googlegroups.com
Not sure if it is overkill to do both, but this seems to do that trick and get rid of what you want to get rid of regardless if the mesh is deformed or not...

for m in meshes:
if not m.isReferenced():
shapes = m.getShapes()
for s in shapes:
if s.intermediateObject.get():
if not s.listConnections():
delete(s)
rename(m.getShape(), '%sShape' % m.name())

/Christian

Viktoras

unread,
Nov 18, 2010, 3:39:58 AM11/18/10
to python_in...@googlegroups.com, Christian Akesson
yep, you need both checks as there can be regular shape with no deformation which you don't want to delete.


On 2010.11.17 20:43, Christian Akesson wrote:
Not sure if it is overkill to do both, but this seems to do that trick and get rid of what you want to get rid of regardless if the mesh is deformed or not...

for m in meshes:
if not m.isReferenced():
shapes = m.getShapes()
for s in shapes:
if s.intermediateObject.get():
if not s.listConnections():
delete(s)
rename(m.getShape(), '%sShape' % m.name())

/Christian


-- 
Viktoras
www.neglostyti.com

Ofer Koren

unread,
Nov 18, 2010, 9:38:45 AM11/18/10
to python_in...@googlegroups.com
m.listConnections() will list all connections (inputs and outputs).
better use m.outputs() so you check only outgoing connections
(implying this shape is indeed contributing to a deformation chain).
Input connections can exist even when the shape isn't used in a
deformation chain (such as connections to a poly-creation node, a
layer, for example)

- Ofer
www.mrbroken.com

> --
> http://groups.google.com/group/python_inside_maya
>

Christian Akesson

unread,
Nov 18, 2010, 5:11:50 PM11/18/10
to python_in...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages