PDA

View Full Version : Selecting by self-illu in Multimaterials


esteban73
04-01-2009, 03:50 PM
Im learning Maxscript and Im trying to select the objects in the scene which have "selfIllumAmount >0".
It works fine if the material its "Standard" but if its "Multimaterial" isnt so easy.
I have problems with searching in every submaterial.

ie:
select (for o in Geometry where (o.material != undefined AND classof o.material != Multimaterial AND (o.material.selfIllumAmount >0) OR (classof o.material == Multimaterial AND (o.material.materialList[1].selfIllumAmount >0))) collect o)


It works fine, but it search just in the first material from the multimaterial " [1] ". I dont know how can I build a variable for all submats.
How can I add this loop on the "collect" function? (This works fine alone but not in the "collect")

ie:
for x = selection do
(
for h = 1 to x.material.numSubs do
(
x.material.materialList[h].selfIllumAmount =....
)
)

What I dont undestand neither is why here looks so easy

ie:
for i in 1 to sceneMaterials.count do
(
if classOf i == Multimaterial do
(
for r in i do
(
if r.selfIllumAmount = ...
)
)
)

I dont have to write " r.material.materialList[h].selfIllumAmount " , "r.selfIllumAmount" its enough...
With the last script Im able to change the selfIllumAmount in every material on the scene... but I want to the select the objects too!!!

Who can help me?

thanks!!
Esteban

Piflik
04-01-2009, 04:12 PM
That might work: I edited your code (bold)


select (for o in geometry where o.material != undefined AND classof o.material != Multimaterial AND (o.material.selfIllumAmount > 0) OR (classof o.material == Multimaterial AND (for m in o.material.materialList where m.selfIllumAmount > 0 collect m).count > 0)) collect o


(I hope I got all brackets right...)

Note: It will also collect objects who have a MultiMat with an Mat with Illum > 0, but don't use this Mat...

esteban73
04-01-2009, 06:08 PM
Thanks Piflik for the fast answer!
It works very good!

Thank you
Esteban

CGTalk Moderation
04-01-2009, 06:08 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.