Author Topic: Put image file to diagram  (Read 4259 times)

st33ve

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Put image file to diagram
« on: June 20, 2014, 08:27:31 pm »
Can I place an image to diagram via automation API? I have an EMF file that I want to be displayed in a diagram. I suppose that I need to interact with image manager, but I don't know how.

Thanks

Stepan

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Put image file to diagram
« Reply #1 on: June 21, 2014, 10:55:03 pm »
Unfortunately there is no direct handling via the API. You need to to the following:
  • Place the image in the t_image table. Choose a random imageID and name, use "Bitmap" as type and place the binary content in Image. Use Repository.Execute ("INSERT INTO t_image...") to actually place the picture. You could also use import reference data from the project interface to get it into EA, but that's not really much easier.
  • Create a boundary element.
  • Place that on the diagram (i.e. create a diagram object)
  • Set ObjectStyle the the diagram object to "ImageID=<id>;" where <id> is that of the image in t_image
  • You're done - sort of :D

q.

st33ve

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: Put image file to diagram
« Reply #2 on: June 23, 2014, 08:54:37 pm »
Hi,

thank you. One last thing - there is no Repository.Execute. Did you mean Repository.SQLQuery? Unfortunatelly, the method does not allow query parameters, only SQL string. Therefore, there is problem with binary data encoding. I want to avoid database specific code, but it is probably impossible.

S.

Stefan Bolleininger

  • EA User
  • **
  • Posts: 308
  • Karma: +0/-0
    • View Profile
Re: Put image file to diagram
« Reply #3 on: June 23, 2014, 09:19:50 pm »
Hi Stepan,

Repository.Execute is an "unsupported" command. It can be used for updating the SQL-tables. As it is unsupported, it is not declared within the documentation. Within the forum you may find many topics related to the function of this command.

Best regards

Stefan
Stefan
Enterprise Architect in "safetycritical development" like medical device industry. My free Add-in at my Website

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Put image file to diagram
« Reply #4 on: June 24, 2014, 01:12:37 am »
To circumvent the parameter issue I used native access to the database (or at least ODBC). Since I'm used to Perl there are libraries which allow to supply parameterized queries. The connection string can be retrieved via Repository.ConnectionString();

q.