How do I get this script that would work with Multimaterials? Get an error. Thanks

(
 on execute do
	(
	 for object in selection do
	 if (classOf object.material == Standard) then
		(
		 if object.material.selfIllumAmount != 100 then
			(
			object.material.showInViewport = on                            
			object.material.selfIllumAmount = 100
			)
			Else
			(
			object.material.showInViewport = on                            
			object.material.selfIllumAmount = 0
			)
		)
		else if (classOf object.material == Multimaterial) then
                        (
                            for b = 1 to b = object.material.numsubs do
                            (
                                if (classOf object.material.materialList[b] == Standard) then
                                ( 
                                object.material.showInViewport = on
                                object.material.selfIllumAmount = 100
                                )
                            )
                        )
 
	)
)

Comments

Comment viewing options

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

Budi G Great thanks!!

it works

barigazy's picture

...

Try this one. If not works then put fn inside execute event

(
	fn changeMtl mtl = 
	(	
		if isKindOf mtl Standard do
		(
			mtl.showInViewport = on
			mtl.selfIllumAmount = if mtl.selfIllumAmount != 100 then 100 else 0
		)
	)
	on execute do
	(
		if selection.count != 0 do
		(
			for obj in selection where obj.material != null do
			(
				case (classof obj.material) of
				(
					(multimaterial): for m in obj.material.materialList do changeMtl m
					(standard): changeMtl obj.material
				)
			)
		)
	)
)

barigazy

Nik's picture

Thanx barigazy

And How to make this for button is pressed when mtl.selfIllumAmount == 100
And If mtl.selfIllumAmount != 100 then button is not pressed.
For example as well as here but i not сan make this script as well as here

 
(
fn isVertexTicks  = (
    local node, f = false
    for node in selection do if node.VertexTicks then (
    f=true
    exit
    )
    return f
)--fn isVertexTicks
on ischecked return isVertexTicks()
 
on Execute do
if isVertexTicks() then (for obj in selection do obj.VertexTicks = off)
else (for obj in selection do obj.VertexTicks = on)
max views redraw
)

barigazy's picture

...

are you want to toggle VertexTicks properties ei. when VertexTicks == on then macro button is checked and if VertexTicks == off then uncheck button?

barigazy

Budi G's picture

I've check your script

I've check your script Nik,
Don't forget to write ".materialList[b]" for Multimaterial

The result of the correction :

object.material.materialList[b].showInViewport = on
 
object.material.materialList[b].selfIllumAmount = 100

Comment viewing options

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