Book a Demo

Author Topic: Connecting to already running instance  (Read 6090 times)

ufechner

  • EA User
  • **
  • Posts: 85
  • Karma: +0/-0
  • I love YaBB 1 Gold!
    • View Profile
Connecting to already running instance
« on: May 04, 2007, 03:55:18 am »
Hallo,

I want to write a code generator in python.

> import win32com.client
> repo = win32com.client.Dispatch("EA.Repository")
> repo.OpenFile(sys.argv[1])
> elem = repo.getElementByID(int(argv[2]))
> print elem.name

I call the script using a custom tools menu entry,
so that the first parameter is the name of the model
file, and the second parameter the name of the selected
element.

It works, but it is very slow (10 seconds on an 1,7 Ghz PC).

How can I get an instance of the repository, that is
already open, without beeing forced to write an addin?

Regards:

Uwe Fechner
« Last Edit: May 04, 2007, 04:06:12 am by ufechner »

thomaskilian

  • Guest
Re: Connecting to already running instance
« Reply #1 on: May 04, 2007, 04:02:45 am »
Wasn't there something called GetObject (or the like) that you supply a file (the repository) which then returns the instance?

ufechner

  • EA User
  • **
  • Posts: 85
  • Karma: +0/-0
  • I love YaBB 1 Gold!
    • View Profile
Re: Connecting to already running instance
« Reply #2 on: May 04, 2007, 04:21:39 am »
Hello,

if I try:

> repo=GetObject("K:\\Bounce\\Doc\\PumpenTester.eap")

I get the exception: "invalid file extension".

Any idea?

Regards:

Uwe Fechner

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: Connecting to already running instance
« Reply #3 on: May 06, 2007, 02:51:25 pm »
Thomas was on the right track, but you need to retrieve the EA.App object using the GetObject call.  For more information, see the EA.App reference page below:
http://www.sparxsystems.com.au/EAUserGuide/app.htm

HTH.

ufechner

  • EA User
  • **
  • Posts: 85
  • Karma: +0/-0
  • I love YaBB 1 Gold!
    • View Profile
Re: Connecting to already running instance
« Reply #4 on: May 06, 2007, 10:59:34 pm »
Thanks for your help.

The following code works fine:

> from win32com.client import *
> app = GetObject(None,"EA.App")
> repo = app.Repository
> print app.ConnectionString
> elem = repo.getElementByID(int(argv[2]))
> print elem.name

One more question:

In the User Guide it is written, that the
repository object is readonly.

Does this mean, that this fast method to access
an already open EA model does not work, if you want to
update the model (e.g. adding comments to already
existing elements)?

Regards:

Uwe Fechner

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Connecting to already running instance
« Reply #5 on: May 07, 2007, 12:20:51 pm »
No, it means that you can't set the Repository object of App to a different Repository.

Note, that all of the Collections are documented as read only for the same reason.  You can't replace the collection with another collection.  You can however make modifications to the collection.