r/Maxscript • u/Valuable_Bed_5282 • Jun 06 '26
Hi everyone, somebody know how to create a 3ds max script that assigns selected materials to objects with the same name?
2
Upvotes
r/Maxscript • u/Valuable_Bed_5282 • Jun 06 '26
1
u/Valuable_Bed_5282 Jun 07 '26
Great! thx a lot it works. If I want apply the script without select the materials before?
1
u/Butthead128 Jun 07 '26 edited Jun 07 '26
1
u/piXelicidio Jun 07 '26
function getSelectedSmeMaterials = (
if not sme.IsOpen() do return #()
local activeView = sme.GetView sme.activeView
local selectedNodes = activeView.GetSelectedNodes()
for n in selectedNodes where isKindOf n.reference Material collect n.reference
)
function assignMaterialsToMatchingObjects matList = (
for mat in matList do (
for obj in objects where obj.name == mat.name do (
obj.material = mat
)
)
)
selectedMats = getSelectedSmeMaterials()
assignMaterialsToMatchingObjects selectedMats