Notifications
Clear all

[Closed] How to load all the installed renderers onto a listbox?

Hello,

I am trying to load all the installed renderers onto a listbox using maxscript, but stuck with an error.

Here is my code.


(
 rollout RendererSelection " Renderer Selection"
 ( 
  local theRenderers = RendererClass.classes
  listbox lbInstRenderers "Installed Rendering Engines"
 )
 
 fn RenderersList=
 (
  lbInstRenderers.items=for i=1 to theRenderers.count collect theRenderers[i])
 )
 
 on RendererSelection open do
 (
   RenderersList()
 ) 
)  
createDialog RendererSelection 300 100

Thanks

13 Replies

 rollout RendererSelection " Renderer Selection"
 ( 
  
  listbox lbInstRenderers "Installed Rendering Engines"
 
 
 fn RenderersList=
 (
  
  lbInstRenderers.items = for o in RendererClass.classes collect (o as string)
 )
 
 on RendererSelection open do
 (
   RenderersList()
 ) 
)  
createDialog RendererSelection 300 100

Thanks for the prompt response David.

Tried your code, doesn’t show any errors and doesn’t load anything.

Your code had issue with Parentheses you might need to click in the Maxscript Listener and press Escape to cause an interruption before my code will work.

Thanks David,

That worked.

I am trying to have the current renderer selected on the listbox when the script loads.

Would this be the code for that:

This code doesn’t show any errors, but doesn’t work the way it should.


lbInstRenderers.items= for i = 1 to Rendererclass.classes.count - 1 collect (Rendererclass.classes[i] as string)
for o = 1 to lbInstRenderers.items.count do 
(
	   if lbInstRenderers.items[o] ==renderers.current then lbInstRenderers.selection= lbInstRenderers.items[o]
)
 

It’s a bit of a pain to do a type conversion on things like Renderers, you’re best off converting them to string then matching patterns. And then to assign a renderer (as I’m guessing you will want to) you need to convert from a String Value to a renderer class value.

rollout RendererSelection " Renderer Selection"
 ( 
  
  listbox lbInstRenderers "Installed Rendering Engines"
 
 
 fn RenderersList=
 (
  
  	lbInstRenderers.items = for o in RendererClass.classes where o.creatable collect (o as string)
	--print lbInstRenderers.items.count
	lbInstRenderers.selection = (for i = 1 to lbInstRenderers.items.count where (matchpattern (Renderers.current as string) pattern:("*" + lbInstRenderers.items[i] + "*")) collect i)[1]

 )
 
 on RendererSelection open do
 (
   RenderersList()
 ) 
 
 on lbInstRenderers selected sel do
 (
 	Renderers.current = execute(lbInstRenderers.selected + "()")
 )
)  
createDialog RendererSelection 300 100
1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

it will be cool to add real-time UI update on the current renderer is changed… it’s easy to implement with the using of #postRendererChange callback.

Thanks David for the detailed explanation. I will have to check it out today.

The key thing is you get a list of renderers that gives you a value like this:

Mental_Ray_Renderer

but when you look to see what renderers.current is you get

Mental_Ray_Renderer:Mental_Ray_Renderer

Hi David ,

Got some time to check it today. It worked perfectly.

for o in RendererClass.classes where o.creatable collect (o as string)

What does o.creatable do here. Checked it on Maxscript help but that didn’t help.

Thanks David.

Page 1 / 2