Using scripts to create UDT data types

From reading the documentation, I can gather that it is really easy to add an instance of a UDT using system.tag.addTag(), however what if we want to make our own UDT’s via script as well? Is this possible? I could not figure out by looking at the documentation.

Assuming this is from a development standpoint, you could just write a script to create the XML definition of a UDT that you could import into the project.

Not sure how you would expect to do this at runtime since you would also have to create objects that could reference it.