Announcement

Collapse
No announcement yet.

VRay MaxScript question ...

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

  • VRay MaxScript question ...

    Hi guys,

    I'm trying to write a script to automatically set certain VRay material values of all VRay mats in the scene, by entering one value in the script. But how do I avoid the script trying to set specific VRay material settings in native Max materials in the scene, causing an unknown property error?

    Here's my script so far:

    ------------------------------------------------

    MainFloater = NewRolloutFloater "Set VRay properties" 300 315

    Rollout VRaymat_prop_refl_subd "VRay mat refl subdivs"
    (

    group "Refl subdivs value"
    (

    label enterreflsubdvalue "Enter refl subdivs value for all VRay mats in the scene"
    spinner reflsubdvalue align:#center range:[1,1000,15] type:#integer scale:1 fieldwidth:45
    button setreflsubdvalue "Set refl subdivs"

    ) -- close group

    on setreflsubdvalue pressed do
    (
    for i = 1 to sceneMaterials.count do
    (
    sceneMaterials[i].reflection_subdivs = reflsubdvalue.value
    )
    )

    ) -- close rollout

    AddRollout VRaymat_prop_refl_subd MainFloater

    ------------------------------------------------

    Thanks very much in advance for your help.

    Cheers,

    Metin
    Sevensheaven.nl — design | illustration | visualization | cartoons | animation

  • #2
    Got it figured out. The important part of the script now reads:


    on setreflsubdvalue pressed do
    (
    for m in sceneMaterials do
    (
    if classof m == VRayMtl then
    (
    m.reflection_subdivs = reflsubdvalue.value
    )
    )
    )
    Sevensheaven.nl — design | illustration | visualization | cartoons | animation

    Comment


    • #3
      well, brute and slow method:

      try sceneMaterials[i].reflection_subdivs = reflsubdvalue.value
      catch()

      better:

      if sceneMaterials[i].reflection_subdivs != undefined then sceneMaterials[i].reflection_subdivs = reflsubdvalue.value

      in case this doesn't work:

      if ((classOf sceneMaterials[i]) == VrayMaterial) then sceneMaterials[i].reflection_subdivs = reflsubdvalue.value

      something like that...i'm not sure if the classOf is really VrayMaterial, you have to try it out.
      Marc Lorenz
      ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___
      www.marclorenz.com
      www.facebook.com/marclorenzvisualization

      Comment


      • #4
        Thanks Plastic,

        My method seems to work, so being a script sucker I guess I'll leave it that way.

        Cheers,

        Metin
        Sevensheaven.nl — design | illustration | visualization | cartoons | animation

        Comment


        • #5
          yeah it's the fastest way anyway...you just don't really need all the brackets
          Marc Lorenz
          ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___
          www.marclorenz.com
          www.facebook.com/marclorenzvisualization

          Comment


          • #6
            But it looks like I'm a real programmer that way.
            Sevensheaven.nl — design | illustration | visualization | cartoons | animation

            Comment


            • #7
              By the way, the first version of my script "The VRay automator" is finished. You can find it here:

              http://www.metinseven.com/menu_goodies.htm

              Spread the word and lemme know if you've got cool suggestions for the script.

              Cheers,

              Metin
              Sevensheaven.nl — design | illustration | visualization | cartoons | animation

              Comment

              Working...
              X