[Closed] scenematerial collect problem
Hello everybody.
I’am a poor man in maxscript world
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
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…
Hello galagast.
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:
hmm… if that’s the case… i guess i wouldnt know that either… 🙁 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
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:
http://www.neilblevins.com/blurscripts/blurscripts.htm
…for a function that should get the real set of scene materials.
- Neil
Hello guys
galagast:
I try your line of code it works perfectly. I don’t think to use superclassof.
Thanks a lot for your help
soulburn3d:
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
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"
deleteFile "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)…