Please have a look at my code and tell me whats wrong!

rollout roll_SB_Tools "SB Multi/Sub-Object V1.0"
(
	group "Create"
	(
		button btn_1 "Create" width:80 height:25
		on btn_1 pressed do
		(
			mat = multimaterial()
			mat.count = 4
			mat[1] = standardmaterial name:"1" diffusecolor:[255,0,0]
			mat[2] = standardmaterial name:"2" diffusecolor:[0,255,0]
			mat[3] = standardmaterial name:"3" diffusecolor:[0,0,255]
			mat[4] = standardmaterial name:"4" diffusecolor:[255,255,0]
                        meditmaterials[activeMeditSlot] = mat
 
	)
	)
createDialog roll_SB_Tools width:200 height:300

Basically I'm writing a script that will create a multi/sub-object material (MSO) that will create a new MSO that has various colours already applied to it so you can just apply it to an object and render quickly to see what id's the object has applied.

So i wrote and tested this bit of code forst which works. It creates a new MSO material and puts it in to the selected material editor slot.

mat = multimaterial()
mat.count = 4
mat[1] = standardmaterial name:"1" diffusecolor:[255,0,0]
mat[2] = standardmaterial name:"2" diffusecolor:[0,255,0]
mat[3] = standardmaterial name:"3" diffusecolor:[0,0,255]
mat[4] = standardmaterial name:"4" diffusecolor:[255,255,0]
meditmaterials[activeMeditSlot] = mat

But when i added this to a rollout with a button to run it, nothing happens. I'd appreciate it if someone could point out to me were my script is wrong. The chunk works on it's own, but not when assigned to a button!

Once I've got this sorted. I will add it to ScriptSpot and then future updates will include specifying how many sub materials you want and if you want them to be Standard, v-ray, mental ray etc.

Hopefully i can figure out how to implement code tht randomises colours!

But for now, I just want this basic script to put the material in to the material editor.

Cheers.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Script_Butler's picture

Doh!

I knew it would be something simple.

Thanks Anubis.

Cheers.

Script_Butler

Anubis's picture

see below...

--// wrong -------------
group "Create"
(
	button btn_1 "Create" width:80 height:25
	on btn_1 pressed do
	(
		-- ...
	)
)
 
--// correct -------------
group "Create"
(
	button btn_1 "Create" width:80 height:25
)
on btn_1 pressed do
(
	-- ...
)

cheers!

my recent MAXScripts RSS (archive here)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.