Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: nealthereader on August 10, 2016, 11:02:43 pm

Title: extract diagram as bpmn2.0 xml
Post by: nealthereader on August 10, 2016, 11:02:43 pm
is it possible to extract bpmn2.0 xml from programatic interface?
Title: Re: extract diagram as bpmn2.0 xml
Post by: PeterHeintz on August 10, 2016, 11:18:48 pm
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?
Title: Re: extract diagram as bpmn2.0 xml
Post by: qwerty on August 10, 2016, 11:34:30 pm
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.
Title: Re: extract diagram as bpmn2.0 xml
Post by: nealthereader on August 10, 2016, 11:51:16 pm
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)
Title: Re: extract diagram as bpmn2.0 xml
Post by: Geert Bellekens on August 11, 2016, 02:09:31 am
I think that's possible yes, where are you having difficulties?

Geert
Title: Re: extract diagram as bpmn2.0 xml
Post by: nealthereader on August 11, 2016, 03:18:44 am
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()
Title: Re: extract diagram as bpmn2.0 xml
Post by: qwerty on August 11, 2016, 05:08:53 am
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.
Title: Re: extract diagram as bpmn2.0 xml
Post by: nealthereader on August 11, 2016, 07:44:41 am
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"
Title: Re: extract diagram as bpmn2.0 xml
Post by: qwerty on August 11, 2016, 08:07:15 am
You're using Windoze\

q.
Title: Re: extract diagram as bpmn2.0 xml
Post by: Eve on August 11, 2016, 08:57:14 am
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)