Book a Demo

Author Topic: Add Diagram Notes element to diagram  (Read 6402 times)

coatie

  • EA User
  • **
  • Posts: 21
  • Karma: +0/-0
    • View Profile
Add Diagram Notes element to diagram
« on: December 23, 2014, 01:53:35 am »
Hello,

is it somehow possible to add the "Diagram Notes" element (the element showing author, created date, changed date and version) to a diagram using the automation interface?

I prefer using the "Diagram Notes" element instead of using the "ShowDetails" properties since the "Diagram Notes" are relocatable.

Best Regards,
Markus

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Add Diagram Notes element to diagram
« Reply #1 on: December 23, 2014, 02:35:56 am »
Try Diagram.ShowDetails. Setting it to 0 or 1 will turn the details off or on.

q.

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: Add Diagram Notes element to diagram
« Reply #2 on: December 23, 2014, 09:35:07 am »
Here is a simple JScript example which creates a new Diagram Note element and adds it to the current diagram:

Code: [Select]
!INC Local Scripts.EAConstants-JScript

function OnDiagramScript()
{
      // Get a reference to the current diagram
      var currentDiagram as EA.Diagram;
      currentDiagram = Repository.GetCurrentDiagram();

      var currentPackage as EA.Package;
      currentPackage = Repository.GetPackageByID( currentDiagram.PackageID );
      
      if ( currentDiagram != null )
      {
            var diagramNote as EA.Element;
            diagramNote = currentPackage.Elements.AddNew( "", "Text" );
            diagramNote.Subtype = 18;
            diagramNote.Update();
            
            var dobj as EA.DiagramObject;
            dobj = currentDiagram.DiagramObjects.AddNew( "", "" );
            dobj.ElementID = diagramNote.ElementID;
            dobj.Update();
            
            Repository.ReloadDiagram( currentDiagram.DiagramID );
      }
      else
      {
            Session.Prompt( "This script requires a diagram to be visible.", promptOK)
      }
}

OnDiagramScript();

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Add Diagram Notes element to diagram
« Reply #3 on: December 23, 2014, 09:58:30 am »
Oh. I mixed that up. The diagram details is fixed top left and has fewer information.

q.

coatie

  • EA User
  • **
  • Posts: 21
  • Karma: +0/-0
    • View Profile
Re: Add Diagram Notes element to diagram
« Reply #4 on: December 24, 2014, 05:19:30 am »
Thank you very much Aaron!

Any chance to also set the option "Scale to one page" for a diagram via the automation interface?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Add Diagram Notes element to diagram
« Reply #5 on: December 24, 2014, 09:48:03 am »
You need to check the string value of Diagram.ExtendedStyle and look for ScalePI=<flag>; where <flag> is either 0 or 1.

q.
« Last Edit: December 24, 2014, 09:48:57 am by qwerty »

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: Add Diagram Notes element to diagram
« Reply #6 on: December 24, 2014, 10:43:16 am »
Yep, what qwerty said.
ExtendedStyle contains a lot of different options in a semi-colon delimited string.  Make sure to check for any existing "ScalePI" value and careful not to lose any other settings when updating the string.