// =========================================================================== // 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. // =========================================================================== // unloadRelatedReferences.mel // // unload the references related to each selected object. // We assume each object relates to at most one reference // (and if we're mistaken, we use the first one we find anyway) // global proc int unloadRelatedReferences () { string $selNodes[] = `ls -sl`; // note - this code may recklessly try to unload a reference more than once // if we have selected geometry and locator/annotation string $selNode; string $refNode; string $testNodes[]; // try all the selected items for ($selNode in $selNodes) { // we might have unloaded a selected item by the time we get here // so lets check if it still exists $testNodes = `ls $selNode`; if( size($testNodes) > 0 ) { $refNode = `getRelatedReference $selNode`; // or we might have selected something unrelated if(size($refNode) > 0 ) { file -ur $refNode; } } } return 0; }