导出 Enterprise Architect 图表的自动化方法?

发布于 2024-08-04 15:11:41 字数 424 浏览 7 评论 0原文

问题:我们的许多设计和架构文档都是在 Enterprise Architect 中创建和维护的 - 无论好坏,就是这样。这些文档存储在我们的 subversion 存储库中 - 这对于创建和更新它们的人员来说非常有效 - 因为我们拥有 EA 的许可证 - 但许多开发人员(内部和外部)在我们的代码库上工作并且需要制作使用图表,但并非全部都有 EA 许可证。

糟糕的解决方案:我们可以手动将 EA 文档导出为可移植格式,然后将其签入,但有时可移植格式版本与 EA 文档已经过时,因为它依赖于人工来执行这些步骤手动转换。

更好的解决方案:我们一直在寻找一种自动化转换的方法。这可以作为提交后挂钩或作为我们持续集成系统的一部分运行。我们缺少的部分是允许我们自动化转换的部分。有什么想法吗?

Problem: A lot of our design and architecture documentation were created and maintained in Enterprise Architect - for better or worse, that is how it is. These documents are stored in our subversion repository - which works out pretty well for the folks that create and update them - since we have licenses for EA - but many of the developers (both internal and external) who work on our codebase and need to make use of the diagrams but dont all have EA licenses.

Poor Solution: We could manually export the EA documents to a portable format and then check those in, but there are bound to be times when the portable format version is out of date with the EA document since it relies on the human to take the steps to manually convert.

Better Solution: We have been looking for a method to automate the conversion. This could be run as a post-commit hook or as part of our continuous integration system. The part we are missing is the piece that allows us to automate the conversion. Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

贱人配狗天长地久 2024-08-11 15:11:41

在示例代码中,我刚刚发现了一个函数 Wish 可以完全满足您的需求。但隐藏在不太有用的名称 ProjectInterfaceExample 中:

option explicit

!INC Local Scripts.EAConstants-VBScript

'
' Examples of how to access and use the Project Interface.
' 
' Related APIs
' =================================================================================
' Project Interface API - http://www.sparxsystems.com/uml_tool_guide/sdk_for_enterprise_architect/project_2.html
'

' Global reference to the project interface
dim projectInterface as EA.Project

sub ProjectInterfaceExample()

    ' Show the script output window
    Repository.EnsureOutputVisible "Script"

    Session.Output( "VBScript PROJECT INTERFACE EXAMPLE" )
    Session.Output( "=======================================" )


    set projectInterface = Repository.GetProjectInterface()

    ' Iterate through all model nodes
    dim currentModel as EA.Package
    for each currentModel in Repository.Models

        ' Iterate through all child packages and save out their diagrams
        dim childPackage as EA.Package
        for each childPackage in currentModel.Packages
            DumpDiagrams childPackage
        next
    next

    Session.Output( "Done!" )

end sub

'
' Recursively saves all diagrams under the provided package and its children
'
sub DumpDiagrams ( thePackage )

    ' Cast thePackage to EA.Package so we get intellisense
    dim currentPackage as EA.Package
    set currentPackage = thePackage

    ' Iterate through all diagrams in the current package
    dim currentDiagram as EA.Diagram
    for each currentDiagram in currentPackage.Diagrams

        ' Open the diagram
        Repository.OpenDiagram( currentDiagram.DiagramID )

        ' Save and close the diagram
        Session.Output( "Saving " & currentDiagram.Name )
        projectInterface.SaveDiagramImageToFile "c:\\temp\\" + currentDiagram.Name + ".emf"
        Repository.CloseDiagram( currentDiagram.DiagramID )
    next

    ' Process child packages
    dim childPackage as EA.Package
    for each childPackage in currentPackage.Packages    
        DumpDiagrams childPackage
    next

end sub

ProjectInterfaceExample

您可能需要稍微微调一下(即不要将所有内容写入 C:\Temp),但这是一个好的开始。

In the Example code I just discovered a function whish will do exactly what you want. But hidden away by the not so helpfull name of ProjectInterfaceExample:

option explicit

!INC Local Scripts.EAConstants-VBScript

'
' Examples of how to access and use the Project Interface.
' 
' Related APIs
' =================================================================================
' Project Interface API - http://www.sparxsystems.com/uml_tool_guide/sdk_for_enterprise_architect/project_2.html
'

' Global reference to the project interface
dim projectInterface as EA.Project

sub ProjectInterfaceExample()

    ' Show the script output window
    Repository.EnsureOutputVisible "Script"

    Session.Output( "VBScript PROJECT INTERFACE EXAMPLE" )
    Session.Output( "=======================================" )


    set projectInterface = Repository.GetProjectInterface()

    ' Iterate through all model nodes
    dim currentModel as EA.Package
    for each currentModel in Repository.Models

        ' Iterate through all child packages and save out their diagrams
        dim childPackage as EA.Package
        for each childPackage in currentModel.Packages
            DumpDiagrams childPackage
        next
    next

    Session.Output( "Done!" )

end sub

'
' Recursively saves all diagrams under the provided package and its children
'
sub DumpDiagrams ( thePackage )

    ' Cast thePackage to EA.Package so we get intellisense
    dim currentPackage as EA.Package
    set currentPackage = thePackage

    ' Iterate through all diagrams in the current package
    dim currentDiagram as EA.Diagram
    for each currentDiagram in currentPackage.Diagrams

        ' Open the diagram
        Repository.OpenDiagram( currentDiagram.DiagramID )

        ' Save and close the diagram
        Session.Output( "Saving " & currentDiagram.Name )
        projectInterface.SaveDiagramImageToFile "c:\\temp\\" + currentDiagram.Name + ".emf"
        Repository.CloseDiagram( currentDiagram.DiagramID )
    next

    ' Process child packages
    dim childPackage as EA.Package
    for each childPackage in currentPackage.Packages    
        DumpDiagrams childPackage
    next

end sub

ProjectInterfaceExample

You might have to fine tune it a litte (i.E. not writing everything into C:\Temp) but it is a good start.

雪化雨蝶 2024-08-11 15:11:41

我不熟悉该产品,但您链接到的网站提到了自动化界面。这应该允许您通过脚本语言(例如 VBScript 或 JavaScript)控制 Enterprise Architect。可以通过该接口进行打印;如果是这样,您可以安装 PDF 打印机驱动程序(或打印到使用通用 PostScript 打印机驱动程序创建一个文件,并使用 GhostScript 将其转换为 PDF。

I am not familiar with this product but the Web site you link to mentions an Automation interface. This should allow you to control Enterprise Architect from a scripting language such as VBScript or JavaScript. It may be possible to print via this interface; if so, you could install a PDF printer driver (or print to a file using a generic PostScript printer driver and use GhostScript to convert it to PDF.

北座城市 2024-08-11 15:11:41

我们有 Enterprise Architect,并且我们将它与 Word 完美集成。我们编写了自己的 Wicket/Jetty WebApp,它将 EA 图的链接作为 HTTP URL 发布,然后我们将其“插入并链接”到我们的 UCR(或其他任何内容)文档中。 Web 应用程序显示一个树状链接结构,每个包对应一个链接,然后我们只需将链接复制到 Word 文档中即可。

效果非常好。我们可以在 EA 中进行任意多的更改,然后在 Word 文档中只需按 CTRL+A 选择全部并按 F9 更新所有链接。不幸的是我没有编写代码,所以我无法确切地告诉你它是如何从 EA 发布的。我认为有一些 Java 代码只是轮询 EA 服务器并在检测到更改时吸出所有内容。

We have Enterprise Architect and we have it nicely integrated with Word. We wrote our own Wicket/Jetty WebApp that publishes links to EA diragrams as an HTTP URL that we then "Insert&Link" into our UCR (or anything else) documents. The web app displays a tree like structure of links, one for each package and then we just copy the link into the word document.

It works really well. We can make as many changes as we like in EA and then in the Word document just go CTRL+A to select all and hit F9 to update all links. Unfortunately I didn't write the code so I can't tell you exactly how it's published from EA. I think there's some Java code that just polls the EA server and sucks out everything if it detects changes.

逐鹿 2024-08-11 15:11:41

VBScript 确实是一种简单快捷的方法。我想出了一个可以导出图表的小脚本。您唯一需要知道的是它的 GUID。

Set MyRep = CreateObject("EA.Repository")

If NOT MyRep.OpenFile("D:\Repository.eap") Then
  MsgBox("Error opening file")
  WScript.Quit -1
End If

Set Project = MyRep.GetProjectInterface

My_Diagram_GUID = "{2256B231-99F6-4c78-9AB0-72E24486D578}"

'Vector export emf/wmf
Project.PutDiagramImageToFile My_Diagram_GUID,"D:\Test.emf",0

'Bitmap export png/bmp/...
Project.PutDiagramImageToFile My_Diagram_GUID,"D:\Test.png",1

VBScript is really an easy and quick possibility. I figured out a small script that allows to export a diagram. The only think you have to know is it's GUID.

Set MyRep = CreateObject("EA.Repository")

If NOT MyRep.OpenFile("D:\Repository.eap") Then
  MsgBox("Error opening file")
  WScript.Quit -1
End If

Set Project = MyRep.GetProjectInterface

My_Diagram_GUID = "{2256B231-99F6-4c78-9AB0-72E24486D578}"

'Vector export emf/wmf
Project.PutDiagramImageToFile My_Diagram_GUID,"D:\Test.emf",0

'Bitmap export png/bmp/...
Project.PutDiagramImageToFile My_Diagram_GUID,"D:\Test.png",1
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文