//detach_connected.mel //By Christopher Evans - August 2003 //Grows selection to all faces in current "shell", and creates a new user named object with that geometry. //Then allows the user to delete the original selection. //This works without seperating the mesh, so it's great for taking selected parts off imported OBJs! //Chris@Dork.com - www.ChrisEvans3D.com //selects the shell polySelectConstraint -type 0x0008 -shell true -mode 2; polySelectConstraint -shell false; //loads that selection string $original_sel[] = `ls -sl`; //selects entire mesh polySelectConstraint -type 0x0008 -shell true -mode 3; polySelectConstraint -shell false; //loads that selection string $original_obj[] = `ls -sl`; //select object of selected item string $sel[]=`ls -sl -fl`; string $buff[]; $tok=`tokenize $sel[0] "." $buff`; select -r $buff[0]; //loads that selection name string $original_mesh_name[] = `ls -sl`; //duplicate it and convert selection to faces duplicate -rr; //loads name of new object string $new_mesh_name[] = `ls -sl`; //get old original object selection (faces) select $original_obj; //deselect original and delete leftovers select -d $original_sel; delete; //select original selection then up to mesh select $original_sel; string $sel2[]=`ls -sl -fl`; string $buff2[]; $tok2=`tokenize $sel2[0] "." $buff2`; select -r $buff2[0]; //prompting user input promptDialog -message "Enter name for new mesh:" -button "Ok" -button "Cancel" -defaultButton "Ok" -cancelButton "Cancel" -dismissString "Cancel"; //rename the object string $name = `promptDialog -query`; rename $name; //rename duplicated object to original object name rename $new_mesh_name $original_mesh_name; //allow user to delete original shell string $result=`confirmDialog -message ("Delete original "+$name+" geometry from "+$original_mesh_name[0]+"?") -button "Yes" -button "No" -defaultButton "Yes" -cancelButton "No" -dismissString "No"`; if ($result == "Yes") { select $original_sel; delete; }