Book a Demo

Author Topic: openfile2 eapx win32com python  (Read 5198 times)

kwasposer

  • EA User
  • **
  • Posts: 91
  • Karma: +1/-0
    • View Profile
openfile2 eapx win32com python
« 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)


qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: openfile2 eapx win32com python
« Reply #1 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.
« Last Edit: February 14, 2020, 10:25:25 pm by qwerty »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: openfile2 eapx win32com python
« Reply #2 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.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: openfile2 eapx win32com python
« Reply #3 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

kwasposer

  • EA User
  • **
  • Posts: 91
  • Karma: +1/-0
    • View Profile
Re: openfile2 eapx win32com python
« Reply #4 on: February 14, 2020, 11:21:27 pm »
Sorry, it works.

What a silly mistake. Thank you all, for this quick reply!!

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: openfile2 eapx win32com python
« Reply #5 on: February 14, 2020, 11:24:38 pm »
We all know that: staring for hours onto some obvious bug without seeing it xD

q.