Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: minna on February 27, 2014, 06:16:11 pm
-
Hi,
I have a collection of information items in an excel spreadsheet. Can I import them into a diagram in EA?
Thanks,
Minna
-
Minna,
You should be able to do that with my Excel Importer (http://bellekens.com/2013/04/30/simple-vba-excel-to-ea-importer-v3/)
Geert
-
Hi Geert,
Thanks for the feedback. If I understand your tutorial correctly, then I need to add 'InformationItem' to the spreadsheet (Type) and add all my information items there. Then I need to change the VBA code to add these 'InformationItems' to EA since there is no 'InformationItem' in EA.Element.Type.
Am I correct in my statement? Is there another way of adding InformationItems to EA using Excel without writing any VBA code?
Thanks,
Minna
-
It's been a while since I wrote the code, but I thought you simply had to set the type field to InformationItem.
I'll try it myself and I'll let you know.
Geert
-
Hi Geert,
Thanks. I will also try just changing the type to InformationItems. I will give my feedback as soon as I have done it (might be only tomorrow).
Looking forward to your feedback.
Regards,
Minna
-
Indeed InformationItem is to be supplied in the element type field when you create it. That should create the right one.
Pk.Elements.AddNew ("new", "InformationItem");
q.
-
I just checked myself and there's a case missing in the operation
EAConnector.isValidElementType(elementType As String)
You'll need to add
Case "InformationItem"
isValidElementType = True
I'll update the version on my site this weekend.
Geert
-
Hi Geert,
Thanks, it works great.
Another thing I want to add is connectors (InformationFlow and Associations) to existing classes in a diagram. I added a Source and Target column header. In those columns I tried adding the class names as well as their GUID. This didn't work.
Should I add extra code in VBA?
Thanks,
Minna
-
Another quick question. How do I get the ElementID of a class in EA? I can only see the GUID in the properties view.
Thanks!
-
In order to add relations you'll need to add extra code.
There's currently no operation in the EAConnector class to add connectors.
You'll have to do something similar to addOrUpdateAttribute but instead of adding a new attribute you'll have to add a new connector. parentClass.Connectors.AddNew (...
There are a few good examples on the forum on how to add a connector to an element.
Geert
-
Thanks. I will look at the forum for examples.
Quick question, How do I get the ElementID of a class in EA? I can only see the GUID in the properties view.
Thanks!
-
I don't think you can without doing a little query on the database.
Geert
-
Hi Geert,
I was going through your 'Simple VBA Excel to EA importer v3' tutorial. I noticed in EAConnector the first line states 'Dim EARepos As EA.repository'.
This might be a stupid question, but how does excel know that EA (in EA.repository) refer to the current Enterprise Architect model that is open on my pc?
Thanks,
Minrie
-
Because the import operation uses
Public Function getSelectedPackage() As EA.package
Dim aEArepository As EA.repository
'if the repository is not already know get the repository
If EARepos Is Nothing Then
'get the currently opened repository
Set aEArepository = Me.[highlight]getCurrentRepository[/highlight]
Else
Set aEArepository = EARepos
End Ifand getCurrentRepository does:
Public Function getCurrentRepository() As EA.repository
Dim EAapp As EA.App
Dim EArepository As EA.repository
[highlight]Set EAapp = GetObject(, "EA.App")[/highlight]
'Warning when EA not open
If EAapp Is Nothing Then
MsgBox "Please Open Enterprise Architect"
'try again
Set getCurrentRepository = Me.getCurrentRepository
End If
'Warning when no repository is opened.
Set EArepository = EAapp.repository
If EArepository Is Nothing Then
MsgBox "Please open a Model in Enterprise Architect"
'try again
Set getCurrentRepository = Me.getCurrentRepository
End If
'return the found repository
Set getCurrentRepository = EAapp.repository
End Function
Geert
-
Hi Geert,
I copied and pasted the code in all the modules as it is in 'Simple VBA Excel to EA importer v3'. I get a error in EAConnector on the top line 'Dim EARepos As EA.repository'. The error is 'User-defined type is not defined'.
This error make sense to me since Excel need to know what 'EA' refers to in 'Dim EARepos As EA.repository'. If I were using visual studio, I would have probably added a reference of Enterprise Architect so that the compiler knows what 'EA' refers to.
How do let Excel know what 'EA' refers to? How does Excel know to go look for an open model of Enterprise Architect?
Thanks,
Minna
-
Tools|Refences
Geert
-
Thanks!