macroScript makeSelSets category:"Comet Cartoons" toolTip:"makeSelSets: Creates nice selection sets based on object prefix_BASE naming from charRigger and stuff." Icon:#("CometCartoons",16) ( -- This script will create selection sets based on a prefix name -- and proper suffix data as created by charRigger and such. -- -- Sets that don't have any objects matching/in them are removed. -- Some sets are defaulted to hidden, such as EndEffectors, Hidden and SETLO -- -- Sets created are as follows: -- prefix is the prefix as entered in the U.I. -- * is any object/wildcard. -- Note $ is not really used as a match, it is just a notation used for "objects" -- -- Set Name: Object match pattern: -- ---------------------------------------------------- -- prefix_CTRLs -> $prefix_*CTRL -- prefix_BONEs -> $prefix_*BONE -- prefix_LITERig -> $prefix_*LITE -- prefix_GEOMetry -> $prefix_*GEOM -- prefix_HITEint -> $prefix_*INT -- prefix_HIDEendEffectors -> $prefix_*EndEffectors -- prefix_DELETEptHelpers -> $pt* -- prefix_SETLO -> $prefix_*SETLO -- prefix_SETHI -> $prefix_*SETHI -- -- -- ----------------------------------------------------------------------------------------------- /* * Global Vars */ global string mSSversion="1.00"; global string mSSdate = "Feb 2, 2002"; global string mSSprefix="prefix"; -- ----------------------------------------------------------------------------------------------- /* * replaceChar() - Given a string replaces all occurences of character f (from) with * character t (to) */ fn replaceChar str f t = ( if (str == "" or str == undefined) then return ""; len = str.count; for i in 1 to len do ( if (str[i] == f) then -- replace it needed str[i] = t; ) return str; ) -- ----------------------------------------------------------------------------------------------- fn makeSetsFromPrefix prefix = ( str = ""; format "Making Selection Sets for: %\n" prefix; clearSelection(); -- not sets, but actual objects currently selected -- First try charRigger sets and other custom stuff like LITERig and GEOM sets. str = "selectionSets[(\""+(prefix)+"_CTRLs\")] = $"+(prefix)+"_*CTRL;"; execute str; if (selectionSets[(prefix+"_CTRLs")].count <= 0) then deleteItem selectionSets (prefix+"_CTRLs"); str = "selectionSets[(\""+(prefix)+"_BONEs\")] = $"+(prefix)+"_*BONE;"; execute str; if (selectionSets[(prefix+"_BONEs")].count <= 0) then deleteItem selectionSets (prefix+"_BONEs"); str = "selectionSets[(\""+(prefix)+"_LITERig\")] = $"+(prefix)+"_*LITE;"; execute str; if (selectionSets[(prefix+"_LITERig")].count <= 0) then deleteItem selectionSets (prefix+"_LITERig"); str = "selectionSets[(\""+(prefix)+"_GEOMetry\")] = $"+(prefix)+"_*GEOM;"; execute str; if (selectionSets[(prefix+"_GEOMetry")].count <= 0) then deleteItem selectionSets (prefix+"_GEOMetry"); str = "selectionSets[(\""+(prefix)+"_HIDEint\")] = $"+(prefix)+"_*INT;"; execute str; if (selectionSets[(prefix+"_HIDEint")].count <= 0) then deleteItem selectionSets (prefix+"_HIDEint"); else hide selectionSets[(prefix+"_HIDEint")]; str = "selectionSets[(\""+(prefix)+"_HIDEendEffectors\")] = $"+(prefix)+"_*EndEffector;"; execute str; if (selectionSets[(prefix+"_HIDEendEffectors")].count <= 0) then deleteItem selectionSets (prefix+"_HIDEendEffectors"); else hide selectionSets[(prefix+"_HIDEendEffectors")]; str = "selectionSets[(\"DELETEptHelpers\")] = $pt*"; execute str; if (selectionSets[("DELETEptHelpers")].count <= 0) then deleteItem selectionSets ("DELETEptHelpers"); else hide selectionSets[("DELETEptHelpers")]; -- for now don't delete str = "selectionSets[(\""+(prefix)+"_SETLO\")] = $"+(prefix)+"_*SETLO;"; execute str; if (selectionSets[(prefix+"_SETLO")].count <= 0) then deleteItem selectionSets (prefix+"_SETLO"); else hide selectionSets[(prefix+"_SETLO")]; str = "selectionSets[(\""+(prefix)+"_SETHI\")] = $"+(prefix)+"_*SETHI;"; execute str; if (selectionSets[(prefix+"_SETHI")].count <= 0) then deleteItem selectionSets (prefix+"_SETHI"); format "Done. Created Selection Sets for: %\n" prefix; ) -- ----------------------------------------------------------------------------------------------- rollout ro_mSSmake "Make Selection Sets" ( group "Options" ( edittext et_prefix "Name: " fieldwidth:80 text:"prefix" width:148; button b_makesets "Create Sets" width:150; ) on et_prefix changed str do ( -- store global as name but with spaces as underscores mSSprefix = replaceChar str " " "_"; ) on b_makesets pressed do ( makeSetsFromPrefix mSSprefix; ) ) -- end of Create Rollout rollout ro_mSSabout "About" ( label abt_lbl1 "makeSelSets" label abt_lbl2 "Version" label abt_lbl3 "Built: " label abt_lbl4 "" label abt_lbl5 "by Michael B. Comet" label abt_lbl6 "comet@comet-cartoons.com" label abt_lbl7 "www.comet-cartoons.com" label abt_lbl7b "" label abt_lbl8 "Copyright ©2002" label abt_lbl9 "Michael B. Comet" label abt_lbl10 "All Rights Reserved." label abt_lbl12 "" on ro_mSSabout open do ( abt_lbl2.text = ("Version "+mSSversion); abt_lbl3.text = ("Built: "+mSSdate); ) ) -- Just make this thing a floater...no need for utility ro_mSSfloater = (newRolloutFloater ("makeSelSets "+mSSversion) 200 165) addRollout ro_mSSmake ro_mSSfloater addRollout ro_mSSabout ro_mSSfloater rolledUp:true ) -- end of Macroscript