Announcement

Collapse
No announcement yet.

Conrol Proxy Mesh visibility via xml file

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

  • Conrol Proxy Mesh visibility via xml file

    Hey does anybody know what the python code would be to show or hide meshes in the proxy visibility list via an xml list.
    Show/Hide all meshes according to name in xml list for proxy selection

  • #2
    We would be better able to help if you could let us know what exactly you're trying to achieve.
    Alex Yolov
    Product Manager
    V-Ray for Maya, Chaos Player
    www.chaos.com

    Comment


    • #3
      Hey I think my explanation does exactly state what I would like to achieve, I have a vrayproxy file storing multiple meshes, if i printed an xml from the original maya file that these proxy were created from which stores the names of the meshes I would like to be visible, is it possible with python / mel to control the visibility of the meshes in the proxy. "Mesh01,02,03,04,05,06,07,08" etc in the vrayproxy. "xml file contains a list... example Mesh01,04. therefore only meshes 01 and 04 would be visible in the vray proxy. thanks

      Comment


      • #4
        When do you want to execute this python/mel?
        Do you want it executed at post-translate/pre-frame/pre-render time?
        Do you want to make a button in a shelf which controls the visibility?
        V-Ray developer

        Comment


        • #5
          Hey, A button on the shelf that just shows and hides the appropriate meshes in the viewport would be needed before any renderig begins, pre render time,
          I imagine when it comes to submitting to the submitting renders to the farm it would be useful to be able to submit different variations of the mesh visibility list, but I imagine ill start thinking about that once i can get it working in the viewport,
          Thanks

          Comment


          • #6
            Great to know if this is possible?

            Comment


            • #7
              Yes, it should be easy to create such a script. For each of the visibility lists (names and ids lists for meshes, hairs and particles) there are two list attributes, one containing the names or IDs and the other containing a 0/1 for the visibility. They are matched by their index. Here are all the attributes:
              Code:
              "visibilityListNames", "objectListNames": Mesh names list
              "visibilityListIDs", "objectListIDs": Mesh IDs list
              "hairVisibilityListNames", "hairObjectListNames": Hair names list
              "hairVisibilityListIDs", "hairObjectListIDs": Hair IDs list
              "particleVisibilityListNames", "particleObjectListNames": Particle names list
              "particleVisibilityListIDs", "particleObjectListIDs: Particle IDs list
              To set them by name, you need to use the Names lists. Here is a simple MEL example searching for meshes that match a list of names and setting their visibility:
              Code:
              string $nodeName="mesh_vraymesh";
              string $names[]={"pCubeShape1", "pSphereShape1"};
              
              int $size=`getAttr -s ($nodeName+".objectListNames")`;
              for ($i=0;$i<$size; $i++) {
                  for ($j=0;$j<2;$j++) {
                      if (`getAttr ($nodeName+".objectListNames["+$i+"]")`==$names[$j]) {
                          setAttr ($nodeName+".visibilityListNames["+$i+"]") 1;
                      }
                  }
              }
              You can do the same for hair and particle lists. If this is slow, it can be optimized with a binary search, since the names are sorted.
              Deyan Spirov
              V-Ray for Maya developer

              Comment


              • #8
                This works perfectly, thanks for the reply...
                Any chance of a python conversion? A few bits here that imm not sure how to translate,

                for ($i=0;$i<$size; $i++) { for ($j=0;$j<2;$j++) { & "+$i+" Thanks

                Comment


                • #9
                  It just iterates all the elements, it can be done in python like this:
                  Code:
                  nodeName="mesh_vraymesh"
                  names=["pCubeShape1", "pSphereShape1"]
                  
                  size=cmds.getAttr(nodeName+".objectListNames", size=True)
                  for i in xrange(0, size):
                      for j in xrange(0,2):
                          if cmds.getAttr("%s.objectListNames[%i]"%(nodeName, i))==names[j]:
                              cmds.setAttr("%s.visibilityListNames[%i]"%(nodeName, i), 1)
                  Deyan Spirov
                  V-Ray for Maya developer

                  Comment


                  • #10
                    Thanks perfect!

                    Comment

                    Working...
                    X