导出Enterprise Architect图表的自动化方法? [英] Automated method to export Enterprise Architect diagrams?

查看:171
本文介绍了导出Enterprise Architect图表的自动化方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:我们的许多设计和体系结构文档都是在 Enterprise Architect 中创建和维护的-为了更好或更糟的是,事实就是这样。这些文档存储在我们的Subversion存储库中-对于创建和更新它们的人们来说效果很好-由于我们拥有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.

糟糕的解决方案:我们可以将EA文档手动导出为可移植格式,然后将其检入,但是有时会出现便携式格式版本用尽的情况。

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?

推荐答案

在示例代码中,我刚刚发现一个函数可以完全满足您的要求。但是被 ProjectInterfaceExample 这个不太有用的名称所掩盖:

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

您可能需要对其进行微调小东西(即不是将所有内容都写到C:\Temp中),但这是一个好的开始。

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

这篇关于导出Enterprise Architect图表的自动化方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆