Book a Demo

Author Topic: Adding a matrix to a diagram using scripting  (Read 5325 times)

Jayson

  • EA User
  • **
  • Posts: 363
  • Karma: +1/-0
    • View Profile
Adding a matrix to a diagram using scripting
« on: August 14, 2014, 08:08:15 am »
Hi all

I am using version 9.3 to create new diagrams.
As part of this I would like to add a matrix to the diagram much the same way as you can do from the "Swim Lanes & Matrix" context menu.

However, there seems to be no documentation on how to do this.

I thought perhaps you do it by manipulating swimlanes, but I can't for the life of me figure out how you might do this as the documentation on swimlanes in the "Automation" section is quite light.

Any help is appreciated.

Cheers

Jays  :)

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Adding a matrix to a diagram using scripting
« Reply #1 on: August 14, 2014, 06:48:46 pm »
Try this:
Diagram context menu:Swimlanes and Matrix
Type: Row
Title1: something
Save
New
-> repeat from Title for all rows
Type: Column
Repeat from Title for all columns

A bit clumsy this dialog, But I guess you'll figure it out.

q.

Jayson

  • EA User
  • **
  • Posts: 363
  • Karma: +1/-0
    • View Profile
Re: Adding a matrix to a diagram using scripting
« Reply #2 on: August 15, 2014, 03:45:16 am »
Hey q

Thanks for that.
However, I am trying to add the matrix to the diagram from within my script.
Any clues on how to do that as I cannot find any mention of a matrix object within the object reference material.

Cheers

Jays :)

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Adding a matrix to a diagram using scripting
« Reply #3 on: August 15, 2014, 06:06:02 am »
Ah. Would have been a bit more obvious if you had posted in the automation forum.

Now, they store it in t_diagram.PDATA. Sort of
Code: [Select]
PDATA;

HideRel=0;ShowTags=0;ShowReqs=0;ShowCons=0;OpParams=1;ShowSN=0;ScalePI=0;PPgs.cx=1;PPgs.cy=1;PSize=1;ShowIcons=1;SuppCN=0;HideProps=0;HideParents=0;UseAlias=0;HideAtts=0;HideOps=0;HideStereo=0;HideEStereo=0;FormName=;;
You need to create different matrices manually and see how that column changes. Bit of work, but probably feasible. Don't forget to save the diagram after each matrix change or your query will still see the old state.

Note that only a few of the above are actually meant for the matrix/swim lane. The others are created to represent other defaults, but only when you define a matrix (or change one of the defaults). PDATA for normal diagrams is empty per default.

q.
« Last Edit: August 15, 2014, 06:08:02 am by qwerty »

Jayson

  • EA User
  • **
  • Posts: 363
  • Karma: +1/-0
    • View Profile
Re: Adding a matrix to a diagram using scripting
« Reply #4 on: August 15, 2014, 08:55:25 am »
Hey Q

Looked there.
In StyleEx there are attributes such as MatrixActive = 1 and MatrixLocked=0

But there doesn't seem to be anything describing the individual columns, rows and headers of the matrix.

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Adding a matrix to a diagram using scripting
« Reply #5 on: August 15, 2014, 09:06:48 am »
It's in t_xref, where t_xref.Type='matrixitem', but a quick glance tells me it's very complex and I have no idea what any of it means. You might be better creating by hand a diagram with a matrix and then cloning it somehow in your script.
The Sparx Team
[email protected]

Jayson

  • EA User
  • **
  • Posts: 363
  • Karma: +1/-0
    • View Profile
Re: Adding a matrix to a diagram using scripting
« Reply #6 on: August 15, 2014, 09:17:15 am »
Cheers, I will look at that.
Alternatively I have been looking at using a boundary element and creating a matrix by specifying both horizontal and vertical swimlanes.

However, I can't see where I can set the column and row sizes programmatically. Or are they always equispaced?

Jays  :)

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Adding a matrix to a diagram using scripting
« Reply #7 on: August 15, 2014, 06:44:15 pm »
The t_xref entries are created per column. The data are comma separated the title,colot, font, etc parameters and finally the width. Pretty much straight forward. If you happen to place a comma in the title it is replaced by @&coma& and if you try to place that text in the title EA will directly revert it to a comma.  ::) (I guess the test fell into a coma when seeing this)

Each row/col is identified by the keyword "Row"/"Column" as the first of the comma separated words.

It's probably not difficult to create a matrix programmatically this way.

Anyhow, a way through the API would be preferred...

q.
« Last Edit: August 15, 2014, 06:45:32 pm by qwerty »