C#开发Enterprise Architect插件:PropertyFlow方向更新失败求助
解决Enterprise Architect中PropertyFlow方向更新失败的问题
核心问题分析
你错误地将PropertyFlow的方向当成了普通TaggedValue来处理——实际上EA中PropertyFlow的direction(in/out/inout)是存储在Element对象的**Direction属性**中,而非t_objectproperties表或TaggedValue集合里,这就是你之前两种方法都无效的原因。
正确的C#代码实现
直接修改Element的Direction属性后再调用Update()即可:
// 调用示例 UpdateFlowPropertyDirection(element, "in"); public void UpdateFlowPropertyDirection(Element flowProperty, string newDirection) { // 确保目标Element是PropertyFlow类型 if (flowProperty.Type == "PropertyFlow") { flowProperty.Direction = newDirection; flowProperty.Update(); // 可选:刷新EA界面显示 Repository.RefreshModelView(flowProperty.PackageID); } }
正确的SQL语句(若需直接操作数据库)
如果要通过SQL修改,需要更新t_object表的Direction字段,而非t_objectproperties:
UPDATE t_object SET Direction = 'in' WHERE Object_ID = 23573 AND Object_Type = 'PropertyFlow'; -- 增加类型过滤避免误改
关于你提到的EARepos.Execute()
如果确实需要用Repository.Execute执行SQL,直接运行上面的正确SQL语句即可,但优先推荐使用EA的API(即修改Element.Direction的方式),因为API会处理EA内部的缓存和一致性校验,减少出错概率。
补充:若操作普通TaggedValue的注意点(非本次场景)
如果以后需要修改真正的TaggedValue,除了设置tagValue.Value,还需要单独调用tagValue.Update(),仅调用element.Update()不会同步TaggedValue的修改——不过本次问题不涉及这个场景。
内容的提问来源于stack exchange,提问作者Ice
相关产品推荐
相关产品推荐

