Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: kwasposer on February 14, 2020, 10:16:45 pm

Title: openfile2 eapx win32com python
Post by: kwasposer on February 14, 2020, 10:16:45 pm
Hello, i was able to open a Enterprise Architect Model from python, with following commands

Unfortunatly I was not able to open a *.eapx File.

What do I have to do to open a *.eapx File?

Code: [Select]

import win32com.client
import sys

def ea():
    try:
        eaApp = win32com.client.Dispatch('EA.App')
        eaRep = eaApp.Repository
    except:
        print("failure dispatch")
        sys.exit(2)
    try:

#------------------------------- How to open *eapx ? --------------------------------------------------------


        eaRep.OpenFile2('C:\Sync\TestStand\Python\easparx\Model1.eap', 1, 0) # Working perfectly!
        #eaRep.OpenFile2('"C:\Sync\Projekte\LISS\SysML\Model2.eapx"', 1, 0) # Not opening!

#------------------------------------------------------------------------------------------------------------------


    except:
        print("failure opening file")
        sys.exit(2)

Title: Re: openfile2 eapx win32com python
Post by: qwerty on February 14, 2020, 10:22:37 pm
Can you open it "by hand"? EAPX requires Jet4 instead of Jet3.x for EAP files.

I usually access the running instance with the file already open and that works with no issu.

q.
Title: Re: openfile2 eapx win32com python
Post by: qwerty on February 14, 2020, 10:28:09 pm
I just tried that and had no issue opening a file that way.

Also
Code: [Select]
'"C:\Sync\Projekte\LISS\SysML\Model2.eapx"' looks fishy with that double quotation.

q.
Title: Re: openfile2 eapx win32com python
Post by: Geert Bellekens on February 14, 2020, 11:14:07 pm
as qwerty has noticed the extension is not the only difference between the one working and the one not working.
The not working one also has double quotes around the filename.

Code: [Select]
eaRep.OpenFile2('C:\Sync\TestStand\Python\easparx\Model1.eap', 1, 0) # Working perfectly!
 #eaRep.OpenFile2('"C:\Sync\Projekte\LISS\SysML\Model2.eapx"', 1, 0) # Not opening!

Geert
Title: Re: openfile2 eapx win32com python
Post by: kwasposer on February 14, 2020, 11:21:27 pm
Sorry, it works.

What a silly mistake. Thank you all, for this quick reply!!
Title: Re: openfile2 eapx win32com python
Post by: qwerty on February 14, 2020, 11:24:38 pm
We all know that: staring for hours onto some obvious bug without seeing it xD

q.