Assign material from one object to another

Assign material from one object to another

wasea.pinkov
Observer Observer
709 Views
2 Replies
Message 1 of 3

Assign material from one object to another

wasea.pinkov
Observer
Observer

Hi, I' trying to assign a material from one box to another 

My code looks like this:

global Wall
global WallMaterial
 
for s in selection do
 (
 
	if s.name == 'WallObject' do
	(
		Wall = s
	)
    
    if s.name == 'WallObject' do
    (
        WallMaterial = s.mat
    )
   
)
Wall.mat = WallMaterial    

 And on execution it throw me an error: 

-- Unknown property: "mat" in Wall
-- MAXScript callstack:
-- thread data: threadID:16784
-- ------------------------------------------------------
-- [stack level: 0]
-- In top-level

 

Can someone help me please

 

0 Likes
Accepted solutions (1)
710 Views
2 Replies
Replies (2)
Message 3 of 3

miauuuu
Collaborator
Collaborator
Accepted solution

Maybe something like this:

 

(
	local WallObj = undefined
	local WallMaterial = undefined
	 
	selObjsArr = selection as array
	for s in selObjsArr where s.name == "WallObject" do WallMaterial = s.material
	
	for s in selObjsArr where s.name != "WallObject" do s.material = WallMaterial
	
)
https://miauu-maxscript.com/