Question

I'm able to append some TaggedValues into EA Element using EA Script. Now, I would like to append those TaggedValues automatically when the targetted Element is created.

Is it possible for an EA Script or EA Add-In to get triggered on an event, more specificly: on EA Element creation event?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top