Announcement

Collapse
No announcement yet.

Interesting problem with script for setting vray obj properties

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Interesting problem with script for setting vray obj properties

    Hello friends.

    I've been messing about with a script that sets vray properties with a quick click and I notice that it is significantly slower than setting the properties the usual way, as with right-clicking and setting vray props that way. The idea is to save myself the hassle of right-clicking, setting all the various properties, and then clicking ok. Basically it would save a bunch of mouse-clicks.

    For example, here is a single piece of the code that sets all selected objects to be matte:

    Code:
    try(destroydialog _MatteObjTool) catch()
    rollout _MatteObjTool "Make Matte Obj" 
    (
    	button _MakeMatte "Make Selected Objects Matte"
    
    	on _MakeMatte pressed do
    	(
    		for i = 1 to selection.count do
    		(
    		setuserprop $ "VRay_Matte_Enable" true
    		setuserprop $ "VRay_Matte_Alpha" -1
    		setuserprop $ "VRay_Matte_Shadows" false
    		setuserprop $ "VRay_Matte_ShadowAlpha" false
    		setuserprop $ "VRay_Matte_ReflectionAmount" 0.000000
    		setuserprop $ "VRay_Matte_RefractionAmount" 0.000000
    		setuserprop $ "VRay_Matte_GIAmount" 0.000000
    		)
    	)
    	
    )
    createdialog _MatteObjTool
    ...and this works. The complete tool has buttons for making selected objs matte shadow, or setting them to be not matte, etc.

    What's interesting is that, with a big dataset like an automobile interior, if I have a great deal of objects selected, the script takes waaaaaay longer than the native vray method. So what I mean is, if I use my script to make a large number of objects matte, I hit the button and I end up waiting for a while. If I use the regular vray method of right-clicking, get vray properties, click the buttons and close, the result happens much faster.

    Now, I know I can just do it the regular way, but I like automation; and also I don't like having to click all the buttons. Can anybody offer advice why it takes so much longer to do it with my script?

    Thanks very much for any advice. Much appreciated.

  • #2
    Is it just me or are you applying the properties to all the objects for each iteration of your loop? ie you are squaring the number of actions.
    either try applying the userprop to all the objects in one action (I'm not sure if this would ever work)
    or replace $ with $[i] to apply the userprop to the current object in the loop.
    Patrick Macdonald
    Lighting TD : http://reformstudios.com Developer of "Mission Control", the spreadsheet editor for 3ds Max http://reformstudios.com/mission-control-for-3ds-max/



    Comment


    • #3
      Hey that's a good suggestion! Thank you, I hadn't considered the idea of it being an array. I'll get back to you, thanks again. Good stuff.

      Comment

      Working...
      X