Book a Demo

Author Topic: Setting Diagram and Diagram Object Attributes  (Read 4977 times)

fwoolz

  • EA User
  • **
  • Posts: 435
  • Karma: +0/-0
  • We have met the enemy, and he is us.<Pogo, 1970>
    • View Profile
Setting Diagram and Diagram Object Attributes
« on: August 04, 2011, 09:12:35 am »
One shortcoming of the automation interface (AI) is the lack of properties and methods for setting/modifying the visual attributes of diagrams and diagram objects. For example, how do you set a diagram automatically generated by the AI to display element aliases using only the AI? Or, how do you set an AI-generated diagram object to display using rectangle notation, again using only the AI?

There are workarounds for these examples, but they are less than optimal. For the first case, you can modify the key-value pair in the diagrams' ExtendedStyle attribute to UseAlias=1. However, it seems that ExtendedStyle is empty when the diagram is first created by the AI, so it is necessary to set the complete ExtendedStyle string, e.g.
Code: [Select]
diagram.ExtendedStyle = "HideRel=0;ShowTags=1;ShowReqs=0;ShowCons=0;OpParams=1;ShowSN=0;ScalePI=0;PPgs.cx=1;PPgs.cy=1;PSize=119;ShowIcons=1;SuppCN=0;HideProps=0;HideParents=0;UseAlias=1;HideAtts=0;HideOps=0;HideStereo=0;HideEStereo=0;FormName=;"in order to accomplish this. (Note that the example also turn tags on and sets the page size to 11x17.)

For the second example, there is an undocumented DiagramObject method SetStyleEx. Rectangle notation can be turned on for a diagram object as follows:
Code: [Select]
diagramObject.SetStyleEx("UCRect", "1")But it is unclear whether this is a "for Sparxians only" method or if the documentation hasn't yet caught up. Note that setting the StyleEx property directly is not straightforward since EA stores a DUID field, unique for each diagram object, in the StyleEx column.

Sparx should provide documented SetStyleEx methods (or equivalent) for both diagrams and diagram objects that allow any diagram/diagram object attributes that can be set in the GUI to be set using the AI.
Fred Woolsey
Interfleet Technology Inc.

Always be ready to laugh at yourself; that way, you beat everyone else to the punch.


KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Setting Diagram and Diagram Object Attributes
« Reply #1 on: August 04, 2011, 10:13:37 am »
Quote
However, it seems that ExtendedStyle is empty when the diagram is first created by the AI, so it is necessary to set the complete ExtendedStyle string
I don't think that's true. Try just setting the value or values that you are interested in, and EA will add the rest.
The Sparx Team
[email protected]

fwoolz

  • EA User
  • **
  • Posts: 435
  • Karma: +0/-0
  • We have met the enemy, and he is us.<Pogo, 1970>
    • View Profile
Re: Setting Diagram and Diagram Object Attributes
« Reply #2 on: August 04, 2011, 12:17:09 pm »
Cheers Neil,

I did not know that; I will give it a try. It does seem, however, that the attribute is empty until the diagram property page is accessed, kind of along the lines of the Pos attribute (empty until the tree order is changed).
Fred Woolsey
Interfleet Technology Inc.

Always be ready to laugh at yourself; that way, you beat everyone else to the punch.