在Maya中将层次结构导出为xml

问题描述

我有一个具有层次结构的Maya场景文件

Wheels_GRP
    FrontWheels_GRP
        Wheel_Front_L_GRP
            Wheel_Rim_Front_L_MSH
                Wheel_Rim_Front_L_MSHShape
        Wheel_Front_R_GRP
            Wheel_Rim_Front_R_MSH
                Wheel_Rim_Front_R_MSHShape

如何将其导出到xml文件

<?xml version="1.0" encoding="utf-8"?>
    <Data>
        <object id="Wheels_GRP">
            <object id="FrontWheels_GRP">
                <object id="Wheel_Front_L_GRP">
                    <object id="Wheel_Rim_Front_L_MSH">``
                    <Wheel_Rim_Front_L_MSHShape type="mesh"/>
                <object id="Wheel_Front_R_GRP">
                    <object id="Wheel_Rim_Front_R_MSH">
                        <Wheel_Rim_Front_R_MSHShape type="mesh"/>
        </object>
    </Data>

我已经编写了代码获取层次结构

def populateTreeView(parentname):
    # list all the children of the parent node
    children = cmds.listRelatives(parentname,children=True,type="transform") or []
    print parentname
    # loop over the children
    for child in children:
        # childname is the string after the last '|'
        childname = child.rsplit('|')[-1]
        
        print child
        # call this function again,with child as the parent. recursion!
        populateTreeView(child)

# find the selected object
selection = cmds.ls(sl=True)[0]

# enter the recursive function
populateTreeView(selection)

我无法将其编写为xml

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)