Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: aldrich on November 03, 2015, 09:51:29 am
-
I have a set of master documents in my model.
I'd like to run this in batch, by running powershell which would run automation against EA via cmdlets.
Has anyone tried this, and has some example scripts I could lift?
If Powershell isn't the right way to do this, any idea on what is?
I'd think this kind of scripting via a command shell would be useful, but I can't see how to do it from the EA User documentation
-
I did not run powershell but WSH (windows scripting host). And that did work. I have switched to compiled Perl (from ActiveState) later and so lost contact with that.
q.
-
You should be able to load 'Interop.EA.dll' into PowerShell which will give you access to all the scripting and other programmability features. The documented api can then be used as the reference. The most common 'issue' you will run into is that even a batch job needs to have interactive session, but it can be scheduled
Stan.
-
You should be able to load 'Interop.EA.dll' into PowerShell which will give you access to all the scripting and other programmability features. The documented api can then be used as the reference. The most common 'issue' you will run into is that even a batch job needs to have interactive session, but it can be scheduled
Stan.
Hi Stan,
Do you have a, small, worked example you can share?
Paolo
-
Example below, It prints a pdf of the Test Environment Model package from EAExample.
PowerShell has been updated since I last used it (v1.0) so com objects can be called directly - makes it a lot easier then loading the dll.
-------------------------------------------------
# Create the EA object
$ea = New-Object -ComObject "EA.Repository" -Strict
$ea.OpenFile("<path to example model>\EAExample.eap")
$pkg = "{407CEBA1-C9DB-47dd-B8BA-AD5D8ED6DC79}"
$template = "Model Report"
$report = "<path to report location>\Test Environment Model.pdf"
$project = $ea.GetProjectInterface()
$project.RunReport($pkg, $template, $report)
$ea.CloseFile()
$ea.Exit()
-
Cool! Thanks Stan!
The script threw an exception:
Exception calling "RunReport" with "3" argument(s): "The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))"
Not sure why?
Changing the RunReport to a GetFileNameDialog call (with appropriate arguments), "worked like a bought one"!
Paolo
-
On the off chance you spot something, I used the below to test run the script. The EAExample.eap file was in a folder under 'My Documents' not the default location.
OS: Windows 10 Enterprise
EA: Version 12.0.1215
PowerShell Version:
Major Minor Build Revision
----- ----- ----- --------
5 0 10240 16384
-
Thanks all, I was able to get this to work like a charm.
Does anyone know how to execute a script externally from EA?
That is, I have a number of validation scripts within EA that I run prior to publication. It is tedious to run them by hand; I'd like to batch them in a powershell script (i.e. something like Repository.ExecuteScript(pathToScript one after another).
I was hoping there was a scripts collection off of the Repository interface, but no such luck. Any thoughts?
-
You can, but it's not that easy.
Check the code for EA-Matic (http://bellekens.com/ea-matic/) on GitHub (https://github.com/GeertBellekens/Enterprise-Architect-Toolpack/tree/master/EAScriptAddin) This add-in executes scripts in EA.
Geert