// =========================================================================== // 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. // =========================================================================== // // // Creation Date: Feb. 2007, Stephen Edwards // Modified Date: May. 2007, Patrick Weekes // // Description: // global proc polyBridgeFaces () { // Check if the selection is valid (1 object) before deleting any faces. // NOTE: Other invalid selections (such us unequal edge selection sizes) // will not be caught until after the faces are deleted. // They are simply too complex to be caught in this MEL script. string $objects[] = `ls -sl -o`; if (`size $objects` == 1) { string $selectedFaces[] = `filterExpand -sm 34 -ex 1`; // get just outer edges of each selected area ConvertSelectionToEdges; string $edges[] = `ls -sl`; select $selectedFaces; ConvertSelectionToContainedEdges; string $inEdges[] = `ls -sl`; select $edges; select -tgl $inEdges; // save outer edges in a set since IDs may change when faces are deleted string $edgeSet; $edgeSet = `sets -name $edgeSet`; // delete the faces and perform the bridge on the appropriate edges delete $selectedFaces; select -r $edgeSet; BridgeEdge; // check if any of the selected edges are still border edges since // this means the face was deleted but not used in the bridge string $outEdges[] = `sets -q $edgeSet`; int $borderFound = 0; int $i = 0; while($i < `size $outEdges` && ! $borderFound) { string $faces[] = `polyInfo -ef $outEdges[$i]`; string $buffer[]; $borderFound = `tokenize $faces[0] $buffer` < 4; $i = $i + 1; } if ($borderFound) { warning (uiRes("m_polyBridgeFaces.kWarningExtraFaces")); } // cleanup: re-select the edges and delete the set select -add $outEdges; delete $edgeSet; selectMode -co; selectType -fc true; } else { error (uiRes("m_polyBridgeFaces.kErrorTooManyObjects")); } }