View Full Version : scenematerial collect problem
02-16-2006, 09:37 AM
I'am a poor man in maxscript world :p
I type a line to get all material in scene by using scenematerial command line in:
"for Mat in scenematerials collect mat as string".
This line makes an array with all material names but i have a "Map #2:bitmap" in my array. Map #2 exist in my scene. This is a map applied in a diffuse of a material already in the array.
Cause of that my code bug on that map #2.
Somebody know why i get this bitmap in my material array?
Thank you for you help guys :thumbsup:
02-16-2006, 10:18 AM
A hunch is that the map is on you Environment Slot... or if you have a renderer that has a separate slot for its HDRI map.. that could be it also..
02-16-2006, 10:39 AM
I searched for the map in environnement map but nothing. For the hdri i don't know where to find it.
I don't understand this bug :shrug:
02-16-2006, 10:53 AM
hmm.. if that's the case.. i guess i wouldnt know that either... :sad: sorry..
but if you still want to get only the materials in the scene, you could use this code:
sceneMats = for m in scenematerials where superclassof m == material collect m
for i in scenMats do format "%\" sceneMats.name
02-16-2006, 06:09 PM
At least several max versions ago, the scenematerial array would produce a lot of bogus results. I ended up writing my own function to iterate through the scene object, etc to get the real scene materials. This may be fixed now, but from the sound of your story it may not, you may want to roll your own function, or check out the BLib script available here:
...for a function that should get the real set of scene materials.
02-16-2006, 07:07 PM
Hello guys :thumbsup:
I try your line of code it works perfectly. I don't think to use superclassof.
Thanks a lot for your help ;)
Yes i think i must write my own script for that.
In fact i'am writing a tool to find material by bitmap name. My code works. I push a button and i get all bitmap in the scene. I select a bitmap in the list and the material that use this bitmap appears in an other list.
But for this time, my code work only for diffusemap slot because i don't find the way to scan all slot and test if the bitmap is used in them.
I must ask if the slot in different of undefined (!= undefined) and compare is filename to the selected one. and this in a for loop. I have any idea hox to do it.
Thanks for your help :thumbsup:
02-17-2006, 01:45 AM
I almost forgot... Bobo mentioned a workaround to refresh the scenematerials, so that it would contain the correct items... its kind of a like hack, and can be slow at times... part of the reason why im using this only as an alternative option for a refresh function.
fn updateSceneMaterials =
saveNodes #() "c:/temp.max"
its sort of like the "Save Selected.." function in max.. but it saves a blank file instead.
And I'm not pretty sure also if this was fixed in later versions (7-8)...
02-17-2006, 01:45 AM
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.
vBulletin v3.0.5, Copyright ©2000-2014, Jelsoft Enterprises Ltd.