如何通过Enterprise Architect API打开Image Manager [英] How to open Image manager through Enterprise Architect API

查看:138
本文介绍了如何通过Enterprise Architect API打开Image Manager的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过C#插件开发Enterprise Architect。我需要通过自动化显示图像管理器,用户可以直接添加图像在添加图像按钮上单击形式。

I am working on Enterprise Architect through C# add-ins. I need to display the image manager through automation where user can add directly add images on an "add image" button click in form.

我使用API​​ Repository.InvokeConstructPicker()但它只打开选择包/类/组件窗口。是否有EA API可用于打开图像管理器。

I use the API Repository.InvokeConstructPicker() but it only opens the select package/class/component window. Is there an EA API available to open the Image Manager.

推荐答案

不,没有。有未记录的 Respository.CustomCommand ,它可以打开几个属性窗口。但图像管理器不是其中的一部分(或者尚未发现要提供的参数)。

No, there is none. There is the undocumented Respository.CustomCommand which can open several properties windows. But the image manager is not part of that (or it has not been discovered what parameters to supply).

请参阅下面的Edit2关于向表中添加新值。

Please see Edit2 below about adding new values to the table.

编辑:根据另一个问题,我不得不深入研究这个问题。

Edit: Based on another question I had to dig into this a bit deeper.

我发现虽然EA导入了许多不同的图像格式,但它在内部使用PNG来存储图像。显然他们的BMP导入器不喜欢所有BMP格式(不是那么深,但我似乎记得有一些8/16位的东西;典型的Windoze怪异)。无论如何,我使用这个Python代码片段来检索以前导入EA的一些测试图像数据:

I found out that, although EA imports a number of different image formats, it internally uses PNG to store the image. Obviously their BMP-importer does not like all BMP formats (not so deep in that, but I seem to remember there's some 8/16 bit stuff; typical Windoze weirdness). Anyhow, I used this Python code snippet to retrieve some test image data, previously imported into EA:

import sys
import win32com.client
import base64
import xml.etree.ElementTree

eaRep = None
try:
    eaApp = win32com.client.GetActiveObject(Class="EA.App")
    eaRep = eaApp.repository
except:
    print "failure to open EA"
    sys.exit(2)

def dump():
    sqlRes = eaRep.SQLQuery("SELECT * FROM t_image")
    root = xml.etree.ElementTree.fromstring(sqlRes)
    for dataset in root:
        for data in dataset:
            for row in data:
                name = row[1].text
                print name
                data = row[3].text
                png = base64.standard_b64decode(data)
                file = open("c:/" + name + ".png", "wb")
                file.write(png)
                file.close()

dump()

这正确地从数据库中提取了图像。

This correctly extracted the images from the database.

Edit2 :我假设EA将png存储为base64,但事实并非如此。 EA仅在返回 SQLQuery 时提供base64。但是他们在内部只是将原始png存储在 Image 中。所以,遗憾的是,你不能使用 Repository.Execute ,因为它无法传输二进制数据 - 或者至少我还没弄清楚如何做到这一点。作为解决方法,您可以查看 Repository.ConnectionString 并打开与数据库的本机连接。在表格中插入新图片后,您可以通过 ImageID 使用它们。

Edit2: I was assuming that EA stores the png as base64, but that's not true. EA only delivers base64 on return of SQLQuery. But they internally just store the raw png in Image. So, unfortunately, you can not use Repository.Execute since it can not transport binary data - or at least I have not figured out how to do that. As a work around you can look into Repository.ConnectionString and open a native connection to the database. Once you have plugged the new picture(s) in the table you can use them via thier ImageID.

t_image的内容


  • ImageID :您只需创建一个唯一ID

  • 名称:任意字符串

  • 输入:固定字符串位图

  • 图片:png的blob

  • ImageID : You just need to create an unique ID
  • Name : an arbitrary string
  • Type : fixed string Bitmap
  • Image : blob of a png

这是一个Python代码段,本地连接到EAP文件:

Here's a Python snippet that connects natively to an EAP file:

import pyodbc
db_file = r'''C:\Documents and Settings\Administrator\Desktop\empty.eap'''

odbc_conn_str = 'DRIVER={Microsoft Access Driver (*.mdb)};DBQ=' + db_file
conn = pyodbc.connect(odbc_conn_str)
cursor = conn.cursor()
cursor.execute("select * from t_image")
row = cursor.fetchone()
if row:
    print(row)

而不是打印带有图像数据的行(表明它的行内容是一个png-blob)您可以使用它实际发出 INSERT UPDATE 修改 t_image

Rather than printing the row with the image data (which shows that its contents is a png-blob) you can use it to actually issue an INSERT or UPDATE to modify t_image.

这篇关于如何通过Enterprise Architect API打开Image Manager的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆