【发布时间】:2019-11-09 18:14:42
【问题描述】:
我正在尝试使用 Python 将新连接器添加到 EA 模型。不幸的是,当我的脚本运行时,它没有添加连接器。通过 EA Javascript 控制台用 Javascript 编写的相同脚本能够添加连接器。
奇怪的是 Python 脚本不会失败。它的行为就像它添加了连接器。如果我刷新正在连接的元素,则连接器似乎在那里。我什至可以从 Python 控制台获取 ConnectorID。
Python:
from win32com.client import Dispatch
import os
ea = Dispatch("EA.App")
rep = ea.Repository
path = os.path.normpath("C:/temp/eaFile.eap")
e1 = rep.GetElementByID(121228)
e2 = rep.GetElementByID(120663)
newCon = e1.Connectors.AddNew("","Association")
newCon.ClientID = e1.ElementID
newCon.SupplierID = e2.ElementID
newCon.Update()
JAVASCRIPT:
e1 = Repository.GetElementByID(121228);
e2 = Repository.GetElementByID(120663);
newCon = e1.Connectors.AddNew("", "Association");
newCon.ClientID = e1.ElementID;
newCon.SupplierID = e2.ElementID;
newCon.Update();
我希望连接器在 Enterprise Architect 中作为元素上的链接可见 - 从 Python 运行时我无法找到它,但从 Javascript 运行时我能够找到它。
【问题讨论】:
标签: javascript python enterprise-architect