/* This script will help the user match the material of a source object to a target object First you need to select the source object then click the script, now start picking your target objects When you finish picking just right-click and the picked objects will have the same material as the source Object plus any UVW Map modifier or Unwrap UVW modifier applied to it. Created by Miled Rizk e-mail: miledrizk@gmail.com */ macroScript matchmaterial buttontext: "Match Material" category: "MiRi-Tools" ( On IsEnabled return ( selection.count == 1 and ((superclassof $ == geometryclass or superclassof $ == shape) and classof $ != TargetObject) )--end on isenabled On Execute do ( fn checkobj obj = ((superclassof obj == geometryclass or superclassof obj == shape) and classof obj != TargetObject) local selectedobj = $ local selectedobjectmodifiers = selectedobj.modifiers local modifierscount = selectedobjectmodifiers.count local target = pickobject count: #multiple select: true filter: checkobj --target variable will hold an array of the picked target objects max create mode if target != #escape do ( if target != undefined do ( if selectedobj.material != undefined and selectedobjectmodifiers.count > 0 then ( target.material = selectedobj.material for modnum in modifierscount to 1 by -1 where (classof selectedobjectmodifiers[modnum] == UVWMap or classof selectedobjectmodifiers[modnum] == unwrap_uvw) do ( Undo On ( addmodifier target selectedobjectmodifiers[modnum] )--end undo on )--end fo modnum )--end if else ( if selectedobj.material != undefined and selectedobjectmodifiers.count == 0 then ( Undo On ( target.material = selectedobj.material )--end undo on )--end if else ( if selectedobj.material == undefined and selectedobjectmodifiers.count > 0 then ( for modnum in modifierscount to 1 by -1 where (classof selectedobjectmodifiers[modnum] == UVWMap or classof selectedobjectmodifiers[modnum] == unwrap_uvw) do ( Undo On ( addmodifier target selectedobjectmodifiers[modnum] )--end undo on )--end fo modnum )--end if )--end else )--end else )--if target != undefined )--end if target != #escape max modify mode )--end on execute )--end macroscript