# Copy one UDT Tag to Another

**URL:** <https://forum.inductiveautomation.com/t/copy-one-udt-tag-to-another/23080>\
**Category:** Ignition\
**Tags:** ignition79\
**Created:** [March 5, 2019, 10:42pm UTC](https://forum.inductiveautomation.com/t/copy-one-udt-tag-to-another/23080 "2019-03-05T22:42:09Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [March 5, 2019, 10:42pm UTC](https://forum.inductiveautomation.com/t/copy-one-udt-tag-to-another/23080/1 "2019-03-05T22:42:09Z")

</div>

Is there a way to copy one udt tag and values to another udt tag? Not the individual members but the whole thing at once.

I tried:

```auto
newUDT = system.tag.read(path to UDT to copy).value
system.tag.write(path to UDT to overwrite, newUDT)

```

But I’m getting an error that says that the tag doesn’t support writing.

Any nifty ways to do this? Or do I need to individually deep copy each member to the new spot?

---

<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:** [March 6, 2019, 1:55am UTC](https://forum.inductiveautomation.com/t/copy-one-udt-tag-to-another/23080/2 "2019-03-06T01:55:19Z")

</div>

Deep copy, sorry. And you need to skip any that are expressions or derived tags.

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [March 8, 2019, 4:58pm UTC](https://forum.inductiveautomation.com/t/copy-one-udt-tag-to-another/23080/3 "2019-03-08T16:58:59Z")

</div>

Not a problem. Thanks for getting back to me.

---

<div class="post-metadata">

**Author:** ![jesse.daniels](https://avatars.discourse-cdn.com/v4/letter/j/e36b37/32.png) [@jesse.daniels](https://forum.inductiveautomation.com/u/jesse.daniels)\
**Post date:** [January 27, 2020, 6:11pm UTC](https://forum.inductiveautomation.com/t/copy-one-udt-tag-to-another/23080/4 "2020-01-27T18:11:41Z")

</div>

Sorry, I’m new to Ignition and Python. Can you please explain deep copy. I’m using Ignition 8 and have a UDT that I want to copy all of its members’ values (values only) to a different UDT. This seems impossible at the moment without going one by one.  
This would make a huge script as some of the members of the UDT are another UDT type.

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [January 27, 2020, 6:57pm UTC](https://forum.inductiveautomation.com/t/copy-one-udt-tag-to-another/23080/5 "2020-01-27T18:57:07Z")

</div>

“Deep copy” refers to going one by one through the members. You may want to make a script that browses through the members and copies the values for all relevant members (skip expressions, etc.), rather than hard-coding all the members to copy. See [system.tag.browse](https://docs.inductiveautomation.com/display/DOC80/system.tag.browse).

---

<div class="post-metadata">

**Author:** ![jesse.daniels](https://avatars.discourse-cdn.com/v4/letter/j/e36b37/32.png) [@jesse.daniels](https://forum.inductiveautomation.com/u/jesse.daniels)\
**Post date:** [January 27, 2020, 8:02pm UTC](https://forum.inductiveautomation.com/t/copy-one-udt-tag-to-another/23080/6 "2020-01-27T20:02:26Z")

</div>

Thanks witman.  
Do you have any examples of the system.tag.browse? The user manual isn’t very helpful on this. When I use it, it returns everything. How can I get it to only return a list of filtered criteria?

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [January 27, 2020, 9:27pm UTC](https://forum.inductiveautomation.com/t/copy-one-udt-tag-to-another/23080/7 "2020-01-27T21:27:32Z")

</div>

You’ll need to recursively browse tags that don’t meet your criteria to find the ones below them that do. Something like this should get you close to what you’re looking for (returns all tags in the specified path with valueSource type of opc or memory:

```python
def browseForTags(path, valueSources):
	'''Return tag paths of the specified valueSource type(s).'''
	
	# Call the browse function.
	results = system.tag.browse(path, {})
	 
	# Loop through every item in the results.
	for result in results.getResults():
		# If result has children, call the function to repeat the process, starting at the child.
		if result['hasChildren']:
			browseForTags(result['fullPath'], valueSources)
		elif result['valueSource'] in valueSources:
			tagsToCopy.append(result['fullPath'])
         
# Create an empty list to be filled with tag paths.
tagsToCopy = []
# Set parameters & call function.
path = '[default]' # Replace with root path of UDT/folder to copy.
valueSources = ['opc', 'memory']
browseForTags(path, valueSources)
# Print results.
for tagPath in tagsToCopy:
	print tagPath

```

You can take the list of tag paths, read them, manipulate the names to match the paths you need to copy them to (hopefully just a different root path), and then write all the read values to the new list of tag paths.
