Enterprise Architect 脚本:为序列图设置连接器的 属性

Enterprise Architect scripting: set Connector's property for sequence diagram

我在两个元素之间创建了一条消息(序列连接器):

dim w_src as EA.Element
dim w_dst as EA.Element

set w_src = Repository.GetElementByGuid("{C90B3F33-D01D-48d9-A46A-BD32CA8AF20E}")
set w_dst = Repository.GetElementByGuid("{239814DD-D331-47dc-A198-F2C32E57471C}")

Session.Output "Src: " & w_src.Name
Session.Output "Dest: " & w_dst.Name

dim w_con as EA.Connector
set w_con = w_src.Connectors.AddNew("wocMessage", "Sequence")
w_con.SupplierID = w_dst.ElementID

w_con.Stereotype = "query"

if not w_con.Update then : Session.Output "Error:" & w_con.GetLastError : exit sub : end if

w_src.Connectors.Refresh

如何以编程方式设置连接器的附加属性(例如我对 Stereotype 所做的)?我要设置的属性是我可以在用户界面上看到的那些:

编辑: 感谢 Geert 的回答,此后完整代码以编程方式设置用户界面提供的所有参数(在 EA 10 上测试):

dim w_src as EA.Element
dim w_dst as EA.Element

set w_src = Repository.GetElementByGuid("{C90B3F33-D01D-48d9-A46A-BD32CA8AF20E}")
set w_dst = Repository.GetElementByGuid("{239814DD-D331-47dc-A198-F2C32E57471C}")

Session.Output "Src: " & w_src.Name
Session.Output "Dest: " & w_dst.Name

dim w_con as EA.Connector
set w_con = w_src.Connectors.AddNew("wocMessage", "Sequence")
w_con.SupplierID = w_dst.ElementID

w_con.Stereotype = "query"
w_con.StyleEx = "aliasparamsTO=int, string;paramvalues=5, theString;aliasparams=5, theString;alias=theAlias;"
w_con.Subtype = "" ' Lifecycle: "New" | "Delete" | ""
w_con.Notes = "This is a note"

if not w_con.Update then : Session.Output "Error:" & w_con.GetLastError : exit sub : end if

'w_con.MiscData(0) = "Asynchronous"
dim w_params : w_params = "'retval=unsigned int;params=5, theString;paramsDlg=5, theString;retatt=returnedValue;'"
dim w_condition : w_condition = "'theCondition'"
dim w_constraint : w_constraint = "'theConstraint'"
dim w_isIteration : w_isIteration = "'Iteration'" ' 'Iteration' | NULL
dim w_synch : w_synch = "'Synchronous'" ' 'Synchronous' | 'Asynchronous'
dim w_kind : w_kind = "'Call'" ' 'Call' | 'Signal'
dim w_isReturn : w_isReturn = 0 ' 1 | 0

Repository.Execute("update t_connector set PDATA1=" & w_synch _
    & ", PDATA2=" & w_params _
    & ", PDATA3=" & w_kind _
    & ", PDATA4=" & w_isReturn _
    & ", SourceCard=" & w_isIteration _
    & ", Btm_Mid_Label=" & w_condition _
    & ", SourceConstraint=" & w_constraint _
    & " where Connector_ID=" & w_con.ConnectorID)

w_src.Connectors.Refresh

Session.Output "[OK]"

您必须检查 t_connector 的列。 我知道生命周期放在子类型中,但其他参数可能存储在其他地方。

特别注意 PDATA* 和 Style* 列。它们通常包含此类信息。