求Transform和Shape

# 选择一个transform节点
obj = pm.selected()[0]
# 求出当前节点的shape
obj_shape = pm.listRelatives(obj.name(), p=0, type='shape')[0]
print obj_shape
# 再从这个shape求出transform
transform_node = pm.listRelatives(obj_shape.name(),p=1,type = 'transform')[0]

属性关联

import pymel.core as pm
sphere_ = pm.polySphere()[0]
cube = pm.polyCube()[0]
# 关联属性
pm.connectAttr(cube.name()+'.tx', sphere_.name()+'.tz')
# 也可以这样关联
sphere_.tx >> cube.tz
# 取消关联
pm.disconnectAttr(cube.name()+'.tx', sphere_.name()+'.tz')

# 求出当前使用的相机

import maya.cmds as cmds
# 求出当前使用的相机
cmds.modelPanel( perspPanel, q=True, camera=1 )
print cmds.lookThru( 'perspView', q=True )

切换当前显示模式为boundingBox

# 切换当前显示模式为boundingBox,线框为wireframe
perspPanel = cmds.getPanel( withLabel='Persp View')
cmds.modelPanel( perspPanel, q=True, camera=True )
#editor = cmds.modelEditor()
cmds.modelEditor(perspPanel, edit=True, displayAppearance='boundingBox')