I have a maya scene file with the hierarchy
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
how do I export it to a xml file like
<?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>
i have written a code to get the hierarchy
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)
i am having trouble writing it as a xml