2017-08-31 75 views
3

添加屬性記我有一些代碼,我想創建Property Note從JavaScript Enterpreise建築師

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 
+0

你想要一個音符元素或元素的音符屬性? – Mart10

+1

@ Mart10我想從代碼中加入[this](http://www.sparxsystems.com/enterprise_architect_user_guide/12/modeling_basics/addpropertiesnote.html) – yami

+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 
+0

缺少'metric.SubType = 18;'部分 - 很酷。謝謝 – yami