Notifications
Clear all

[Closed] A little help tweaking script

I have bolted together a few bits of code that nearly do what I want, but I am missing the last little bit. This script applys a 2 sided red standard material to the selected object. It currently only adds to individual objects and not to groups? I would think this is very possible?! Maybe the whole code could be writeen neater too?

Any help would be much appreciated.

script

for i in selection do

(
$.material = StandardMaterial name: (“red”)
$.material.diffuse = color 255 0 0
$.material.specular = color 255 0 0
$.material.useSelfIllumColor = on
$.material.selfIllumColor = color 255 0 0
$.material.twoSided = on
)

2 Replies
1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

you code is almost correct. it has to be:


for i in selection do
 (
     i.material = StandardMaterial name: ("red")
     i.material.diffuse = color 255 0 0 
     i.material.specular = color 255 0 0 
     i.material.useSelfIllumColor = on
     i.material.selfIllumColor = color 255 0 0
     i.material.twoSided = on
 )

but the optimal way is:


if selection.count > 0 do
(
	selection.material = StandardMaterial name:"red" diffuse:red specular:red \
		useSelfIllumColor:on selfIllumColor:red twoSided:on
)

Thanks Denis, worked a treat!