Author Topic: SetAppearance removes element type  (Read 11264 times)

royvanmarrewijk

  • EA User
  • **
  • Posts: 61
  • Karma: +1/-0
    • View Profile
SetAppearance removes element type
« on: July 04, 2016, 09:14:42 pm »
Hi,

I am writing a script (JScript) which set the global color of the blocks and there instances. I use the SetAppearance function to do this but when I color an instance the element type of the instance within an internal block diagram disappears. So can anyone tell me how to prevent this or how I can enable 'show element type' with scripting?

kind regards,
Roy van Marrewijk

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: SetAppearance removes element type
« Reply #1 on: July 04, 2016, 09:25:37 pm »
I'm not sure about the coloring question. There is per element and per diagram coloring. The latter overrides the first.

Regarding Type: diagram.StyleEx contains VisibleAttributeDetail which can be set to 0 (name and type; see p. 73 of my Inside book).

q.

royvanmarrewijk

  • EA User
  • **
  • Posts: 61
  • Karma: +1/-0
    • View Profile
Re: SetAppearance removes element type
« Reply #2 on: July 04, 2016, 09:52:16 pm »
Hi qwerty,

Thanks for your quick reaction!!
Normally we right click on an element in the internal block diagram and then select advanced -> Show element type, this of course wil show the type of the selected element. I would like to automate this and I am going to try out your idea.

Roy

royvanmarrewijk

  • EA User
  • **
  • Posts: 61
  • Karma: +1/-0
    • View Profile
Re: SetAppearance removes element type
« Reply #3 on: July 04, 2016, 10:53:59 pm »
Hi,

I tried to edit the diagram styleEX but that didn't work out. This is what my code look likes:

Code: [Select]
diagram.StyleEx = "ShowAsList=0;"+
"AdvanceElementProps=1;"+
"ShowTests=1;"+
"ShowMaint=1;"+
"ShowNotes=1;"+
"HideQuals=0;"+
"AdvancedFeatureProps=1;"+
"ShowOpRetType=1;"+
"SuppressBrackets=1;"+
"AttPkg=1;"+
"VisibleAttributeDetail=1;"+
"TExplicitNavigability=1;"+
"AdvancedConnectorProps=1;"+
"SuppConnectorLabels=1;"

diagram.Update();

With this code I see some changes but not the required element type.

Can anyone provide me with some tips & tricks?
Roy

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: SetAppearance removes element type
« Reply #4 on: July 04, 2016, 11:03:58 pm »
Roy,

You'll have to figure out what exactly EA changes in order to make the element type appear.
I'm guessing it will be something on the DiagramObject rather the Diagram.

A useful tool in such circumstances is a profile (such as the one in SQL Server) so you can record every query EA executes on the database and thus easily spot the place where EA hides this information.

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: SetAppearance removes element type
« Reply #5 on: July 05, 2016, 07:11:11 am »
Unfortunately you are likely referring to SysML which I don't have. So you are probably bound to what Geert suggests. What I do is to export the contents of all tables before and after an update and then run Winmerge on the dump. This way I just need EAP files and have no need for a more complex RDBMS.

q.

royvanmarrewijk

  • EA User
  • **
  • Posts: 61
  • Karma: +1/-0
    • View Profile
Re: SetAppearance removes element type
« Reply #6 on: July 05, 2016, 04:21:57 pm »
Hi,

Since I don't want to ruin the general model I am scripting in a local .eap. So is there an option to read / export the database behind the .eap so I can compare it.

kind regards,
Roy

PeterHeintz

  • EA User
  • **
  • Posts: 976
  • Karma: +58/-18
    • View Profile
Re: SetAppearance removes element type
« Reply #7 on: July 05, 2016, 04:56:14 pm »
Not sure what you have in mid for compare. .eap is a MS-Access DB (just to long ago that I worked with Access to know I comparing two DB’s is simple or not.
Another option would be transferring it to a real SQL DB like oracle, MySQL, MS-SQL,…
Best regards,

Peter Heintz

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: SetAppearance removes element type
« Reply #8 on: July 05, 2016, 06:40:43 pm »
I use a litte Perl script for the export (I use a few Mickeysoftware as possible). If you have M$ Access you can open the EAP (eventually you need to rename it to .mdb IIRC). I don't know what it offers on extra tools. I know you can use VB inside too, but that would not be much different to using it from inside EA.

q.

royvanmarrewijk

  • EA User
  • **
  • Posts: 61
  • Karma: +1/-0
    • View Profile
Re: SetAppearance removes element type
« Reply #9 on: July 05, 2016, 07:48:26 pm »
Thanks again!

I've installed a MySQL database on my pc and exported my project to this database. After I compared the two exports (before and after the change) I discoverred that t_diagramobject.ObjectStyle contains the information (PType = 1) as you allready expected. Only when the property type must be shown the PType string will be visible in the ObjectStyle field.

Thanks for giving me directions!
Roy

royvanmarrewijk

  • EA User
  • **
  • Posts: 61
  • Karma: +1/-0
    • View Profile
Re: SetAppearance removes element type
« Reply #10 on: July 05, 2016, 07:57:21 pm »
FYI:

I used the following code to set the colors of a diagramObject to 'default'

Code: [Select]
diaObj.Style = "BCol=-1;BFol=-1;LCol=-1;LWth=-1;";
diaObj.Update();

because the function "element.SetAppearance(0, 0, white)" didn't do the trick.

So this is the cause of the failure.

Roy




qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: SetAppearance removes element type
« Reply #11 on: July 05, 2016, 10:01:36 pm »
Element.SetAppearance influences the element's general appearance. If you place it on a fresh diagram it will have the specified color. But you can override this color locally per diagram (this is what your code piece is doing).

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: SetAppearance removes element type
« Reply #12 on: July 06, 2016, 02:04:32 am »
FYI:

I used the following code to set the colors of a diagramObject to 'default'

Code: [Select]
diaObj.Style = "BCol=-1;BFol=-1;LCol=-1;LWth=-1;";
diaObj.Update();

because the function "element.SetAppearance(0, 0, white)" didn't do the trick.

So this is the cause of the failure.

Roy

Cool. Thanks for posting the solution as well.

Geert

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8083
  • Karma: +118/-20
    • View Profile
Re: SetAppearance removes element type
« Reply #13 on: July 06, 2016, 08:38:59 am »
I used the following code to set the colors of a diagramObject to 'default'

Code: [Select]
diaObj.Style = "BCol=-1;BFol=-1;LCol=-1;LWth=-1;";
diaObj.Update();

because the function "element.SetAppearance(0, 0, white)" didn't do the trick.

So this is the cause of the failure.

Roy

That code replaces everything in the style string with exactly the string that you have specified. So, yes it will remove any other settings associated with that diagram object.