Skip to main content

Open Maya

General

import maya.api.OpenMaya as om # API 2.0

import maya.api.OpenMayaAnim as omanim
import maya.api.OpenMayaRender as omrender

import maya.OpenMaya as om # API 1.0. No reason to use except for legacy purposes

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 ) )