Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - George

Pages: [1]
1
I’d like to share my findings after experimenting with ImportInternalDocumentArtifact() for adding internal documents to Artifact elements. Initially, I thought the method was broken, but it turns out I had made a few mistakes — including falling into an undocumented trap.
These methods basically work as expected:
  • Element.ImportInternalDocumentArtifact(filePath) – imports the specified file as an internal document of the element
  • Element.IsInternalDocArtifact – indicates whether this element is an internal document Artifact
  • Element.ExportInternalDocumentArtifact(filePath) – exports the internal document to a file
However, beware of gotchas:
1. Stereotype blocks the file import
If the Artifact element has a Stereotype set, then ImportInternalDocumentArtifact() silently fails and returns false.
Workaround:
Code: [Select]
var origStereotype = artifact.StereotypeEx;
artifact.StereotypeEx = "";
artifact.ImportInternalDocumentArtifact(filePath);
artifact.StereotypeEx = origStereotype;
artifact.Update();

2. Artifact element name is overwritten
Calling ImportInternalDocumentArtifact() will automatically rename the element (element.Name) to match the imported file name. It can be also changed, reverted to the original name, if required.

3. Element.Files have nothing to do with internal documents
They only concern the external ones.

Hope this helps others avoid the same confusion.
Let me know if there are other obstacles or undocumented behaviors.
Thanks!

2
Regarding the documentation of ImportInternalDocumentArtifact() method.
Yes, I also found that documentation is missing, but Google found these links:

Mentioned in EA v12(!): Changes and fixes for Build 1212:
And also here, it seems to be Japanese version of EA documentation:
@Takeshi K:
Ok, I checked working with element.Files collection on a manual example.
- It works for external files (attachments) only, i.e. Type = "Local File" for files in file system or Type = "Web Address".
- Internal document stored within EA db seems not to be included into this collection, so the count in my original code fragment is useless.

3
Hello all,
I'm currently trying to import a file as an internal document using the ImportInternalDocumentArtifact() method from the EA automation interface (Enterprise Architect v16.x, 64-bit), but it does not seem to work.
Code: [Select]
var filePath = "C:\\Temp\\sample.json";
var artifact as EA.Element;
artifact = currentPackage.Elements.AddNew("config.json", "Artifact");
artifact.Update();
var result = artifact.ImportInternalDocumentArtifact(filePath);
Session.Output("File imported?: " + result + "; Count of artifact files: " + artifact.Files.Count);

Logged output:
Code: [Select]

[434475711] File imported?: true; Count of artifact files: 0
When I double-click on the created Artifact, no document opens — the file has not been imported.
Are there any preconditions for ImportInternalDocumentArtifact() to work? Any insight would be greatly appreciated.
 Thank you!

4
Hi all,
I'm working with EA 16+ (64-bit) and I’m trying to understand, when and how EA updates the size and position of objects in a diagram — for example, based on the element's name length, displayed features, etc.
If I insert an object into a diagram via script and set its size to something very small (e.g. 20×20), it seems that EA keeps using those coordinates until:
  • I open the diagram (Repository.OpenDiagram) – at that point EA renders the object with correct size on screen, but the original coordinates are still stored,
  • I save the diagram (Repository.SaveDiagram) – only then are the updated dimensions written to the model.
Here’s an example of the script output:
Code: [Select]
[695255689]      Calculated object position: left=300, top=100, right=320, bottom=120
[695255717]      Position initial: left=300, top=100, right=320, bottom=120
[695255736]      Position after AdviseElementChange: left=300, top=100, right=320, bottom=120
[695255741]      Position after ReloadDiagram: left=300, top=100, right=320, bottom=120
[695256049]      Position after OpenDiagram: left=300, top=100, right=320, bottom=120
[695256117]      Position after SaveDiagram: left=300, top=100, right=371, bottom=142
So my question is:
Is there a way to force EA to recalculate object size and position in the background, without having to open the diagram?

Thanks in advance for any insight or shared experience!
Jiri

5
Hi all,
I think that I found a bug in EA automation when placing ProvidedInterface or RequiredInterface elements in a component diagram via EA automation.
  • From testing, I found that the rendered "lollipop" shape of an interface has dimensions 40×13 px, with a 1 px inset into the component.
  • When such an interface is positioned on top or bottom of a component (i.e., placed horizontally), everything behaves as expected: the interface is rendered and stored with correct coordinates.
  • However, when the same interface is positioned on the left or right side of the component, using the same assumptions (i.e., horizontal orientation, 40×13), EA places the interface element at the requested top-left coordinates, but rotates it vertically.
    • The stored coordinates no longer match expectations: the bottom-right corner indicates a vertical object.
    • This happens even though EA renders the interface correctly when the diagram is opened.
    • If I manually move the component (e.g., drag it slightly), the interface moves with it and the coordinates are then recalculated correctly and updated after save.
Following are fragments of test script that demonstrates this issue.
Code: [Select]

// Sizes and positions
var COMP_X = 300, COMP_Y = 100, COMP_W = 200, COMP_H = 100; // Component rectangle
var IF_LEN = 40, IF_THICK = 13, IF_OFFSET = 1; // Real size of the i/f lollipop is 40x13 px and 1 px into the component
...

Session.Output("TopInterface expected: l=" + IF_TOP_X + ";t =" + IF_TOP_Y + "; r=" + (IF_TOP_X + IF_THICK) + "; b=" + (IF_TOP_Y + IF_LEN));
Session.Output("TopInterface actual:   l=" + diaIfTop.left + "; t=" + diaIfTop.top + "; r=" + diaIfTop.right + "; b=" + diaIfTop.bottom);
...

Session.Output("LeftInterface expected: l=" + IF_LEFT_X + "; t=" + IF_LEFT_Y + "; r=" + (IF_LEFT_X + IF_LEN) + "; b=" + (IF_LEFT_Y + IF_THICK));
Session.Output("LeftInterface actual:   l=" + diaIfLeft.left + "; t=" + diaIfLeft.top + "; r=" + diaIfLeft.right + "; b=" + diaIfLeft.bottom);
Logged results:
Code: [Select]

[653159378]      Component position: l=300; t=-100; r=500; b=-200
[653159387]      TopInterface expected: l=380;t =61; r=393; b=101
[653159390]      TopInterface actual:   l=380; t=-61; r=393; b=-101
[653159400]      LeftInterface expected: l=261; t=150; r=301; b=163
[653159403]      LeftInterface actual:   l=261; t=-150; r=274; b=-190
Does anyone have the same experience?
Rgds
Jiri

6
Regarding the association between element/attribute and its type, we use connector type "Dependency". When importing XSD into model, we use the option “Import XSD elements/attributes as UML attributes”. Then we run a script which generates the dependency connectors between attributes with their types. This way one can achieve both, complete view of the classes/types with all attributes (incl. their order in sequence!) and also visualization of the relationships, that everyone is likely to want.

7
Hello,
is there a possibility to run XSL transformation from a script? For example if I have XML Transform Diagram, is it possible to execute the xmlTransform activity from script? Or to access and execute the XSLT stored as Stylesheet resource?
Thanks
Jiri

8
General Board / Cloud Server - Windows Security login timeout
« on: September 20, 2017, 12:23:27 am »
Hello all,
we tested Cloud Server with MODEL_AUTHENTICATION against a DBMS repository. It works more or less as expected, however very unpleasant is the Windows Security login dialog timeout. It is accessible only a few seconds. If I don’t enter the username and password in time, the login dialog is overlaid by Windows „Server busy“ modal window. Then I can only kill EA task in Task Manager and start again.
Does anybody have similar experience? Is there any way how to resolve this, for example to set a timeout for the Windows Security login dialog?
Regards
Jiri

9
Hi Daniel and Geert,
did you manage to fix this problem?
I struggle with the same, I think.
In JavaScript:
------
var xmlDOM = new COMObject( "MSXML2.DOMDocument" );
...
var nodeList = xmlDOM.documentElement.selectNodes( nodePath );
error: xmlDOM.documentElement.selectNodes is not a function
------
In JScript it works, with appropriate DOM object creation - new ActiveXObject( "MSXML2.DOMDocument" )).
I tried both, "MSXML2.DOMDocument" and "MSXML2.DOMDocument.6.0", error is the same.
Best regards
Jiri

10
The layout option in GUI is is named "Digraph", it allows to choose also the direction. Corresponding constants are:
lsLayoutDirectionDown
lsLayoutDirectionLeft
lsLayoutDirectionRight
lsLayoutDirectionUp

11
Suggestions and Requests / Order of Inherited Attributes in reports
« on: November 18, 2016, 01:29:22 am »
We would like to use Inherited Attributes eventually Run State in the report. However, the report sorts the attributes unsatisfactorily.
Currently:
- Inherited Attributes are sorted in the report alphabetically.
- Run State attributes are sorted in the report different way, probably in the order of editing during value setting (?).
- On the diagram are the "attribute initializers", if displayed, sorted in the order of editing during value setting, but in reverse order than in the report.
None of the these behaviors is nice. Together they are quite confusing.
Correct order of the attributes in the descendant class (or object instance) should be the same as the order of attributes defined by its parent class.
Any advice, how to achieve it?

Pages: [1]