创建新的nHair系统集

2024-06-02 09:05:38 发布

您现在位置:Python中文网/ 问答频道 /正文

python编写一套新的头发系统的方法是什么? 显然,当我尝试运行我的代码时,它只能创建第一组hairSystem,而当再次尝试运行它时,它无法这样做。在

编辑:我已经设法解决了我的其他问题,但目前我的头发系统有问题

def createPlane(self):
        global nurbsPlane
        # Create the nurbsPlane
        nurbsPlane = cmds.nurbsPlane(n = "nurbsPlane", p=[0,0,0], ax = [0,1,0], w=1, lr=5, d=3, u=1,v=5, ch=1)
        cmds.select(nurbsPlane, r=True)
        # Cleanup the control vertexs
        mm.eval("createHair 1 5 5 0 0 0 0 5 0 2 1 1;")
        cmds.rename("hairSystem1Follicles", "hairSys_Follicles")

Tags: the方法代码self编辑系统defcreate
1条回答
网友
1楼 · 发布于 2024-06-02 09:05:38

首次运行后,Maya尝试重命名hairSystem1Follicles时将抛出错误,因为创建的对象将具有不同的名称。这是maya.cmds/MEL世界。但是对于我们的优势,createHair方法在成功运行后保持hairSystem的选定状态。我们可以利用这一事实来动态地找出您试图在代码中重命名的hairSystemFollicles组。您可以尝试以下解决方案: 在

import maya.cmds as cmds
import pymel.core as pm

def createPlane(self):
    # Create the nurbsPlane
    nurbsPlane = cmds.nurbsPlane(n = "nurbsPlane", p=[0,0,0], ax = [0,1,0], w=1, lr=5, d=3, u=1,v=5, ch=1)
    cmds.select(nurbsPlane, r=True)
    # Cleanup the control vertices

    pm.language.Mel.eval("createHair 1 5 5 0 0 0 0 5 0 2 1 1;") # Pymel's evals are easier to debug and more robust
    created_hairsystem = pm.PyNode("hairSystem1")
    follicles_created = created_hairsystem.getShape().listFuture(type="follicle")
    follicles_group = pm.nodetypes.DagNode(follicles_created[0]).getParent(generations=2)
    cmds.rename(follicles_group, "hairSys_Follicles")

这种方法总是有效的。在

相关问题 更多 >