Enterprise Architect met en œuvre une fonctionnalité de script flexible et facile à utiliser basée sur le standard de l’industrie Javascript, Microsoft JScript et VBScript. Geert Bellekens, propriétaire de Bellekens.com et partenaire de Sparx Systems, démontrera comment l’automatisation peut vous faire gagner du temps.
Dans ce webinaire, vous apprendrez à:
Exemple modéle: | EAExample.eap |
Enterprise Architect 12 (Build 1213).
Oui. Scripting has been available in every version of Enterprise Architect since Enterprise Architect 7.5, Corporate Edition or higher.
Read the Enterprise Architect User Guide for more information about Automation and Scripting.
Oui. Click the link above to download the scripts.
Oui. Click the link above to download the scripts.
The EAExample model was used throughout the webinar. This model ships with every copy of Enterprise Architect.
Automation API support included to allow custom extensions for Autre frameworks and export formats.
Sparx: Oui. You would have to write an executable that can be run as a scheduled task by Windows. Read the Community Site article to learn more information on running scheduled scripts in Windows Server.
Geert: See EA-Matic and its open source code on Github for an example.
Oui. The webinar demonstrated how a script could be applied to several diagram elements.
Oui. You can include and execute scripts from Autre scripts using the !INC statement.
No.
You can use security to allow or disallow Workflow Scripts, but unfortunately this is not available for Standard Scripts. Review the Enterprise Architect User Guide for more information on Workflow Scripts.
No.
No.
However, scripts can be included with MDG Technologies to prevent users from modification. Read the Enterprise Architect User Guide to learn more about adding Scripts to an MDG Technology file.
It is probably best to organize that outside of EA using a version control system of some kind.
There is currently no integration with a version control system for scripts. Any version control will have to be done manually.
The scripts created in the webinar are stored in the model and available only in that model. You can export them and import them into anAutre model in order to use them there as well as shown in the webinar.
Autre options for sharing scripts amongst different model is storing them as a local script by saving the file in the appropriate folder:
<EA Installation Folder>\EA\Scripts
.
You can also save scripts in an MDG technology file and distribute them that way.
No. You can test the elements stereotype in the script and react appropriately.
The API is documented in the help file. See section Automation and Scripting | Enterprise Architect Object Model | Reference
The selection of a scripting Language was a matter of personal preference.
No.
No.
With the "context" script groups you can limit the menu's to Element, Package, Diagram or Connector. If you need more fine-grained control you can consider writing an add-in or using the third party add-in EA-Matic written by Geert Bellekens.
You'll have to work bottom up using EA.Element.ParentID , EA.Element.PackageID and EA.Package.ParentID
something like:
function getQualifiedNameElement(element, fqn)
'add my name to the fqn
fqn = element.name & "/" & fqn
'first check if this element is nested under anAutre element
if element.ParentID > 0 then
dim parentElement as EA.Element
set parentElement = Repository.GetElementByID(element.ParentID)
fqn = getQualifiedNameElement(parentElement, fqn)
else
'no parent element, so we go to the package
dim parentpackage as EA.Package
set parentPackage = Repository.GetPackageByID(element.PackageID)
fqn = getQualifiedNamePackage(parentPackage, fqn)
end if
'return fqn
getQualifiedNameElement = fqn
end function
function getQualifiedNamePackage(package, fqn)
'add my name to the fqn
fqn = package.name & "/" & fqn
if package.ParentID > 0 then
dim parentpackage as EA.Package
set parentPackage = Repository.GetPackageByID(package.ParentID)
fqn = getQualifiedNamePackage(parentPackage, fqn)
end if
'return fqn
getQualifiedNamePackage = fqn
end function
Oui. On the Project Interface there are operations like ImportDirectory() and ImportFile() that can be used to reverse engineer from code.
Oui. For a simple run of a report, read the Enterprise Architect User Guide topic on RunReport. Note that setting the Filename extension (.rtf or .pdf) sets the output type. For a more complex scenario there is the Document Generator Class available to do specific scripted reporting.
Project.RunReport(PackageGUID, "Diagram Report", "C:\Temp\MyDiagrams.pdf")
Or export each individual diagram to a separate PDF using Diagram.SaveAsPDF.
You can find examples in
Oui.
There is a wide variety in use cases. Typically we see thing like
You can use Repository.GetContextItemType() to determine the type of the object in context.
There is a section in the Enterprise Architect User Guide located at Projects and Team | Team Development | Workflow Scripts.
The Community Site also contains a comprehensive white paper on Workflow Scripting in Enterprise Architect.
No.
Geert: Oui, you can use the Excel API to create an excel file from within a script. Or you could do it the Autre way around and write a VBA script in Excel and then use the EA API from within Excel. An example of such an Excel file importing elements into EA is available for free on Bellekens.com
Sparx: MDG Integration for Office is designed to integrate with the Microsoft Office and Visio Suites. Import documents and spreadsheets into Enterprise Architect, providing a rich modeling experience. Learn more about MDG Integration for Microsoft Office and an interface with Microsoft Project.
This is standard VBScript syntax for checking if an object is initialized.
There is an example script in the Local Scripts that deals with tagged values. VBScript - Element Extras Example