Best way to tackle this

I updated my latest script https://www.scriptspot.com/3ds-max/scripts/easy-turntable
the other day and I need to add some error catching to the section that allows you to pick a Vray Physical Camera.
Rather than just use a try catch, I thought if they are using a Vray camera why not set the renderer at the same time you click on the radio button.
If they don't have Vray installed then just disable the radio buttons and keep the default to a standard target camera. (How do I check this?)

1. Is there a method to call the current renderer as Vray regardless of which version of Vray is installed? ie 1.5, 2.0.03 etc
2. I know enough to be dangerous but not enough to actually think like a programmer yet! so any thoughts on how to best implement these ideas would be appreciated.
3. I had the cameras in separate functions originally, and just called them the via the radio buttons' case statement is this the preferred way?
4. The code can be looked at via the above link.

Thanks Luke

Edit: I have now solved many issues including saving the tangents prior to changing them, all I really need now is how to tell if Vray (any version)is installed and the best way to disable the radio buttons if it isn't installed. and if function would be better practice

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Anubis's picture

Hi Luke

If the user has VRay camera on the scene he probably already set VR as current renderer. You can check the class of the selected camera (ClassOf $ == VR...). I not use VR so can't tell the name of it camera class, but maybe all that you need is just to check for VR (is installed) on dialog open and disable radio-buttons. Because the name of the VR varied, I also use matchPattern. Here is 2 functions:

fn setVRayRenderer = (
	reClasses = RendererClass.classes
	vr = (for cls in reClasses where \ -- find VRay
		matchPattern (cls as string) pattern:"v_ray*" or \
		matchPattern (cls as string) pattern:"VRay*" collect cls)[1]
	if vr != undefined then renderers.current = vr() else false
)
 
fn isVRayInstalled = (
	reClasses = RendererClass.classes
	vr = (for cls in reClasses where \ -- find VRay
		matchPattern (cls as string) pattern:"v_ray*" or \
		matchPattern (cls as string) pattern:"VRay*" collect cls)[1]
	vr != undefined -- boolean result
)

I hope this help.

my recent MAXScripts RSS (archive here)

br0t's picture

Hey, you can check for vray

Hey,
you can check for vray being the current renderer by comparing its name like so:

vr = renderers.current
if matchPattern (vr as String) pattern:"*V_Ray_Adv*" do print "VRay is the current renderer!"

You can also check if VRay is installed by looking for it in the renderer classes:

vr = for r in rendererClass.classes where (matchPattern (r as String) pattern:"*V_Ray_Adv*") collect r
if vr.count == 1 do renderers.current = vr[1]() --if found, assign vray as the current renderer

Cheers

Never get low & slow & out of ideas

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.