// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== //this proc converts the type caps to curves //it supports holes by using the holeinfo attribute on the type node global proc convertTypeCapsToCurves() { string $sel[] = `ls -sl`; //check for selection if (size($sel) == 0) { error (getPluginResource("Type", "kSelectTypeOrSVGError")); } //could be several SVG/ Type nodes for ($node in $sel) { string $conns[] = `listConnections($node+".message")`; for ($obj in $conns) { //in case multiple objects if (`objExists ($obj+".numberOfShells")`) { string $null = `group -em -name ($node+"Curves#")`; // disable polyRemesh string $typeConns[] = `listConnections($obj+".remeshMessage")`; int $remeshNodeState = 1; if( size($typeConns) > 0 ) { $remeshNodeState = `getAttr ($typeConns[0]+".nodeState")`; setAttr( $typeConns[0]+".nodeState", 1 ); } //check it's compatible int $numberOfShells = `getAttr ($obj+".numberOfShells")`; string $shapes[] = `listRelatives -fullPath -shapes $sel`; //check if we have front and back caps as this affects the ID of the faces we want to convert string $extrudeNode[] = `listConnections ($obj+".vectorMessages.extrudeMessage")`; int $delc = `getAttr ($extrudeNode[0]+".deleteCaps")`; int $ext = `getAttr ($extrudeNode[0]+".enableExtrusion")`; int $fb = `getAttr ($extrudeNode[0]+".enableFrontBevel")`; int $bb = `getAttr ($extrudeNode[0]+".enableBackBevel")`; setAttr( $extrudeNode[0]+".enableExtrusion", 0 ); setAttr( $extrudeNode[0]+".enableFrontBevel", 0 ); setAttr( $extrudeNode[0]+".enableBackBevel", 0 ); setAttr( $extrudeNode[0]+".deleteCaps", 0 ); //first do the normal faces, these are easy for ( $i = 0; $i < $numberOfShells; $i++) { select -cl; select -add ($shapes[0] + ".f[" + $i + "]"); ConvertSelectionToEdges; string $curveName[]; catchQuiet($curveName = `polyToCurve -ch 0 -form 2 -degree 1`); parent $curveName[0] $null; } //mow do the holes, these are a bit more convoluted as we need the hole information provided by the type node to do this. int $holeInfoArray[] = `getAttr ($obj+".holeInfo")`; for ( $s = 0; $s < size($holeInfoArray); $s+=3) { //get the info from the array int $startVert = $holeInfoArray[$s+2]; int $endVert = $startVert+$holeInfoArray[$s+1]; select -cl; for ( $p = $startVert; $p < $endVert; $p++) { select -add ($shapes[0] + ".vtx[" + $p + "]"); } ConvertSelectionToEdges; string $curveName[]; catchQuiet($curveName = `polyToCurve -ch 0 -form 2 -degree 1`); parent $curveName[0] $null; } // restore polyRemeshing state if( size($typeConns) > 0 ) setAttr( $typeConns[0]+".nodeState", $remeshNodeState); setAttr( $extrudeNode[0]+".enableExtrusion", $ext ); setAttr( $extrudeNode[0]+".enableFrontBevel", $fb ); setAttr( $extrudeNode[0]+".enableBackBevel", $bb ); setAttr( $extrudeNode[0]+".deleteCaps", $delc ); select $null; } else { error (getPluginResource("Type", "kSelectOnlyTypeOrSVGError")); } } } }