Author Topic: How do I set Diagram Properties using VB Script?  (Read 9424 times)

Gayle

  • EA User
  • **
  • Posts: 37
  • Karma: +1/-0
    • View Profile
How do I set Diagram Properties using VB Script?
« on: April 14, 2016, 04:46:43 am »
I'm using EA 12.1.1229 and Visual Basic to write scripts.  The most recent script has generated diagrams and partially populated the diagrams.  For the Sequence Diagrams, I would like to set the "Show Parameter Detail" property under "Features".  The default is "Type Only" and I would like it to be "Full Details".

I created a pair of test diagrams - one with "Type Only" and the other with "Full Details".  When I do an XML export, the only field that appears to be changed is the "SuppressFOC" which is under the extended styles.  I could not access this value using the ExtendedStyle or StyleEx diagram class attributes.

I think that the ReadStyle and WriteStyle Methods could be used to read and write the style information.  However, none of my attempts to use these operations have resulted in updating the "Show Parameter Detail" to be "Full Details".  I could not find an example using these Methods, so I'm probably misunderstanding the information in the EA User Manual on how to format the operations.

I'm guessing that I'm missing something with respect to how to modify the diagram properties.  I found the "HighlightImports" to change the "Show Namespace" setting, but this "Show Parameter Detail" value does not appear to be as easy to modify.  Any ideas would be appreciated.

Thank you, Gayle

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: How do I set Diagram Properties using VB Script?
« Reply #1 on: April 14, 2016, 08:04:41 am »
Look out for OpParams in t_diagram.pdata (see also p. 49 in my Inside book).

q.

Helmut Ortmann

  • EA User
  • **
  • Posts: 967
  • Karma: +42/-1
    • View Profile
Re: How do I set Diagram Properties using VB Script?
« Reply #2 on: April 14, 2016, 02:55:54 pm »
Hi Gayle,

in a case like yours I usually:
- Make an example model with just the problem at hand (two diagrams)
- With SQL Query (EA SQL Scratch Patch) I look for differences
  (t_diagrams, t_xref, ..)
- Than I go into documentation (EA and qwerties book)
- Mostly I can use an existing EA API property and have to ascertain the content I need
- Sometimes I need to use SQL to update / insert the content (be careful with this)
- Sometimes you have to look into t_xref (here you often have to look for GUIDs to find the element(s) it's connected to)

Helmut
Coaching, Training, Workshop (Addins: hoTools, Search&Replace, LineStyle)

Gayle

  • EA User
  • **
  • Posts: 37
  • Karma: +1/-0
    • View Profile
Re: How do I set Diagram Properties using VB Script?
« Reply #3 on: April 15, 2016, 03:26:46 am »
I'm executing the script to create diagrams in a small test model.  To try and get the data associated with the PDATA statement, I created a small script to collect the data via SQL queries from the diagram that I have selected in the browser (I included diagram type and PDATA).  When I get PDATA for the diagrams created by the script, PDATA is blank.  I used diagram and package updates in the script, and the model (.eap file) has been closed and reopened at least twice since the diagrams were created.  Is there some kind of operation I need to perform on the diagrams once created to be able to retrieve PDATA and other values via SQL queries?

I was hoping to read PDATA and use it to make the update to the diagram properties.  For the update, do I replace the entire string that is read, or can I just update the "OpParams" field?

Gayle

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: How do I set Diagram Properties using VB Script?
« Reply #4 on: April 15, 2016, 05:41:33 am »
You must be doing something wrong. Run
Code: [Select]
select * from t_diagramin the SQL Scratch Pad and you will see that PDATA is not blank.

q.

Gayle

  • EA User
  • **
  • Posts: 37
  • Karma: +1/-0
    • View Profile
Re: How do I set Diagram Properties using VB Script?
« Reply #5 on: April 15, 2016, 08:27:31 am »
I am certain that I have missed something, however, I've never used the SQL Scratch Pad and don't know how to set my model up to use it.  The model is an eap file and the repository type is JET.

My logic in the script is relatively simple.  I ask the user for a UseCase name, create packages, diagrams and elements. The following is an example of how I have created a diagram:

   set newSD = currentPackage.Diagrams.AddNew(diagramName + " SD", "Sequence")
   newSD.Update()
   currentPackage.Update()

where "currentPackage" is the location that I want the diagram to go in and "diagramName" is the UseCase name that the user entered. 

I followed this with the SQLQuery:

   temp = Repository.SQLQuery ("SELECT PDATA FROM t_diagram WHERE Diagram_ID = " & newSD.DiagramID)
   Session.Output ("Diagram data - PDATA = " & temp)

The raw XML data that resulted from this query captured from the System Output window is:
   
Diagram data - PDATA = <?xml version="1.0"?>
<EADATA version="1.0" exporter="Enterprise Architect">
<Dataset_0><Data><Row><PDATA/></Row></Data></Dataset_0></EADATA>
   
Any ideas what I'm missing?

Gayle

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: How do I set Diagram Properties using VB Script?
« Reply #6 on: April 15, 2016, 08:36:20 am »
Ah. Maybe if you create it via automation the PDATA is empty.

Just do following for the scratch pad: CTRL-F, Click the Paper-Pencil icon on top (left of the large X). Now you have the scratch pad. It allows to enter most SQL directly (SELECT only and with few restrictions). So type the above query just here and inspect the PDATA of existing diagrams. You need to create a similar entry with OpParams=1; or the like. Alter diagram options and compare what changes in the respective PDATA.

q.

Gayle

  • EA User
  • **
  • Posts: 37
  • Karma: +1/-0
    • View Profile
Re: How do I set Diagram Properties using VB Script?
« Reply #7 on: April 15, 2016, 08:54:49 am »
I was looking for the SQL Scratch Pad elsewhere in the tools and missed it under find.  When I used it, I did confirm that diagrams created with the script have no PDATA.  I just discovered that I can open the diagram, save the diagram and close the diagram before doing the SQL query and PDATA is populated.

Now to try and change the diagram properties!!

Thank you for the help.

Gayle

Gayle

  • EA User
  • **
  • Posts: 37
  • Karma: +1/-0
    • View Profile
Re: How do I set Diagram Properties using VB Script? - SOLVED
« Reply #8 on: April 16, 2016, 06:42:51 am »
I now have the logic capturing the PDATA, parsing the string to insert "OpParams=2", concatenating the string back together and performing a "Repository.Execute" on the "Update" SQL statement.  The diagram now has the "Show Parameter Details" set to "Full Details".

Thank you all for your help.

Gayle