Book a Demo

Author Topic: saving a diagram as a jpg-image via API / autom.  (Read 3779 times)

iMikel

  • EA Novice
  • *
  • Posts: 14
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
saving a diagram as a jpg-image via API / autom.
« on: March 17, 2008, 07:17:34 am »
Hello to all of you!

The EA user interface provides the ability to save a diagram as a jpg-image-file (or other picture format).

Is this scriptable? So is there any way to automate via API / automation interface?

Greetings

Mikel


«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: saving a diagram as a jpg-image via API / auto
« Reply #1 on: March 17, 2008, 08:10:46 am »
Yes Mikel,

You can save a diagram to a file with the Project.SaveDiagramImageToFile. AFAIK this will save the diagram in the file type set in Tools | Options. [I could be wrong, it might attempt to figure out the correct graphics type from the file extension.] This method works only with the current diagram, so you need to have one open (whether or not EA is visible). This can be a limitation, so see below.

There is another method that appears to be newer and smarter. Project.PutDiagramImageToFile does know about other file types, including JPG, and knows enough to check the extension - if you ask it to - before deciding on the output format.

You can also put diagrams in the clipboard. In this case you might only get the choice of bitmap and metafile formats. You use the Project.PutDiagramImageOnClipboard. The file type parameter is not documented correctly, so you have to play with it a bit. [HINT: passing a value of 0 almost always works. I think that forced a metafile, while a value of 1 might tell EA to choose what you've set in Tools | Options.]

HTH, David

EDIT: Documentation bug reported.
« Last Edit: March 17, 2008, 08:13:47 am by Midnight »
No, you can't have it!