Python Newbie Help: For each Vertex, Bake corresponding Object Pivot?




I’m a bit new to python but am seeing a great benefit to it for Maya use.

This is something I’ve been stumped on for a while:

I have

  • 1 single vertex selected on each object in maya.

for Each vertex in my selection:
- select the corresponding parent object
- align the move tool to the corresponding vertex
(or use vertexnormal)
- bake object pivot


Can maybe help you on some bits there.

import pymel.core as pm

# All components, face, vertex, edge etc can be filtered by the type float3
for float3 in pm.selected(type="float3"):
    # Abort operation on anything but mesh vertex.
    if not isinstance(float3, pm.MeshVertex):
    # `polyListComponentConversion` unexpectedly returns a string, so find the pymel node
    # corresponding to the shape name returned using `ls`.
    shape = fromVertex = True ))
    # To get the transform for the shape you can then just run `shape.getTransform()`

To work with the move tool, you can check out manipMoveContext in the docs

I don’t really follow you on the “bake object pivot” but found this


Do you need to fiddle with the move tool at all? Are you just interested in setting the pivot to coincide with the vertex location?


Just setting the pivot of the object to the selected vertex on the object itself… but for a group of objects with 1 vertex selection on each. I think the stack exchange script has what I need. Thanks guys!