Maya Python scripting – Getting an Object’s world-space transform matrix

Software:
Maya 2018

How to get an object transformation matrix in world space coordinates:

from maya.api.OpenMaya import MVector, MMatrix, MPoint
import maya.cmds as cmds

def get_world_transform (obj):
 return MMatrix ( cmds.xform( obj, q=True, matrix=True, ws=True ) )

selected_object = (cmds.ls(sl=1,sn=True))[0]

print ( get_world_transform( selected_object ) )

Capture

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s