Maya Python游戏与影视编程指南阅读笔记——第五章

pymel
相比于maya.cmds,pymel面向对象,代码更加简洁

代码:

import pymel.core as pm
my_sphere = pm.polySphere()[0] #创建球体
my_sphere.scaleY.set(10)    #设置属性
scale_y = my_sphere.scaleY.get()    #获取属性
sphere_shape = my_sphere.getShape() #获取shpape节点
my_cube = pm.polyCube()[0]  #创建立方体
my_cube.translateX.connect(my_sphere.scaleZ)    #连接属性
import pymel.core as pm
pm.newFile(force = True)    #新建场景
pm.saveAs('NewSence.ma',force = True) #保存场景
pm.openFile('NewSence.ma',force = True)    #打开场景
#创建窗口
import pymel.core as pm
with pm.window() as w:
    with pm.horizontalLayout() as h:
        pm.button()
        pm.button()
        pm.button()
        h.redistribute(1,5,2)
    with pm.horizontalLayout() as h2:
        pm.button()
        pm.button()
        pm.button()
        h.redistribute(1,3,7)

猜你喜欢

转载自blog.csdn.net/peixin_huang/article/details/104131427
今日推荐