python运用maya_使用mel/python在Maya中创建简单的层次结构

我猜已经两年多了,你现在已经知道这个了。。但是对于后人来说,有两个问题-首先,你很清楚绝对路径的必要性,但是在应用maya.cmds.parent()打电话。我刚刚做了一些轻重写来说明-主要是你可以使用这样一个事实,当你创建的东西,他们成为默认选择,和maya.cmds.ls()很聪明,会把你需要的东西还给你。。因此:c.group( em=True, name="group_parent", parent="Group_Root")

group_parent = c.ls(sl=True)[0]

modes = ["group1" , "group2", "group3"]

for mode in modes:

c.group( em=True, n=mode, parent=group_parent )

mode_group = c.ls(sl=True)[0]

if mode == "group1":

c.spaceLocator(name="locator1")

s = c.ls(sl=True)[0]

# maya.cmds.parent() with something selected will actually

# parent the specified object to the selected object.

# You don't want that.

# We might as well use the explicit syntax to be sure

# (parent everything specified to the last item in the list)

c.parent( s, mode_group )

elif mode == "group3":

c.spaceLocator(name="locator2")

s = c.ls(sl=True)[0]

c.parent( s, mode_group )

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值