Author Topic: [EA Scripting] Note elem. on Logical Diagram issue  (Read 3190 times)

asseco

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
[EA Scripting] Note elem. on Logical Diagram issue
« 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.


Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: [EA Scripting] Note elem. on Logical Diagram i
« Reply #1 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);

asseco

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: [EA Scripting] Note elem. on Logical Diagram i
« Reply #2 on: August 18, 2011, 01:33:09 am »
Thx for help.