Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: st33ve 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
-
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.
-
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.
-
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
-
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.