Book a Demo

Author Topic: open an external file  (Read 4476 times)

pr1smiley

  • EA User
  • **
  • Posts: 33
  • Karma: +0/-0
  • EOD is a Blast!
    • View Profile
open an external file
« on: February 11, 2008, 08:44:07 am »
Hello All,

I am currently writing an automation Add-in and i would like for the add-in to open a file dialog and be able to choose a file(XML) for reading.

Anyone have a project that opens an external file for reading values into a package programatically?

Any help would be greatly appreciated

Thanks  

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: open an external file
« Reply #1 on: February 11, 2008, 08:53:30 am »
When you say "reading values into a package" do you mean importing a model package, much as you would from the EA main menu?

If so, look at the ImportPackageXMI and ExportPackageXMI methods of the Project interface of the API.

If not, but something similar, read through the rest of the methods in the Project interface. Perhaps one of them addresses your requirement.

HTH, David
No, you can't have it!

pr1smiley

  • EA User
  • **
  • Posts: 33
  • Karma: +0/-0
  • EOD is a Blast!
    • View Profile
Re: open an external file
« Reply #2 on: February 11, 2008, 09:31:29 am »
David,

Actually i would like to open an XML file , read its contents via Linq2xml and programatically create packages,diagrams,elements etc. based on the XML file contents

using C# VS2008

Thanks

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: open an external file
« Reply #3 on: February 11, 2008, 09:46:10 am »
All of which complete sense. Except...

I just don't see the problem. You seem to have all the right tools at hand. You've got VS 2008, so you should be able to open and manipulate files, and you've got a first-class XML engine. All you need to do is read and parse your XML file, then create the appropriate elements in your EA model.

If you are using LINQ you might even be able to use XQuery to get some extra horsepower in the parsing process. [You'll need to check into that yourself.]

What am I missing?

David
No, you can't have it!

pr1smiley

  • EA User
  • **
  • Posts: 33
  • Karma: +0/-0
  • EOD is a Blast!
    • View Profile
Re: open an external file
« Reply #4 on: February 11, 2008, 10:01:31 am »
David,

The problem is I'm using a OpenFileDialog in my add-in to show a Modal file open dialog in EA , however it will not show in the EA interface so i can choose which XML file to read.

Thanks

pr1smiley

  • EA User
  • **
  • Posts: 33
  • Karma: +0/-0
  • EOD is a Blast!
    • View Profile
Re: open an external file
« Reply #5 on: February 11, 2008, 10:56:09 am »
David,

I fixed it, Thanks for your time spent with me

Dana

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: open an external file
« Reply #6 on: February 11, 2008, 10:58:19 am »
I think I see what you mean. You need something running from 'inside' EA to bring up an OpenFileDialog.

My (completely uneducated) guess is that you want this to occur in response to some action the user takes, or at some point in a process mediated by your add-in. The problem now becomes one of somehow calling your code at the correct moment, so you can provide the dialog and consume the result.

My best guess is that you are going to have to trap some kind of event. There are only a few of these, unless you create an MDG add-in. The MDG interface significantly extends the number of events you can react to. It requires you to provide stubs for all events, but using VS 2008 all you need to do is inherit the top-level interface and the stubs are created for you. While these things were originally expected to extend the code generation capabilities of EA, they turn out to have all kinds of nifty uses.

You might have to do some rethinking of your scenario - you can always write a use case in EA - to make sure an appropriate event is available, and that your users cause it to be fired, but that's only a design problem.

So, read up on that model. You'll find it after the section on the EA object model in the help file.

David
No, you can't have it!