// =========================================================================== // 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. // =========================================================================== global proc deleteReferenceObject() // // Description // Looks at the selection list for the first piece of // geometry and then proceeeds to: // delete the referenceObject for each // surface under the selectedObject. // { // Get the relevant selected objects (transforms or geometryShapes) string $selectedObjects[] = `ls -sl -type transform -type geometryShape`; if (size($selectedObjects) >= 1) { // Get the geometryShapeNodes for the first selected object. string $originalShapeNodes[] = `ls -sl -dagObjects -type geometryShape $selectedObjects[0]`; if (size($originalShapeNodes) >= 1) { // There is at least one geometryShape node so proceed // Iterate through all the shape nodes for ($shapeNode in $originalShapeNodes) { // If referenceObject attribute is connected, find out the // node it is connected to and delete it. string $connectedNode[] = `listConnections -shapes true ($shapeNode + ".referenceObject")`; if (size($connectedNode) == 1) { int $interHist = `getAttr ($connectedNode[0] + ".intermediateObject")`; // // If the reference object is an intermediate object // (ie, the undeformed original shape), then just // break the connection. // Otherwise, delete the reference shape. // // We used to try to optimize by not making a reference object // but connecting to an undeformed upstream node. If we load // an old file (2.0) that has such a connection and the user // tries to "delete reference object" we will warn the user // and break the connection. // if ($interHist) { string $warningMsg = ("Reference object " + $connectedNode[0] + " is an intermediate object. This object will no longer be a reference object for " + $shapeNode + " but it will not be deleted."); warning($warningMsg); disconnectAttr ($connectedNode[0] + ".message") ($shapeNode + ".referenceObject"); } else { delete $connectedNode[0]; } } } } } }