从javascript Enterpreise Architect添加属性说明

时间:2017-08-31 13:43:18

标签: enterprise-architect

我有一些代码,我想创建Property Note

 var metric as EA.Element;
 metric = thePackage.Elements.AddNew("", "Text");

我应该用什么而不是Text来添加我想要的东西?

我试过了:

 metric = thePackage.Elements.AddNew(text, "Property Note");

 metric = thePackage.Elements.AddNew(text, "PropertyNote");

修改

 metric = thePackage.Elements.AddNew(text, "Note");

不起作用:

我期待

enter image description here 在红色框中,而不是它上面的element

答案:

 metric = thePackage.Elements.AddNew("", "Text"); // the Note Property
 metric.SubType = 18; // This will actually make a simple Text behave as Note Property

1 个答案:

答案 0 :(得分:2)

正如这里所承诺的那样,创建图表注释的代码。很抱歉Perl,但您可能会将其翻译为Javascript。

my $p = $rep->GetPackageByGUID("{157B01A5-8F9A-4458-8C7F-E48F5DA77B0A}"); # sample package
my $dnote = $p->Elements->AddNew("", "Text"); # the Note Property
$dnote->{SubType} = 18; # This will actually make a simple Text behave as Note Property
$dnote->Update(); # save in package elements
my $dia = $p->Diagrams->GetAt(0); # sample diagram
my $do = $dia->DiagramObjects->AddNew("l=10;r=110;t=-20;b=-80", ""); # place Note Property in diagram (coordinates are about top left)
$do->{ElementID} = $dnote->ElementID; # link with the Note Property
$do->Update(); # place in diagram
$rep->ReloadDiagram($dia->DiagramID); # make ir appear instantly