Book a Demo

Author Topic: How to grab a diagram image from a SQL query  (Read 10592 times)

jplusip

  • EA User
  • **
  • Posts: 69
  • Karma: +0/-0
    • View Profile
How to grab a diagram image from a SQL query
« on: October 27, 2015, 04:26:07 am »
Using a SQL query, how do I pull the image of a diagram out? Looking at the tables in Inside EA, I'm not seeing anything for the actual diagram image.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to grab a diagram image from a SQL query
« Reply #1 on: October 27, 2015, 04:39:14 am »
You can't. It isn't stored in the database.

What you can do is use Project Interface.PutDiagramImageOnClipboard() or Project Interface.PutDiagramImageToFile() to get a hold of the diagram image.

Geert

jplusip

  • EA User
  • **
  • Posts: 69
  • Karma: +0/-0
    • View Profile
Re: How to grab a diagram image from a SQL query
« Reply #2 on: October 27, 2015, 06:40:12 am »
Hmmm... so is there a way outside of using scripts to grab particular diagrams and place them in particular parts of an autogenerated document?

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: How to grab a diagram image from a SQL query
« Reply #3 on: October 27, 2015, 08:38:07 am »
By saving the images to the file system when you're creating them? The images aren't stored statically by EA, so you either need EA to generate them or have already saved them.

Technically, using EA's document generator would fulfill what you've asked for. Maybe you should clarify what you're actually trying to do.

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: How to grab a diagram image from a SQL query
« Reply #4 on: October 27, 2015, 07:46:18 pm »
Hello,


"Outside of using scripts": well, you can write an Add-In, which executes within the EA client, or an external program (in Java or COM/.NET) which interacts with an EA project through the API. But there are no diagram images stored in the database so there's nothing to be grabbed by SQL.

You can create images using the API calls Geert suggested; you can also look at Diagram.SaveAsPDF() and Diagram.SaveImagePage().

If you're asking whether you can insert an image "here" when using the DocumentGenerator class, the answer is no. DocumentGenerator allows you to insert text strings and page/section breaks, but everything else is done using RTF templates.

Cheers,


/Uffe
My theories are always correct, just apply them to the right reality.

jplusip

  • EA User
  • **
  • Posts: 69
  • Karma: +0/-0
    • View Profile
Re: How to grab a diagram image from a SQL query
« Reply #5 on: October 28, 2015, 01:42:07 am »
Quote
By saving the images to the file system when you're creating them? The images aren't stored statically by EA, so you either need EA to generate them or have already saved them.

Technically, using EA's document generator would fulfill what you've asked for. Maybe you should clarify what you're actually trying to do.

So, to clarify, in generating a document, I only want to pull say, four specific diagrams and, ideally, the report generation will be run off of the root package to grab elements dispersed throughout the model.

If I use the document template editor GUI (that is, I don't use any custom queries), it will just grab every diagram it comes across and throw them in sequentially. But that's not what I'm looking for, I just want four diagrams and I want them placed in very specific spots.

Unfortunately, using a custom script may not be an option on this particular project (at least, that's what a couple of my supervisor's are saying; hopefully that isn't the case since I think I have a decent idea of how to do this off of Geert's response).

So basically, what I'm understanding for the replies is:
Without using outside scripting and being limited to selectors and SQL queries, it isn't possible to grab a specific subset of diagrams and place them in specific places automatically.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to grab a diagram image from a SQL query
« Reply #6 on: October 28, 2015, 03:34:52 am »
Actually it is possible without writing any scripts if you use Virtual Documents.

You can create one «master document» package and create a «model document» for each of the diagram you want to show in your document.

The selection for the content of the model documents can either be a package, or a model search.

I often use a model search that returns a single element based on its GUID as the source of my model documents.

This works best if you only have one diagram under the element or package you use as source of a model document. That avoids having to use filters in the template.

Geert

PS. Often it is more efficient to tell us your goal i.s.o. asking for a specific solution. Here you were asking how to move the mountain, whereas you only needed some way to get to the other side. If you had told me all you needed was to get on the other side I would have never tried to explain ways to move the mountain.  :)
« Last Edit: October 28, 2015, 03:39:16 am by Geert.Bellekens »

jplusip

  • EA User
  • **
  • Posts: 69
  • Karma: +0/-0
    • View Profile
Re: How to grab a diagram image from a SQL query
« Reply #7 on: October 30, 2015, 04:31:39 am »
Thanks for the heads up. I actually did not know about the virtual documents at all, and they are definitely making life a lot easier! (granted, I'm still glad to know how to do this stuff using SQL queries and scripts).

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to grab a diagram image from a SQL query
« Reply #8 on: October 30, 2015, 04:07:52 pm »
For added bonuspoints:
You can write a script that automatically creates the virtual document based on the selected elements, or diagram, or whatever.

Geert

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to grab a diagram image from a SQL query
« Reply #9 on: November 12, 2015, 07:56:04 pm »
For those interested int the scripting part, I wrote an article about my approach to document generation in EA: Tutorial: Generate complex documents from Enterprise Architect with a two-step semi-automated approach complete with an example model, working templates, scripts and searches.

Geert