# Conrol  Proxy Mesh visibility via xml file

**URL:** <https://forums.chaos.com/t/conrol-proxy-mesh-visibility-via-xml-file/94332>\
**Category:** SDK\
**Created:** [June 7, 2019, 11:04am UTC](https://forums.chaos.com/t/conrol-proxy-mesh-visibility-via-xml-file/94332 "2019-06-07T11:04:56Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![ali\_cgi](https://avatars.discourse-cdn.com/v4/letter/a/3da27b/32.png) [@ali\_cgi](https://forums.chaos.com/u/ali_cgi)\
**Post date:** [June 7, 2019, 11:04am UTC](https://forums.chaos.com/t/conrol-proxy-mesh-visibility-via-xml-file/94332/1 "2019-06-07T11:04:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![yolov](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/yolov/32/11920_2.png) [@yolov](https://forums.chaos.com/u/yolov)\
**Post date:** [June 11, 2019, 2:58pm UTC](https://forums.chaos.com/t/conrol-proxy-mesh-visibility-via-xml-file/94332/2 "2019-06-11T14:58:05Z")

</div>

We would be better able to help if you could let us know what exactly you’re trying to achieve.

---

<div class="post-metadata">

**Author:** ![ali\_cgi](https://avatars.discourse-cdn.com/v4/letter/a/3da27b/32.png) [@ali\_cgi](https://forums.chaos.com/u/ali_cgi)\
**Post date:** [June 11, 2019, 10:52pm UTC](https://forums.chaos.com/t/conrol-proxy-mesh-visibility-via-xml-file/94332/3 "2019-06-11T22:52:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![t.petrov](https://avatars.discourse-cdn.com/v4/letter/t/c68b51/32.png) [@t.petrov](https://forums.chaos.com/u/t.petrov)\
**Post date:** [June 12, 2019, 4:28pm UTC](https://forums.chaos.com/t/conrol-proxy-mesh-visibility-via-xml-file/94332/4 "2019-06-12T16:28:32Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![ali\_cgi](https://avatars.discourse-cdn.com/v4/letter/a/3da27b/32.png) [@ali\_cgi](https://forums.chaos.com/u/ali_cgi)\
**Post date:** [June 13, 2019, 9:05am UTC](https://forums.chaos.com/t/conrol-proxy-mesh-visibility-via-xml-file/94332/5 "2019-06-13T09:05:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ali\_cgi](https://avatars.discourse-cdn.com/v4/letter/a/3da27b/32.png) [@ali\_cgi](https://forums.chaos.com/u/ali_cgi)\
**Post date:** [September 24, 2019, 9:27pm UTC](https://forums.chaos.com/t/conrol-proxy-mesh-visibility-via-xml-file/94332/6 "2019-09-24T21:27:50Z")

</div>

Great to know if this is possible?

---

<div class="post-metadata">

**Author:** ![deyan.spirov](https://avatars.discourse-cdn.com/v4/letter/d/ecc23a/32.png) [@deyan.spirov](https://forums.chaos.com/u/deyan.spirov)\
**Post date:** [September 25, 2019, 9:23am UTC](https://forums.chaos.com/t/conrol-proxy-mesh-visibility-via-xml-file/94332/7 "2019-09-25T09:23:04Z")

</div>

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:

```auto
"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:

```auto
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](https://en.wikipedia.org/wiki/Binary_search_algorithm), since the names are sorted.

---

<div class="post-metadata">

**Author:** ![ali\_cgi](https://avatars.discourse-cdn.com/v4/letter/a/3da27b/32.png) [@ali\_cgi](https://forums.chaos.com/u/ali_cgi)\
**Post date:** [December 11, 2019, 8:13pm UTC](https://forums.chaos.com/t/conrol-proxy-mesh-visibility-via-xml-file/94332/8 "2019-12-11T20:13:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![deyan.spirov](https://avatars.discourse-cdn.com/v4/letter/d/ecc23a/32.png) [@deyan.spirov](https://forums.chaos.com/u/deyan.spirov)\
**Post date:** [December 12, 2019, 9:57am UTC](https://forums.chaos.com/t/conrol-proxy-mesh-visibility-via-xml-file/94332/9 "2019-12-12T09:57:17Z")

</div>

It just iterates all the elements, it can be done in python like this:

```auto
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)

```

---

<div class="post-metadata">

**Author:** ![ali\_cgi](https://avatars.discourse-cdn.com/v4/letter/a/3da27b/32.png) [@ali\_cgi](https://forums.chaos.com/u/ali_cgi)\
**Post date:** [December 12, 2019, 10:41am UTC](https://forums.chaos.com/t/conrol-proxy-mesh-visibility-via-xml-file/94332/10 "2019-12-12T10:41:13Z")

</div>

Thanks perfect!
