trying to build a temporary pivot tool

38 views
Skip to first unread message

Frame

unread,
Jan 6, 2026, 8:10:21 AM (yesterday) Jan 6
to Python Programming for Autodesk Maya

I’m trying to build a temporary pivot tool, and I made a very simple version just to test the core logic.

The idea is:
I compute the relative matrix and apply it to the selected object.

The problem is that while I’m working on the current frame, everything behaves correctly.
But after I close the tool and scrub or check other frames, the character gets completely broken

What could be causing this issue?

I’ve uploaded the code and a screen recording of the problem to Google Drive


https://drive.google.com/drive/folders/1Bs1oB_2rrRAreBJ0REZZpn2ZW4zbyz0P?usp=sharing


Also This is another test. The problem is that the translation is always wrong.
I’m doing the test on frame 7, and I uploaded the scene I’m testing on to Drive.


import maya.cmds as cmds

import maya.mel

import maya.api.OpenMaya as om

import maya.api.OpenMayaAnim as oma

import math



def get_dag_path(nodeName):

selection_list = om.MSelectionList().add(nodeName)

return selection_list.getDagPath(0)



# pivot_name_1 repesent point a

pivot_name_1 = "locator3"

pivot_1 = get_dag_path(pivot_name_1)

pivot_matrix_1 = pivot_1.inclusiveMatrix()



# pivot_name_2 repesent point b ( after locator3 moved )

pivot_name_2 = "locator4"

pivot_2 = get_dag_path(pivot_name_2)

pivot_matrix_2 = pivot_2.inclusiveMatrix()



# obj_name = "Char_Norman_A1_v011:ctrl_Root"

obj_name = "Char_Norman_A1_v011:ctrlIK_Lf_ArmIK"

obj = get_dag_path(obj_name)

obj_matrix = obj.inclusiveMatrix()





# parent_name = "Char_Norman_A1_v011:grAll_Ctrl"

parent_name = "Char_Norman_A1_v011:grCon_Lf_ArmIK"

parent = get_dag_path(parent_name)

parent_matrix = parent.inclusiveMatrix()



relative_matrix = obj_matrix * pivot_matrix_1.inverse()

new_obj_matrix = relative_matrix * pivot_matrix_2

local_matrix = new_obj_matrix * parent_matrix.inverse()



transform_matrix = om.MTransformationMatrix(new_obj_matrix)

translation = transform_matrix.translation(om.MSpace.kTransform)

rotation = transform_matrix.rotation(False)



cmds.xform(obj_name, translation=translation)

cmds.xform(obj_name,

rotation=[ math.degrees(rotation.x), math.degrees(rotation.y), math.degrees(rotation.z) ])

Marcus Ottosson

unread,
3:36 AM (12 hours ago) 3:36 AM
to python_in...@googlegroups.com
Just to give you some idea of what some of us are seeing and how challenging it would be to try and understand you.

image.png

Most people are busy people, any obstacle you can remove between question and answer, such as not having to visit Google Drive and formatting your code with syntax highlighting, will yield a quicker answer for you. Win-win.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/python_inside_maya/ec2724c9-1ce8-4295-8ec1-9f567595a2c9n%40googlegroups.com.

Kangd dan

unread,
8:44 AM (7 hours ago) 8:44 AM
to Python Programming for Autodesk Maya
https://github.com/kangddan/LinkTempPivot  
Please check this GitHub repository; a few months ago, I implemented a simple script that mimics a TempPivot feature similar to AnimBot

Frame

unread,
2:13 PM (1 hour ago) 2:13 PM
to Python Programming for Autodesk Maya

Sorry about that, I’ll be more careful next time. Thanks for pointing it out.

Frame

unread,
2:18 PM (1 hour ago) 2:18 PM
to python_in...@googlegroups.com

I’ve checked it, thank you so much. 
And Great job on the tool and the clean, well-organized code.

 I just had a few questions—I sent you a private message and hope you get a chance to take a look.


‫في الأربعاء، 7 يناير 2026 في 3:44 م تمت كتابة ما يلي بواسطة ‪Kangd dan‬‏ <‪aa1518...@gmail.com‬‏>:‬
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages