Home Website Youtube GitHub

Lattice skin weight export

Hello, I need to use lattice in rigging and to use skining lattice by joints.
I tried to export skin weight on lattice with mGear>Skin and Weights>Export Skin
But I couldn’t, maya says

Warning: angleLatticeLattice: Skipped because don’t have Skin Cluster

Warning: angleLatticeLattice: Skipped because don’t have Skin Cluster

Warning: Any of the selected objects have Skin Cluster. Skin Pack export aborted.

“angleLatticeLattice” is lattice name
Is it possible or not?

My environment is
maya 2020
mGear 4.0.9


Thank you

It’s not currently possible. This might be simple to implement.

In skin.py on line 502, there is a TODO that I wrote :slight_smile: saying to implement lattice and other skinnable objects.

First, it needs an extra elif clause looking for pm.nodetypes.Lattice. Something like this:

                if isinstance(objNode.getShape(), pm.nodetypes.Mesh):
                    meshVertices = pm.polyEvaluate(objShapes, vertex=True)
                elif isinstance(objNode.getShape(), pm.nodetypes.NurbsSurface):
                    # if nurbs, count the cvs instead of the vertices.
                    meshVertices = sum([len(shape.cv) for shape in objShapes])
                elif isinstance(objNode.getShape(), pm.nodetypes.NurbsCurve):
                    meshVertices = sum([len(shape.cv) for shape in objShapes])
                # Lattices use .pt instead of .cv or .vtx:
                elif isinstance(objNode.getShape(), pm.nodetypes.Lattice):
                    meshVertices = sum([len(shape.pt) for shape in objShapes])
                else:
                    meshVertices = 0

But then the rest would need to be bug-tested, since a lattice returns its points in a nested format. I’m not sure if some logic in other functions or in the data storage format would need some modification, or if it would just work in a flattened list.

There are also potential bugs when a skinned lattice is deforming a skinned object. Then you have to make sure you are returning the correct skinCluster in the history stack. If you don’t filter it properly, it can return the skinCluster of the geo that is being deformed by the lattice. I have code for this, but it has to be tested.

You are free to attempt this. Or I will hopefully take a look next week, and make a PR.

1 Like

Thank you very much
I will try it

Did you have any success?

If not, it’s still something I’ll keep on my list, but I got busy with some projects.

Thank you reamind me.
I changed skin.py as you wrote.
And I changed line 47 like this

try:
if (pm.nodeType(obj.getShape())
in [“mesh”, “nurbsSurface”, “nurbsCurve”, “lattice”]):

sorry, I don’t know how to change texts to code like you did

I could export and import lattice weight!
Thank you!!

Oh that’s great! Glad it was simple. I guess the API handles the index format properly. It will be great to get a PR done and fix it for everyone.

You can format code like this:

```
Code between triple backticks
```
1 Like

@chrislesage you should send a PR to the repo :wink:

I will. Still going to test it more thoroughly. :slight_smile:

It’s on my list for next week.