// =========================================================================== // 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. // =========================================================================== // // removeDynamicConstraint.mel // // Description: // Interface for removing a dynamicConstraint. // // Arguments: // None. // global proc removeDynamicConstraint( string $scope ) // // Description: // // Given a selected list of meshes, remove them (their nObject) from any nucleus solver // system to which they are associated. // // Input: // $scope all: remove all nCloths // selected: remove only selected nCloths // { string $constraints[]; if( $scope == "all" ){ $constraints = `ls -type "dynamicConstraint"`; if( size($constraints) == 0 ){ warning( (uiRes("m_removeDynamicConstraint.kNoDynamicConstraints")) ); return; } } else { // $scope == "selected" is assumed string $selected[] = `ls -sl`; // Get the selected dynamic constraints // $constraints = `listRelatives -ni -s -type "dynamicConstraint" $selected`; if( size($constraints) == 0 ){ warning( (uiRes("m_removeDynamicConstraint.kNoDynamicConstraintSelected"))); return; } } string $constraint; $constraints = stringArrayRemoveDuplicates( $constraints ); for( $constraint in $constraints ) { string $parents[] = `listRelatives -pa -p $constraint`; delete $constraint; if( size($parents) > 0 ){ string $parent = $parents[0]; string $children[] = `listRelatives $parent`; if( size($children) == 0 ){ delete $parent; } } } return; }