Book a Demo

Author Topic: Scripting to change Diagram Properties  (Read 4332 times)

isaacjoh

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Scripting to change Diagram Properties
« on: July 09, 2015, 07:02:01 am »
Hi all, I'm trying to change the Diagram Property "Show Additional Parents" via JScript. The reason for this is that it's very tedious to go into each diagram and either check/uncheck this box. I'm trying to automate this and just run it for a package with numerous diagrams, looping through each and either checking/unchecking the box automatically.

I looked at the EaDiagram.WriteStyle and EaDiagram.ReadStyle options but I have found that they only work for the diagram property "Show Connector Property String" and "Show Element Property String". I assumed the WriteStyle function could be used for any of the diagram properties but that is not the case I guess. Any help would be much appreciated, thank you in advance!!

isaacjoh

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Scripting to change Diagram Properties
« Reply #1 on: July 09, 2015, 08:30:53 am »
Thanks for the quick reply Qwerty! So you're saying if I add it to the StyleEx column, it'll work? Right now I see HideParents=1 or HideParents=0 in the PDATA column but StyleEx has a bunch of other stuff.

The question I have is whether you meant PDATA. If you did, there's no way to access PDATA in EaDiagram unfortunately. If you say it'll still work if I add HideParents=1 to the StyleEx, that'll be great because I can access StyleEx.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Scripting to change Diagram Properties
« Reply #2 on: July 09, 2015, 08:33:09 am »
I was too fast with my reply (and you with reading). StyleEx does not seem to work, but modifying PDATA with HideParents=1;

See also p. 46 of my Inside EA book.

I'm cross checking currently.

q.
« Last Edit: July 09, 2015, 08:36:51 am by qwerty »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Scripting to change Diagram Properties
« Reply #3 on: July 09, 2015, 08:35:49 am »
You can modify PDATA by using
Code: [Select]
Repository.Execute ("UPDATE t_diagram SET PATA='...' WHERE ...")
This is an undocumented/unsupported function but it works and is widely used to do things like this. Of course you don't get support from Sparx when using it.

q.
« Last Edit: July 09, 2015, 08:36:07 am by qwerty »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Scripting to change Diagram Properties
« Reply #4 on: July 09, 2015, 08:44:31 am »
So it seems I got it. There is an ExtendedStyle property for the diagram object which you can access from the API (this must have been introduced in a later EA version). You can check this to contain the HideParents attribute and change the assignment or add it if it's not present.

q.

isaacjoh

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Scripting to change Diagram Properties
« Reply #5 on: July 09, 2015, 08:48:29 am »
Perfect!! That's exactly what I need. It should be a simple change from here. Thank you so much, I really appreciate it!!