-- V0.2 Change name from MatID Pallete to MatIDTools -- V0.3 Added Pick Selected -- V0.4 Bug Fixes -- V0.5 Add Auto Rename Material ID Modifier and Add instanced to Selection -- V0.6 Added SPREAD Source Slots function -- Working --V0.7 BugFix7 --V0.8 Smarter -- V0.9 Multi-Sub Rename Direction <- or -> -- V0.91 Added Apply Source MAterial to Selection -- V0.92 Apply Source Material to Selection on Double Click -- Delete all the older MaterialID Modifiers and Add a New One uwidth = 250 uheight = 375 nameIndex = 1 valid_multisub = 0 --- The ID LISTBOX ALWAYS shows the Material NAMES, not SLOT NAMES... source_label = "none" picklist = #() if selection.count == 1 then ( global source_obj = $ validatemultisub source_obj source_label = source_obj.name )else ( source_obj = undefined source_label = "none" ) global status_label = "" fn validatemultisub source_obj = ( valid_multisub = 0 if source_obj.material == undefined then valid_multisub = 0 else ( -- If it DOEN´S HAVE a Material then INVALID ELSE, go Next routine... if classof source_obj.material != multimaterial then valid_multisub = 0 else ( -- If it HAS a Material but its not a MULTI SUB, then INVALID else go Next routine... testslots = for i = 1 to source_obj.material.count where sceneMaterials[source_obj.material.name].material[i] !=undefined collect i if testslots.count != 0 then valid_multisub = 1 else valid_multisub = 0 ) ) ) fn getnewlist source_obj = ( picklist = #("") validatemultisub source_obj if classof source_obj.material != multimaterial or valid_multisub == 0 then ( picklist = #("No MultiMaterial on Selected") status_label = "No MultiMaterial on Selected" ) else ( for c = 1 to source_obj.material.count do -- PickObject as valid material and list them ( if sceneMaterials[source_obj.material.name].material[c] !=undefined then picklist[c] = ("ID "+c as string +" :"+ source_obj.material[c].name) else picklist[c] = ("ID "+c as string +" :"+"----------- empty") -- Fill Picklist positions with undefined status_label = "2clicks to Apply Material " ) ) ) try(DestroyDialog MatIDTools)catch() rollout MatIDTools "MatID Tools V0.92" ( group "Choose Source SubMaterials source :" ( label lbl_picked_obj "Source:" across:2 align:#left label picked_obj source_label align:#left pos:[55,24] pickbutton bt_pick "Pick Source Object (SubMaterial)" width:(uwidth-20) button bt_picksel "Pick from Selected Object" width:(uwidth-20) button bt_applySourcetoSel "Apply Source Material to Selection" width:(uwidth-20) listbox matids "Materials List [NODES]" items:(if selection.count == 1 and valid_multisub == 1 then for c = 1 to source_obj.material.count where sceneMaterials[source_obj.material.name].material[c] !=undefined collect "ID "+c as string +" : "+source_obj.material[c].name else #("No MultiMaterial on Selected")) height:10 label sel1 status_label ) group "Mult-Sub Source RENAMER" ( button bt_spreadslots "NODES <<-- SLOTS" across:2 button bt_spreadnodes "NODES -->> SLOTS" ) label lab1 "© Kumodot tools - Marcelo Souza - 2015" -- Registry on matids selected nameIndex do ( status_label = "" sel1.text = status_label if matids.items.count > 1 then ( sel1.text = status_label+ (matids.items[nameIndex]) as string ) else ( -- status_label = "No MultiMaterial on Selected" sel1.text = status_label ) ) on MatIDTools open do ( source_label = "none" if selection.count == 1 do ( global source_object = $ getnewlist source_obj ) sel1.text = status_label -- + (matids.items[nameIndex]) as string matids.items = picklist ) on matids doubleClicked itm do ( for x in selection do for i = x.modifiers.count to 1 by -1 where classof x.modifiers[i] == Materialmodifier do deleteModifier x i if matids.items.count > 1 then ( local midMod = Materialmodifier () midMod.name = matids.items[itm] as string addModifier selection midMod selection[1].modifiers[1].materialID = itm status_label = " Applied" sel1.text = matids.items[itm] as string + status_label if source_obj.material != undefined then selection.material = source_obj.material else MessageBox "Source Material/Object doesn´t have Materials." ) else ( status_label = "Can´t Apply MaterialID" sel1.text = status_label ) ) on bt_pick picked obj do ( status_label = "" sel1.text = status_label global source_obj = obj source_label = source_obj.name picked_obj.text = source_label getnewlist source_obj if valid_multisub == 1 then (status_label = "2clicks to Apply Material " sel1.text = status_label+ (matids.items[nameIndex]) as string) else sel1.text = status_label matids.items = picklist -- Populate ListBox matids.selection = 1 )--end on on bt_picksel pressed do ( if selection.count == 1 then ( global source_obj = $ source_label = source_obj.name picked_obj.text = source_label status_label ="" sel1.text = status_label getnewlist source_obj if valid_multisub == 1 then (status_label = "2clicks to Apply Material " sel1.text = status_label+ (matids.items[nameIndex]) as string) else sel1.text = status_label matids.items = picklist matids.selection = 1 ) else MessageBox "Select ONE object." )--end on on bt_applySourcetoSel pressed do ( if source_obj.material != undefined then selection.material = source_obj.material else MessageBox "Source Material/Object doesn´t have Materials." )--end on on bt_spreadslots pressed do -- Rename from SLOTS to NODES ( if source_obj.material != undefined then ( actionMan.executeAction 0 "50048" for c = 1 to source_obj.material.count where sceneMaterials[source_obj.material.name].material[c] !=undefined do ( source_obj.material[c].name = sceneMaterials[source_obj.material.name].names[c] getnewlist source_obj -- Populate ListBox matids.items = picklist -- Populate ListBox status_label = "NODES RENAMED" sel1.text = status_label ) ) else MessageBox "No MultiMaterial on Selected to Spread." ) on bt_spreadnodes pressed do -- Rename from NODES to SLOTS ( if source_obj.material != undefined then ( actionMan.executeAction 0 "50048" for c = 1 to source_obj.material.count where sceneMaterials[source_obj.material.name].material[c] !=undefined do ( sceneMaterials[source_obj.material.name].names[c] = source_obj.material[c].name getnewlist source_obj -- Populate ListBox matids.items = picklist -- Populate ListBox status_label = "SLOTS RENAMED" sel1.text = status_label ) ) else MessageBox "No MultiMaterial on Selected to Spread." )--end on )--end rollout createDialog MatIDTools uwidth uheight fgcolor:yellow