I know this is going to drive joojaa over the edge, so I apologize in advance...
I'm working on a tool to toggle between mesh and subdiv and back while retaining the existing transform and shape name.
also the script checks to see if you have a mtorSubdivNode attached to the shape.
if so then it records these settings and reapplies them to the shape when it is returned to a mesh.
the script seems to work correctly(in that it accomplishes the task), however once the subDiv is returned to a mesh, and the mtor attrs added, and reconnected to the mtorSubdivNode, something happens to the transform node. in the hypergraph, the icon changes to what looks like a render node icon and in the model panel when the transform is selected the right mouse button selection mask treats the obj as if it were a shape node.
I'm kind of at a loss.
I'm sure that everything I'm doing is inefficient and clumsy, but I'm just learning mel so take that for what its worth.
Thx
Scott
[codebox]
//if the shape is a subDiv convert it to mesh, and reconnect any disconnected MtorSubdiv node.
if($shapeType =="subdiv")
{
string $newShapeName[1] = subdToPoly -ch off -aut on -format 3 -depth 0 -sampleCount 1 -maxPolys 1 -extractPointPosition 1 -shareUVs 1 -subdNormals 0 $ea
;
delete $ea;
string $extgName[1] = listRelatives -parent $newShapeName[0]
;
rename $newShapeName[0] $ea;
polyNormal -normalMode 2 -ch 1 $extgName[0];
polySetToFaceNormal -setUserNormal;
DeleteHistory;
//get all shapes
string $mtorShape[] = `listRelatives -shapes $extgName[0]`;
// if there is more than 1 shapeNode then...
if(size ($mtorShape) > 1)
{
//cycle through the shapes and see if one of them is a mtorSubdiv node
for ($eachShape in $mtorShape)
{
string $mtorParent[] = `listRelatives -parent $eachShape`;
// if it is a mtorSubdiv node then: retrieve the settings from the mtorTrackWin, add the attrs to the shape node, and connect them back to the mtorsubDiv node.
if(startsWith ($eachShape,"mtorSubdiv"))
{
for($each in $mtorShape)
{
if(`nodeType $each` == "mesh")
{
addAttr -ln "mtorSubdiv" -at bool -r 1 -k 1 $each;
addAttr -ln "mtorSubdivExtrap" -at bool -r 1 -k 1 $each;
addAttr -ln "mtorSubdivInterp" -at bool -r 1 -k 1 $each;
addAttr -ln "mtorSubdivIgnoreEdges" -sn "SubdivIgnoreEdges" -at bool -r 1 -k 1 $each;
setAttr -keyable 1 ($each + ".mtorSubdiv") `intField -q -v ($mtorParent[0] + "\_mtorTrack\_subDiv\_if")`;
setAttr -keyable 1 ($each + ".mtorSubdivExtrap") `intField -q -v ($mtorParent[0] + "\_mtorTrack\_subDivEx\_if")`;
setAttr -keyable 1 ($each + ".mtorSubdivInterp") `intField -q -v ($mtorParent[0] + "\_mtorTrack\_subDivInt\_if")`;
setAttr -keyable 1 ($each + ".mtorSubdivIgnoreEdges") `intField -q -v ($mtorParent[0] + "\_mtorTrack\_subDivIE\_if")`;
// not sure yet what to do about the in/out mesh thing.
// connectAttr -l 0 -f ($mtorParent[0] + "Shape" + ".outMesh") ($eachShape + ".inMesh");
connectAttr -l 0 -f ($each + ".mtorSubdivExtrap") ($eachShape + ".autoExtrap");
connectAttr -l 0 -f ($each + ".mtorSubdivInterp") ($eachShape + ".interpBoundary");
connectAttr -l 0 -f ($each + ".SubdivIgnoreEdges") ($eachShape + ".ignoreEdges");
}
}
}
// delete the trackWin.
if(`window -exists ($mtorParent[0] + "\_mtorTrackWin")`)
{
deleteUI ($mtorParent[0] + "\_mtorTrackWin");
}
print ("csb\_polyTogel maintained mtorSubdiv connections to " + $mtorParent[0]);
}
}
}[/codebox]