# Iterate through all components programatically in Perspective?

**URL:** <https://forum.inductiveautomation.com/t/iterate-through-all-components-programatically-in-perspective/32938>\
**Category:** Ignition\
**Tags:** ignition80, perspective\
**Created:** [March 9, 2020, 7:39pm UTC](https://forum.inductiveautomation.com/t/iterate-through-all-components-programatically-in-perspective/32938 "2020-03-09T19:39:52Z")\
**Posts on this page:** 2\
**Page:** 2

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [December 4, 2023, 5:44pm UTC](https://forum.inductiveautomation.com/t/iterate-through-all-components-programatically-in-perspective/32938/21 "2023-12-04T17:44:18Z")

</div>

We went with this one so our `util` library looks like

```auto
def getComponents(element):
	def walkComponents(component):
		for child in component.children:
			yield child
			walkComponents(child)
	return walkComponents(element)

def parseContainer(container):
	return {
		c.name: c.custom["outValue"]
		for c in getComponents(container) if "outValue" in c.custom
	}

```

and call parseContainer on a container works as we expect it too.

Decided on this one because it's the most readable to me and without needing a library.

Thank you all very much!

---

<div class="post-metadata">

**Author:** ![basel\_Kalalib-Achabi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/basel_kalalib-achabi/32/62564_2.png) [@basel\_Kalalib-Achabi](https://forum.inductiveautomation.com/u/basel_Kalalib-Achabi)\
**Post date:** [May 18, 2024, 5:51pm UTC](https://forum.inductiveautomation.com/t/iterate-through-all-components-programatically-in-perspective/32938/22 "2024-05-18T17:51:23Z")

</div>

Hello I'm having a similar problem:

I have a view with a bunch of components. Each one of them has the following custom properties : _ **name** (bined to the meta name to make the iterating code simpler), **tagPath** , and **status**._

How can I iterate through that view's components and spit out a dictionary of dictionaries which should look like this below?

```python
myList = 
{
"EmbeddedView_1": {"name": EmbeddedView_1,"tagPath": "some path", "status": "open"},
"EmbeddedView_2": {"name": EmbeddedView_2,"tagPath": "some_other_path", "status": "close"},
"EmbeddedView_2": {"name": EmbeddedView_3,"tagPath": "a_different_path", "status": "close"},
 etc ...
}

```

Thank you.  
Basel

[Previous page](https://forum.inductiveautomation.com/t/iterate-through-all-components-programatically-in-perspective/32938.md?page=1)
