ScriptSpot

Forum topic · General Scripting

easy question

By Cruzifer · 2008-12-08

Description

hi,
i have an object with a multimaterial ( 2 submaterials, and in each defuse channel is a falloff map) assigned. i just want to check whether the second`s submaterial defuse channel has a falloff map.if this is true, it should run the else condition...But i dont get it to work.

cheers cruzifer

objs = selection as array
count= objs.count
For i = 1 to count do
(

if classof objs[i].material.materialList[2].texmap_diffuse =! falloff ()
then(
print "do this"

)
else(
print "do something else"
)

)

Comments (5)

masquerade · 2008-12-09

--Not Tested--

It should be something like this:

objs=selection as array

for i in objs do

(

if classof i.material.material[2].texmap_diffuse == falloff then

(

print "hede"

)

else

(

print "hodo"

)

)

But,

this will work if all materials of selected objects are Multimaterials containing VrayMtls on the second slot. Because texmap_diffuse is a variable only for Vray material. If you are going to use other materials you have to foolproof your script or add possible variables of other materials also.

Cruzifer · 2008-12-09

thanx a bunch, it works. i know that texmap_diffuse is a vray variable - i did it by purpose ;) but could you please explain what it does exactly? the only thing i dont understand is:
"for i in objs do" - how works "i in objs"?
and what was wrong in my attempt?
thanks anyway!

cheers cruzifer

masquerade · 2008-12-09

I am not particularly good in explaining things, but I'll give it a try.

when you define this variable:

objs=selection as array

it creates an array which name is "objs" and put access informations of all objects in selection range.

For example, if you select three teapots and run this command, it returns something like that:

#($Teapot:Teapot02 @ [0.703583,-28.856720,0.000000], $Teapot:Teapot03 @ [21.703278,-48.355049,0.000000], $Teapot:Teapot01 @ [-33.079620,4.926483,0.000000])

 

when we write "for i in objs", i stands for every single object of the selection.

regarding to the three teapot example, all following will do the same job.

1.

for i in objs do

(print i.name)

2.

for i in selection do

 (print i.name)

3.

for i = 1 to objs.count do

(print objs[i].name)

4.

print $teapot01.name

print $teapot02.name

print $teapot03.name

 

Cruzifer · 2008-12-09

thaks alot masquerade,
actually your try of explanation was very good :)
it really helped me out!

have a nice day
cheers cruzifer

masquerade · 2008-12-10

you are welcome, glad if I could help.