# Set/Reset Visible using VSTA

**URL:** <https://tech-community.robotics.abb.com/t/set-reset-visible-using-vsta/2181>\
**Category:** RobotStudio\
**Created:** [September 30, 2008, 6:27pm UTC](https://tech-community.robotics.abb.com/t/set-reset-visible-using-vsta/2181 "2008-09-30T18:27:18Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/system/32/6_2.png) [@system](https://tech-community.robotics.abb.com/u/system)\
**Post date:** [September 30, 2008, 6:27pm UTC](https://tech-community.robotics.abb.com/t/set-reset-visible-using-vsta/2181/1 "2008-09-30T18:27:18Z")

</div>

I have about 100 objects in my simulation that I need to be able to set or reset the visible property for that object from VSTA. Can someone give me a small example of how to reference that object from VSTA and set its visible property? I found an example that shows how to set the current selected items visible property but these will not be selected. I need to be able to set any objects visible property.

BR

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/system/32/6_2.png) [@system](https://tech-community.robotics.abb.com/u/system)\
**Post date:** [September 30, 2008, 11:20pm UTC](https://tech-community.robotics.abb.com/t/set-reset-visible-using-vsta/2181/2 "2008-09-30T23:20:27Z")

</div>

Hi!  
With the following code you can iterate through the objects in the scene and make the object with name xy invisible:

```auto
station = Project.ActiveProject as Station;
foreach (GraphicComponent gc in station.GraphicComponents)
if(gc.Name.equals("xy"))
gc.Visible = false;
```

Best Regards,  
Matthias

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/system/32/6_2.png) [@system](https://tech-community.robotics.abb.com/u/system)\
**Post date:** [September 30, 2008, 11:32pm UTC](https://tech-community.robotics.abb.com/t/set-reset-visible-using-vsta/2181/3 "2008-09-30T23:32:02Z")

</div>

Thank you for the response. I can make this work, but I would rather not loop through all the objects and just reference the one I want. I think that it will take to long.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/system/32/6_2.png) [@system](https://tech-community.robotics.abb.com/u/system)\
**Post date:** [September 30, 2008, 11:38pm UTC](https://tech-community.robotics.abb.com/t/set-reset-visible-using-vsta/2181/4 "2008-09-30T23:38:55Z")

</div>

This did not work BTW it gives me a error (The name ‘station’ does not exist in the current context)

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/system/32/6_2.png) [@system](https://tech-community.robotics.abb.com/u/system)\
**Post date:** [October 1, 2008, 7:58am UTC](https://tech-community.robotics.abb.com/t/set-reset-visible-using-vsta/2181/5 "2008-10-01T07:58:03Z")

</div>

You can try

```auto
station.GraphicComponents.TryGetGraphicComponent(String str, out: GraphicComponent gc)
```

to get the component with name str in GraphicComponent gc

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/system/32/6_2.png) [@system](https://tech-community.robotics.abb.com/u/system)\
**Post date:** [October 1, 2008, 3:51pm UTC](https://tech-community.robotics.abb.com/t/set-reset-visible-using-vsta/2181/6 "2008-10-01T15:51:59Z")

</div>

Thank you for trying but I think I am not using the same version as you. I am missing GraphicComponents from the station. Are you doing this in VSTA or VS making a Addin? I am working in VSTA.

---

<div class="post-metadata">

**Author:** ![PerSvensson](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/persvensson/32/1040_2.png) [@PerSvensson](https://tech-community.robotics.abb.com/u/PerSvensson)\
**Post date:** [October 1, 2008, 9:59pm UTC](https://tech-community.robotics.abb.com/t/set-reset-visible-using-vsta/2181/7 "2008-10-01T21:59:47Z")

</div>

Hi David

This may give you some hints  
In my example ‘myComponent’ is just the name of a box.

public void Macro\_SwitchVisible()

{

Station stn = Project.ActiveProject as Station;

if (stn == null) return;

GraphicComponent gc = stn.GraphicComponents[“myComponent”];

gc.Visible = !gc.Visible;

}

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/system/32/6_2.png) [@system](https://tech-community.robotics.abb.com/u/system)\
**Post date:** [October 2, 2008, 1:00am UTC](https://tech-community.robotics.abb.com/t/set-reset-visible-using-vsta/2181/8 "2008-10-02T01:00:16Z")

</div>

Hi Per  
That works if my object is in the root of the tree but how do you reference a obj that is inside of a component that is inside of a component? For Example say I have a Component called CIMLetters and inside that component I have a component called LetterC. Inside that component is my actual object. How do I reference down through the two to the object in the string name?

---

<div class="post-metadata">

**Author:** ![PerSvensson](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/persvensson/32/1040_2.png) [@PerSvensson](https://tech-community.robotics.abb.com/u/PerSvensson)\
**Post date:** [October 2, 2008, 10:51pm UTC](https://tech-community.robotics.abb.com/t/set-reset-visible-using-vsta/2181/9 "2008-10-02T22:51:58Z")

</div>

Hi David  
There is a metod for finding certain types(no matter location in the station) but this doesn’t seam to work in VSTA and still you need to loop thru what it reports. But anyway here is an example

Station stn = Project.ActiveProject as Station;

if (stn == null) return;

GraphicComponent gcParts = stn.FindGraphicComponentsByType(typeof(Part));

foreach (Part prt in gcParts)

{

prt.Visible = !prt.Visible;

}
