Notifications
Clear all

[Closed] material types from renderer

Is it possible to get a list of the material types from installed renderers via maxscript?
You can see them in the material editor/map browser, and when they’re in the scene already, test them for compatabilty for a given renderer.
What I’m looking to do is automate listing out the materials associated with scanline, MR, VRay, FinalRender etc to generate an interface, so that when updates appear i don’t have to completely rewrite and check the list again

6 Replies

Hi Alex,

Maybe you’ve already done that but have you looked at areMtlAndRendererCompatible() function.

Hi Yannick,

Yes I looked at that and I need to do that later in the process, but first I need the list of materials to check from all those available to max.
Just running FinalRender and Vray gives a total of 59 materials to check (about 20 of which were new in the latest version of each renderer).
Right now I’m just looking in the browser, loading them up and taking a note of properties in the listener, then creating a huge array! There must be a better way of doing this …hehe!

Thanks

This is a simplified version of what I’ve done for something similar… Its builds a array of the Structure RendererAndMats. You’ll see some of the Materials are not constructible in MaxScript, so they drop out with the try()catch()

 
(
struct RendererAndMats ( Renderer , Materials )
 
local RenderMatArray = #()
 
local tnMatClasses = material.classes
 
for ChkRenderer in RendererClass.classes do
(
append RenderMatArray ( RendererAndMats Renderer:(ChkRenderer as string) Materials:#() )
for ChkMat in tnMatClasses do
	 if ( areMtlAndRendererCompatible ChkMat renderer:ChkRenderer ) then 
		 append RenderMatArray[ RenderMatArray.count ].Materials ChkMat
)
for RendNMat in RenderMatArray do
   (
   format "% [%]: % 
" RendNMat.Renderer RendNMat.Materials.count RendNMat.Materials
   ) 
 
)

Hope this helps…

Thanks Keith,

That is so elegant compared to how I was approaching it. What I was missing was knowledge of the .classes queries.

Alex

Hi Keith,

I have one question…on the line:

append RenderMatArray[ RenderMatArray.count ].Materials tnMaterial

how does it know which index to put the materials into? Doesn’t the count always remain the total for the array as a whole? It obviously works ok – just trying to understand what’s going on.

Alex

Ah got it now…

because we’re building the array as we go along the count increases by one each time we append an entry…doh!

Alex