Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: royvanmarrewijk 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
-
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.
-
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
-
Hi,
I tried to edit the diagram styleEX but that didn't work out. This is what my code look likes:
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
-
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
-
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.
-
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
-
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,…
-
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.
-
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
-
FYI:
I used the following code to set the colors of a diagramObject to 'default'
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
-
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.
-
FYI:
I used the following code to set the colors of a diagramObject to 'default'
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
-
I used the following code to set the colors of a diagramObject to 'default'
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.