Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: coatie on July 24, 2015, 04:30:37 am
-
Hello,
just wrote me a Powershell script to open an EA model and realized that my add-in is not enabled when running EA via the PS script.
Snippet from powershell script:
...
$dbConnection = "DBType=3;Connect=Provider=OraOLEDB.Oracle.1;Password=XXXXX;Persist Security Info=True;User ID=YYYYYY;Data Source=eadb;"
$EaApp = New-Object -ComObject "EA.App"
$EaRepo = $EaApp.Repository
$EaRepo.OpenFile2($dbConnection,"user","secret"))
...
After calling the OpenFile2 I expected the event EA_FileOpen to be fired and my Add-In (C# DLL) to do some action but it didn't happen. Then I added $EaRepo.ShowWindow(1) to the Powershell script and found that my Add-In is in state "disabled" within the Addin-Manager.
Any way to enabled it?
Markus
-
That means you did something wrong during initialization. Unfortunately EA just lets you guess about what that might have been :-/
q.
-
No add-ins are loaded when EA is created from automation. It behaves that way so that add-ins don't interfere with the caller.
There should be1 API functions to load the add-ins.
1 Meaning I remember a function to load a specific add-in, and one to load all add-ins being implemented a while back in response to a similar situation. I assume they are part of 12, but no idea what they are called.
-
See Repository.LoadAddins(). Introduced in EA 11 Build 1105.
http://www.sparxsystems.com/enterprise_architect_user_guide/12.0/automation_and_scripting/repository3.html
-
Thanks a lot, totally missed that when browsing the help...
Anything else to consider?
I added the LoadAddins() (tried before and after OpenFile2) to the PS script and now the Addin is in state enabled but still events seem not to be triggered and menu entry of the Addin is missing.
Using EA 11.0.1106
-
Add-ins are supposed to react to human interaction. External scripts are intended to run in batch (without human interaction). So I don't see the point in enabling add-ins for batch use. If you run a batch then include all code you need.
q.
-
If you run a batch then include all code you need.
That's exactly what I wanted to prevent and was looking for an alternative and use the trigger EA_FileOpen for supporting automation from within my add-in.
BTW, why was LoadAddins() added if there would be no need for it?
-
BTW, why was LoadAddins() added if there would be no need for it?
I can't count the number of features that have been added with (at least) doubtful use cases.
q.
-
At a minimum, it could be required for add-ins providing an MDG technology. (ie. An external script to run documentation isn't going to be useful if the shape scripts defined in an add-in aren't used)