# Removing items in a window through project script?

**URL:** <https://forum.inductiveautomation.com/t/removing-items-in-a-window-through-project-script/19770>\
**Category:** Ignition\
**Created:** [September 21, 2018, 6:01pm UTC](https://forum.inductiveautomation.com/t/removing-items-in-a-window-through-project-script/19770 "2018-09-21T18:01:02Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![joe.brodersen](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/joe.brodersen/32/3303_2.png) [@joe.brodersen](https://forum.inductiveautomation.com/u/joe.brodersen)\
**Post date:** [September 21, 2018, 6:01pm UTC](https://forum.inductiveautomation.com/t/removing-items-in-a-window-through-project-script/19770/1 "2018-09-21T18:01:02Z")

</div>

Is there a way to remove an object (e.g. a button) from a project script? I can use the .getWindow and .getRootContainer to access the window’s components, but I’m trying to find a component.delete or something to that effect.

---

<div class="post-metadata">

**Author:** ![mrogers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mrogers/32/4110_2.png) [@mrogers](https://forum.inductiveautomation.com/u/mrogers)\
**Post date:** [September 21, 2018, 6:04pm UTC](https://forum.inductiveautomation.com/t/removing-items-in-a-window-through-project-script/19770/2 "2018-09-21T18:04:03Z")

</div>

To that effect, simply make it invisible (.visible = False). I don’t believe there is a way to actually delete it. The only other way is if you were to use a template canvas or repeater, but it doesn’t sound like that is what you’re looking for.

---

<div class="post-metadata">

**Author:** ![joe.brodersen](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/joe.brodersen/32/3303_2.png) [@joe.brodersen](https://forum.inductiveautomation.com/u/joe.brodersen)\
**Post date:** [September 21, 2018, 6:07pm UTC](https://forum.inductiveautomation.com/t/removing-items-in-a-window-through-project-script/19770/3 "2018-09-21T18:07:24Z")

</div>

Good thought, but I need it gone.

---

<div class="post-metadata">

**Author:** ![mrogers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mrogers/32/4110_2.png) [@mrogers](https://forum.inductiveautomation.com/u/mrogers)\
**Post date:** [September 21, 2018, 6:10pm UTC](https://forum.inductiveautomation.com/t/removing-items-in-a-window-through-project-script/19770/4 "2018-09-21T18:10:13Z")

</div>

Why must it be completely gone? If its not visible, it wont be clicked so unless there’s something else its doing, it should be effectively gone. If it is doing something else, just check if its visible and do it if it is, don’t do it if its not.

---

<div class="post-metadata">

**Author:** ![joe.brodersen](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/joe.brodersen/32/3303_2.png) [@joe.brodersen](https://forum.inductiveautomation.com/u/joe.brodersen)\
**Post date:** [September 21, 2018, 6:16pm UTC](https://forum.inductiveautomation.com/t/removing-items-in-a-window-through-project-script/19770/5 "2018-09-21T18:16:58Z")

</div>

The reason being, is that if a customer doesn’t have a particular object (on my template that gets generated for our customers) then there is no reason to keep around except to give me problems if the tag behind it does not exist or something else. I’m wanting to remove what does not exist in the PLC. I did a quick test and pointed to a non-existing value, and fair enough that stays invisible. Will that work for a template with a UDT attached? I’d just rather remove.

---

<div class="post-metadata">

**Author:** ![mrogers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mrogers/32/4110_2.png) [@mrogers](https://forum.inductiveautomation.com/u/mrogers)\
**Post date:** [September 21, 2018, 6:21pm UTC](https://forum.inductiveautomation.com/t/removing-items-in-a-window-through-project-script/19770/6 "2018-09-21T18:21:40Z")

</div>

It should. However if you’re using a UDT as a parameter in a template, I’d heavily suggest you don’t. Just pass the path to the tag in and read it like that. Especially if you have many of these templates on a window - the reason is, it will load the entire UDT into each template even if you only read one or two things from it. It can really slow things down overall.

---

<div class="post-metadata">

**Author:** ![joe.brodersen](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/joe.brodersen/32/3303_2.png) [@joe.brodersen](https://forum.inductiveautomation.com/u/joe.brodersen)\
**Post date:** [September 21, 2018, 6:22pm UTC](https://forum.inductiveautomation.com/t/removing-items-in-a-window-through-project-script/19770/7 "2018-09-21T18:22:03Z")

</div>

Bigger picture: I have a set of window templates that I control. I want to be able to configure that template for my customer via a simple script (fed in via XML or SQL table). Run the script, and configure (preferably delete) so that the user will never see it. The problem is, I will never be rid of a customer who wants to customize the screens, so they will eventually get to it. Therefore, I’d rather delete than hide what functionality (or elements) they didn’t pay for.

---

<div class="post-metadata">

**Author:** ![joe.brodersen](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/joe.brodersen/32/3303_2.png) [@joe.brodersen](https://forum.inductiveautomation.com/u/joe.brodersen)\
**Post date:** [September 21, 2018, 6:22pm UTC](https://forum.inductiveautomation.com/t/removing-items-in-a-window-through-project-script/19770/8 "2018-09-21T18:22:34Z")

</div>

I do appreciate you input. I’m just pigeon-holed to some degree.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 22, 2018, 3:45am UTC](https://forum.inductiveautomation.com/t/removing-items-in-a-window-through-project-script/19770/9 "2018-09-22T03:45:29Z")

</div>

The container’s .remove() method should do it, but you might have to remove all of that component’s bindings first. Totally unsupported, of course.

---

<div class="post-metadata">

**Author:** ![stephen.ross](https://avatars.discourse-cdn.com/v4/letter/s/a183cd/32.png) [@stephen.ross](https://forum.inductiveautomation.com/u/stephen.ross)\
**Post date:** [January 10, 2019, 10:38pm UTC](https://forum.inductiveautomation.com/t/removing-items-in-a-window-through-project-script/19770/10 "2019-01-10T22:38:35Z")

</div>

I can verify that the .remove() method does indeed work whether or not it is bound to anything. I tested it with tag bindings and a few component property bindings and have not had a problem yet!

-Code Snippet-

Window = system.gui.getWindow(“Test”)  
Container = Window.getRootContainer()

Component\_Array = Container.getComponents()

for Component in Component\_Array:

```
if( component.getName() == "Button 3"):
	Container.remove(component)
```
