Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: chrvi on September 12, 2007, 09:47:36 am
-
Hi,
I'm trying to export diagrams into image files. However, some of the exported files are zero-sized.
I have finally discovered the reason:
When I create a DiagramObject I use the following code:
DiagramObject newDiagramObject = aParentDiagram.GetDiagramObjects().AddNew(diagramObjectName, "something");
I don't know why but the String "something" becomes a content of newDiagramObject.Style attribute.
The diagramObjects created manually in EA contains something like this in their Style attribute: "DUID=461CC6F9;"
Diagrams containg diagramObjects with such a Style attribute export correctly.
Diagrams containing diagramObjects created via automation and with their Style set to "AttPro=0;AttPri=0;AttPub=0;AttPkg=0;OpPro=0;OpPri=0;OpPub=0;OpPkg=0;RzO=1;" (because I don't want attributes info or methods info to be shown in the diagram for this diagramObject) export also correctly (despite the Style attribute contains no DUID info as in the previous case).
However, diagrams with diagramObjects created simply by AddNew(diagramObjectName, "something"), contains "something" in their Style. In EA you can't notice this. The diagram looks normally. But the exported diagram will be an empty file then.
So HOW shall I populate the diagram's diagramObject's Style to make the diagram export correctly and to have diagramObjects displayed WITH their attributes and methods?
Possibly by setting DUID to the Style attribute but how to do that? What is the mysterious DUID and how to access it?
Thanks for any hint...
-
Well, I appologize. It's not truth that DiagramObject.Style attribute must be filled and contain something meaningful to export its diagram correctly to a file.
I created a new model with a new diagram manually in EA and afterwards changed its DiagramObjects Style via automation first to something meningfull ("NSL=0;"), then to empty string "" and finally to "something" but the diagram was always exported correctly and no zero-sized file has appeared.
Now I really don't have ANY idea why some of my diagrams were always exported as empty files.
I can't see any difference between diagrams and diagramObjects which export correctly and which export wrong (I can't see any difference even in database where I can compare all their data field after field)...
It makes me mad. I've probably filled something wrong via automation but what can it be if the difference can't be found when comparing Diagrams and DiagramObjects?
-
Did you do a Diagram.DiagramsObjects.Refresh() after you added the objects but before you did the export? If not, the diagram would not 'know' it was populated, and EA would likely get a zero-size bounding rectangle.
Just a guess, but it seems possible.
David
-
Yes, I did. The model was considered "stable" having the needed data and containing diagrams which (in EA) seemed to be OK. I always use Refresh metod when inserting a new object into a collection.
Nevertheless, I bet the diagramObjects wouldn't be accessible or visible in EA if I didn't add them correctly. But this is not the case.
-
I've sometimes noticed that I need to reload a diagram in order to get it to display correctly after inserting objects via the API.
As well, the API often creates all the objects in the same location (unless you explicitly set their locations). You'd have to do a layout to get them off one another.
There are some 'reload-ish' repository methods you might want to try: ReloadDiagram, RefreshModelView, RefreshOpenDiagrams. There are also two methods that might help in other circumstances: AdviseElementChange and AdviseConnectorChange. AFAIK these would be unlikely to affect what you are doing now.
David