Add-In, yes; script, no. Scripts only have access to the Object Model API, while Add-Ins also have access to the Add-In Model API, where the event callbacks are located.
The various events are documented in the help file under Automation and Scripting -- Enterprise Architect Add-In Model. Events relating to model CRUD are under Broadcast Events.
In order to add a tagged value to an element when it is created, you'll need an Add-In that responds to EA_OnPostNewElement
. This is called after the element has been created, and allows you to make further changes to it. (By contrast, EA_OnPreNewElement
is called before the element has been created, allowing you to prevent it from being created in the first place but not to make any changes since it does not yet exist.)
Your implementation of EA_OnPostNewElement
must return true
if it makes any changes to the element, and false
if it does not (your Add-In will get called whenever any element is created, and presumably you only want to add the tagged value to some elements).
All that said, in most cases it is simpler to specify a tagged value in a profile rather than write a custom Add-In to do it, but that's not what you're asking about.