# \[feature-781\]Perspective: Check if Embedded View 'path' is valid?

**URL:** <https://forum.inductiveautomation.com/t/feature-781-perspective-check-if-embedded-view-path-is-valid/39583>\
**Category:** Ignition\
**Tags:** ignition80, perspective\
**Created:** [October 12, 2020, 2:04am UTC](https://forum.inductiveautomation.com/t/feature-781-perspective-check-if-embedded-view-path-is-valid/39583 "2020-10-12T02:04:57Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [October 12, 2020, 2:04am UTC](https://forum.inductiveautomation.com/t/feature-781-perspective-check-if-embedded-view-path-is-valid/39583/1 "2020-10-12T02:04:57Z")

</div>

v8.1rc1

Is it possible to check if an Embedded View `path` property value is valid? I want to hide the component if it’s not, as I’m using a generic structure to generate the path, where some instances don’t have the item.

Essentially, I’m asking if there’s a function to check if a View path exists?

Also, can I get the view path of an open view? As in the path seen in the Designer project tree:  
For this below, it would be Winery/Tank Farms/Main  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/4/140708f3c9467cff200724936735f265bf773eba.png)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [October 12, 2020, 4:24pm UTC](https://forum.inductiveautomation.com/t/feature-781-perspective-check-if-embedded-view-path-is-valid/39583/2 "2020-10-12T16:24:17Z")

</div>

I filed an internal ticket a long time ago to add a `system.perspective.getViewNames()` or similar tool for introspection, along the lines of the Vision function. That’s probably your best bet here.

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [February 18, 2021, 5:18pm UTC](https://forum.inductiveautomation.com/t/feature-781-perspective-check-if-embedded-view-path-is-valid/39583/3 "2021-02-18T17:18:44Z")

</div>

I [posted a proposal](http://forum.inductiveautomation.com/t/automatically-creating-perspective-navigation/24338/7) on another thread that I think will solve this ask.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [December 6, 2021, 12:24pm UTC](https://forum.inductiveautomation.com/t/feature-781-perspective-check-if-embedded-view-path-is-valid/39583/4 "2021-12-06T12:24:04Z")

</div>

Was anything like this ever implemented? I’m running into the same issue again (albeit in 8.1.5) where I’m using an Embedded View where the view path is dynamic. Often the path will be invalid (which is valid) and in these cases I want to hide the embedded view. I don’t see a way to do this. For me, an expression function `viewExists('Path/To/View')` would be great here to have

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [December 6, 2021, 12:42pm UTC](https://forum.inductiveautomation.com/t/feature-781-perspective-check-if-embedded-view-path-is-valid/39583/5 "2021-12-06T12:42:20Z")

</div>

Maybe there is a easier way but this works xd  
It checks if the resource folder of the view exists^^

```auto
	def viewExists(viewpath):	
		from com.inductiveautomation.ignition.gateway import IgnitionGateway			
		context = IgnitionGateway.get()	
		pathToProjectFolder = str(context.systemManager.dataDir.absoluteFile).replace('\\','/') + '/projects'	
		pathToProject = pathToProjectFolder + "/" + system.perspective.getProjectInfo().name + "/com.inductiveautomation.perspective/views/"
		return system.file.fileExists(pathToProject + viewpath)

```

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [December 6, 2021, 1:17pm UTC](https://forum.inductiveautomation.com/t/feature-781-perspective-check-if-embedded-view-path-is-valid/39583/6 "2021-12-06T13:17:29Z")

</div>

Haha, that’s works. I didn’t even think about doing it that way, cheers. I’ll use that for now

I guess for speed I could cache a list of all views found updated periodically or on trigger (eg designer save) and then read from that instead. I’ll see what kind of delay I get, shouldn’t be too bad though!

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [December 6, 2021, 1:22pm UTC](https://forum.inductiveautomation.com/t/feature-781-perspective-check-if-embedded-view-path-is-valid/39583/7 "2021-12-06T13:22:39Z")

</div>

i dont think there is going to be any noticable delay. but i havent tested it with crazy deep folders xd

it just takes about a milisecond or 2 for my views so xd  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/b/8b2d29bcabc1b376e350e280e60ad2d9a428410e.png)

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/2/5232cf7b15985b7a856d0c4a0e5bd6325773a290.png)

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [December 6, 2021, 1:36pm UTC](https://forum.inductiveautomation.com/t/feature-781-perspective-check-if-embedded-view-path-is-valid/39583/8 "2021-12-06T13:36:59Z")

</div>

> [@victordcq](#):
>
> about a milisecond or 2

My operators will probably still complain 😂

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [December 6, 2021, 1:39pm UTC](https://forum.inductiveautomation.com/t/feature-781-perspective-check-if-embedded-view-path-is-valid/39583/9 "2021-12-06T13:39:54Z")

</div>

average human reaction time is about 250milisec so i think you’re safe 😛  
even the fastest reacting animals (fruit flies?) need 5ms

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [December 6, 2021, 3:19pm UTC](https://forum.inductiveautomation.com/t/feature-781-perspective-check-if-embedded-view-path-is-valid/39583/10 "2021-12-06T15:19:26Z")

</div>

`system.perspective.getProjectInfo()` returns a `views` array, you can check that for the view. Probably substantially faster than filesystem access.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [December 6, 2021, 3:25pm UTC](https://forum.inductiveautomation.com/t/feature-781-perspective-check-if-embedded-view-path-is-valid/39583/11 "2021-12-06T15:25:06Z")

</div>

Apparently yes, Carl posted this in the thread he linked:

> [@Automatically creating Perspective Navigation](https://forum.inductiveautomation.com/t/automatically-creating-perspective-navigation/24338/11):
>
> We ended up implementing this as a scripting call after all. The json shape I indicated above will be returned from session.getProjectInfo() and system.perspective.getProjectInfo() as of 8.1.4

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [December 6, 2021, 3:25pm UTC](https://forum.inductiveautomation.com/t/feature-781-perspective-check-if-embedded-view-path-is-valid/39583/12 "2021-12-06T15:25:20Z")

</div>

> [@paul-griffith](#):
>
> Probably substantially faster than filesystem access

It seems to be going a tiny bit faster. Tho you gotta itterate over an array of dicts so if you got many views idk if it will be actually faster.

```auto
def viewExists(view):
	return any(x.path == view for x in system.perspective.getProjectInfo().views)

```

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [December 14, 2021, 10:30pm UTC](https://forum.inductiveautomation.com/t/feature-781-perspective-check-if-embedded-view-path-is-valid/39583/13 "2021-12-14T22:30:47Z")

</div>

6 posts were split to a new topic: [Jython filtering profiling](https://forum.inductiveautomation.com/t/jython-filtering-profiling/54120)
