Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: asseco on August 10, 2011, 06:39:52 pm

Title: [EA Scripting] Note elem. on Logical Diagram issue
Post by: asseco on August 10, 2011, 06:39:52 pm
EA
I want to create Note element on logical diagram using JScript.

I tried:
Code: [Select]
var note as EA.DiagramObject;
note = dgmObjects.AddNew("l=20;t=20;b=40;r=200;", "Note");
note.Update();
but its not work.

There is no Note element on diagram.

After this I thought that maybe the Note was created but
is not visible in diagram and I tried
Code: [Select]
Repository.Execute("Update t_object SET Object_Type=\'Note\', Note =\'"+cls.ElementGUID+"\' WHERE Object_ID="+note.ElementID

but note.ElelmentID is 0.

Any sugestions.

Title: Re: [EA Scripting] Note elem. on Logical Diagram i
Post by: Aaron B on August 11, 2011, 09:15:00 am
A note is created much like a Class or any other element.  You need to create the EA.Element object first, then reference the Element using a new EA.DiagramObject.

For example:

Code: [Select]
var p as EA.Package;
var e as EA.Element;
var d as EA.Diagram;
var obj as EA.DiagramObject;

p = Repository.GetTreeSelectedPackage();
e = p.Elements.AddNew("", "Note");
e.Notes = "Hello World!";
e.Update();
d = Repository.GetCurrentDiagram();
obj = d.DiagramObjects.AddNew("", "");
obj.ElementID = e.ElementID;
obj.Update();
Repository.ReloadDiagram(d.DiagramID);
Title: Re: [EA Scripting] Note elem. on Logical Diagram i
Post by: asseco on August 18, 2011, 01:33:09 am
Thx for help.