ScriptSpot

Forum topic · General Scripting

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

By Nik · 2013-08-06

Description

(
 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 (5)

Budi G Great thanks!!

Nik · 2013-08-06

it works

barigazy · 2013-08-06

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
)
)
)
)
)

Thanx barigazy

Nik · 2013-08-13

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 · 2013-08-13

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

Budi G · 2013-08-06

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