Announcement

Collapse
No announcement yet.

Maxscript and Vray

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

  • Maxscript and Vray

    Hi,
    In Maxscript, I tried to get the class name of VrayDirt like forward : "classOf VrayDirt" but it returne me an error.
    Can you tell me what is the right way to get the class name of Vray classes?
    thank you

    Julien

  • #2
    Works fine for me:

    Code:
    classof VRayDirt
    [COLOR=#0000ff]textureMap[/COLOR]
    Colin Senner

    Comment


    • #3
      Ok, it was not what I was looking for
      How can check if my current textureMap is VrayDirt class?
      Thank you

      Comment


      • #4
        Ah no problem. Let's say you have a VRayMtl is in the material editor in slot 1, and there's a map in the diffuse texture slot.

        Code:
        if (classof meditmaterials[1].texmap_diffuse) == VRayDirt then (
            -- In the material editor in slot 1 (meditmaterials[1]) in the map slot of "diffuse" is VRayDirt do the following
        )
        Colin Senner

        Comment


        • #5
          ps. You'll need other error checking depending on what all you're checking for. This will only work with VRayMtl's. If you run the previous script on a VRayLight material it'll crash, you'll want to preceed it with something like this:

          Code:
          if (isProperty meditmaterials[1] #texmap_diffuse) then (  -- This makes sure the property "texmap_diffuse" exists on the material
               if (classof meditmaterials[1].texmap_diffuse) == VRayDirt then (
                   -- In the material editor in slot 1 (meditmaterials[1]) in the map slot of "diffuse" is VRayDirt do the following
               )
          )
          Does this help? Perhaps you'd like to elaborate on what you're running it on (all scene materials? currently selected object's material?, etc?) and maybe I can be of more help.
          Colin Senner

          Comment


          • #6
            ok thank youcolin,
            I want to test 2 things :
            -1 VrayExtratex render element
            -1 Vraydirt texture in my VrayExtratex render element

            so I used :

            theManager = maxOps.GetRenderElementMgr #Production
            for i = 0 to (theManager.numrenderelements()-1) do
            (
            myRenderElement = theManager.getrenderelement(i)
            if (classof myRenderElement == VRayExtraTex) then
            (
            if (classof myRenderElement.texture == VRayDirt) then
            (
            messagebox (classof myRenderElement.texture as String)
            )
            )
            )

            and he didn't understand what I try to do. I hope you, yes
            thank you for your help

            Comment


            • #7
              Sorry for the day delay. Got busy.

              Is this what you want? It includes debug print outs

              Code:
              (
                  clearListener()
                  
                  local theManager = maxOps.GetRenderElementMgr #Production    -- Render Element Manager
                  
                  for i = 0 to (theManager.NumRenderElements() - 1) do (    -- For each render element (i)
                      local theElement = theManager.GetRenderElement i    -- theElement = the current element in the list
                      
                      print ("theElement = " + theElement as string)
                      print ("  theClass = " + ((classof theElement) as string))
                      
                      if (classof theElement == VRayExtraTex) then (    -- if the element is a VRayExtraTex
                          -- Now check the texture slot of the VRayExtraTex slot and print it
                          print ("      theClass inside VRayExtraTex == " + ((classof theElement.texture) as string))
                          
                          if (isProperty theElement #texture) and (classof theElement.texture) == VRayDirt then (   -- Usually a good idea to call "isProperty" on anything you're accessing a property on first
                              messageBox "VRayExtraTex render element with VRayDirt inside"
                          )
                      )
                  )
                  
              )
              Last edited by MoonDoggie; 17-08-2012, 09:54 AM.
              Colin Senner

              Comment


              • #8
                Not sure exactly what you want to do but there's other ways to get them all the extratexs with VrayDirt

                for o in getclassinstances VrayExtraTex where o.texture != undefined and classof o.texture == VrayDirt do print o.texture
                Maxscript made easy....
                davewortley.wordpress.com
                Follow me here:
                facebook.com/MaxMadeEasy

                If you don't MaxScript, then have a look at my blog and learn how easy and powerful it can be.

                Comment


                • #9
                  I think he's specifically looking for it nested in a VRayExtraTex texture within a render element. The example he showed is doing just that. I'm not exactly sure either

                  A side note though specific to getClassInstances:

                  getClassInstances cannot get maps in:
                  1. Particle flows
                  2. UVW_Unwrap (in the edit UVWs dialog loaded in the editor)
                  3. A refract/reflect map set to box in each of the

                  So you will have to do a workaround if using any of these (which I'm sure you aren't, just wanted to make a note).
                  Colin Senner

                  Comment


                  • #10
                    Hi Colin,
                    Thanks a lot for your help I never used isProperty before but you are right it's good thing.
                    Except this element, I don't understand why my version didn't working...I see the only difference in your script are the variables name and the "isProperty"....maybe is the "local" parameter at the beginning of your script that determinate the variables are locals...
                    anyway thank you.

                    Julien

                    Comment


                    • #11
                      I'm not sure either. The "local"s won't change the behavior, I just do it for good measure. "isProperty" won't affect it either. I'm not sure why yours doesn't work, but mine does right?
                      Colin Senner

                      Comment


                      • #12
                        isProperty and hasProperty are quite slow to execute, I believe it's faster in this case, as you know that property exists for VRayExtraTex to do...

                        if theelement.texmap != undefined and classof theelement.texmap == VRayDirt do....
                        Maxscript made easy....
                        davewortley.wordpress.com
                        Follow me here:
                        facebook.com/MaxMadeEasy

                        If you don't MaxScript, then have a look at my blog and learn how easy and powerful it can be.

                        Comment


                        • #13
                          Yes, since we're already checking to make sure it's a VRayExtraTex (which we know has a #texture property) then it doesn't really matter as long as future implementations of it call it the same. You are correct. I default to using isProperty() a lot because in cases where you aren't sure what you're looking for it becomes necessary.
                          Colin Senner

                          Comment

                          Working...
                          X