detecting object in a scene?


Im looking to do a quick check of all existing light in the scene when the script loads.

So when the script loads id like to check the rootnode for all objects and check over them for which of them is a light, or is there an easier way?



You can access all lights in the scene using lights object set to iterate over all lights in your scene do this

 for l in lights do 
   print --this prints light's name likewise do whatever with l



hey where can i see more information on this?

For example can i do …

for i in hidden do () ?


What do you want to do???
Do you want to access all hidden nodes in the current scene?


no it was just an example.

I want to find the lights currently… :slight_smile:


Oh ok. 3dsmax has some standard object sets like lights, objects, geometry etc which you can use to find out the scenes items. Refer to maxscript reference topic object sets for details. Always have maxscript reference nearby when scripting and search for things that are globally available.


In the MAXScript Reference, of course :slight_smile:
Topic is “ObjectSet Values”

There is no built-in Hidden object set, but you can say

HiddenLights = for o in Lights where not o.isHidden collect o

You can also use

ReallyHiddenLights = for o in Lights where not o.isHiddenInVpt collect o

This will take into account ANY reasons for the hidden state, including Hidden Frozen objects, Hidden Layer, Hidden Category and Hidden Node…


Btw, the fastest way to get all lights (hidden or not) is

theLights = lights as array

This is equivalent to

theLights = for o in lights collect o

but should be faster.
Of course, in the second case you can apply WHERE statements to collect conditionally, while the first one just gives you an array with all lights in it.


Cheers :slight_smile:

Thanks guys clears up some stuff


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.