Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: nealthereader on August 10, 2016, 11:02:43 pm
-
is it possible to extract bpmn2.0 xml from programatic interface?
-
I assume, you need to be a bit more precise in what you intend to achieve.
In a modelling environment a diagram is nothing/empty without the model behind.
What do you want to do with you extracted xml file?
-
IIRC there is a XMI export specific to BPMN. I seem to remember some Sparxian was talking about that in another thread. And at the same level of memory there is the information that this export format is not (yet) realized.
q.
-
I use extracted bpmn file to show on web UI with http://bpmn.io/ (http://bpmn.io/) library.
What I am trying to do is use powershell with Interop.EA.dll and programmatic extract diagram in bpmn2.0 xml
http://www.sparxsystems.com/enterprise_architect_user_guide/9.3/automation/project_2.html (http://www.sparxsystems.com/enterprise_architect_user_guide/9.3/automation/project_2.html)
-
I think that's possible yes, where are you having difficulties?
Geert
-
Here is my powershell script.
ExportPackageXMI may have some direction to answer but need help how to get there.
$eapDll="C:/Program Files (x86)/Sparx Systems/EA/Interop.EA.dll"
$eapFile="C:/eap/test.eap"
$extractedFile="C:/eap/extracted.xml"
[system.reflection.assembly]::LoadFile($eapDll)
$rep=New-Object EA.RepositoryClass
$rep.OpenFile($eapFile)
$project=New-Object EA.ProjectClass
#peaid is package guid
$peaid = $project.GUIDtoXML('{EB97F043-D87E-42ff-B58C-6645F9143C2C}')
#eaid is model guid
$eaid = $project.GUIDtoXML('{7598E729-E4D3-4f78-B339-01765F583D7A}')
#$project.ExportPackageXMI($peaid, 'xmiEA20', 1, '-1', 1, 1, $extractedFile)
#$project.PutDiagramImageToFile("{7598E729-E4D3-4f78-B339-01765F583D7A}",$extractedFile,0)
#$project.ExportPackageXMIEx($peaid, 'xmiEADefault', 1,'-1',1, 1, $extractedFile, 'epSaveToStub')
#Write-Output $project.EnumDiagramElements($eaid)
$project.Exit()
-
To export BPMN2.0 (I was wrong with the export, it's just the import which is missing), you need to supply 20 (xmiBPMN20 = 20) as 2nd. parameter.
See http://sparxsystems.com/enterprise_architect_user_guide/12.1/automation_and_scripting/xmitypeenum.html (http://sparxsystems.com/enterprise_architect_user_guide/12.1/automation_and_scripting/xmitypeenum.html) and http://sparxsystems.com/enterprise_architect_user_guide/12.1/automation_and_scripting/project_2.html (http://sparxsystems.com/enterprise_architect_user_guide/12.1/automation_and_scripting/project_2.html)
q.
-
Thanks Everyone
Solved
$project.ExportPackageXMI($peaid, 20, 1, '-1', 1, 1, $extractedFile)
somehow file path need back slash instead of forward.
$extractedFile="C:\eap\extracted.xml"
-
You're using Windoze\
q.
-
The '20' in that call corresponds to the constant xmiBPMN20. Which is documented at http://sparxsystems.com/enterprise_architect_user_guide/13.0/automation/xmitypeenum.html (http://sparxsystems.com/enterprise_architect_user_guide/13.0/automation/xmitypeenum.html)