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 - Andre_b_b

Pages: 1 [2] 3
16
Hi guys, i am able to add packages to a model, add diagrams and elements to a package, add elements do diagram and connectors between the elements. Almost perfect, except for the fact that when i finish running my script, the elements are all in the same position and the layout options of the menu are not so useful because they cannot separate some elements. Anyone have an idea of a method  to arrange the elements and the connectors in a better visualization? I have seen some discussions here in the forum, but none of them were useful to me /:   Is it better to arrange during the generation of the elements, generation of the connectors, or is there a function that organizes everything and i could put in the end of the script?

17
ok  :D. Yes, looking back in the post, it really seems i am a "vampire", but if i am, it was not my intention. Sorry guys, i am trying to understand stuff, but sometimes my low-konwledge of programming, in general, do not allow me to evolute  :-\ :-\

18
Excuse me, i am not sure what you mean from this comment. I hope you are not judging me for trying to learn programming and how to use Enterprise Architect.

19
Thanks guys! I have tried reading the tutorials and everything but i do not understand the documentation, and everything looks advanced to me, so in this moment i am not able to learn - apparently -, that is why i keep asking here in the forum, because i do not find answers in any other place. Sorry for the mistakes and thanks for your help.

20
I have managed to create the connection, but how can i turn it visible? I would like to show the relation in a diagram.

21
Thanks for your help Geert.
Unfortunately, even with the suggestions and corrections you've made, i am still not able to run the script and so, i cannot make the connections. The error given is "this object does not manage" and it does reference to the line of "Element1 = Repository.GetElementByGUID("{53C6DD5C-04D6-4b6f-9102-142557A3F4C7}")"
Code: [Select]
option explicit 
 
!INC Local Scripts.EAConstants-VBScript 
sub main

Dim Element1
Dim Element2
Dim Connector
Element1 = Repository.GetElementByGUID("{53C6DD5C-04D6-4b6f-9102-142557A3F4C7}")
Element2 = Repository.GetElementByGUID("{49602501-62AA-4426-A862-45B066F62DF0}")

Set Connector = Element1.Connectors.AddNew("", "Association")
   Msgbox ("!")
Connector.SupplierID = Element2.ElementGUID
Connector.Update()
end sub 
 
main 


22
There is this "internal error" in the line "Set Element1 = Repository.GetElementByGuid("{53C6DD5C-04D6-4b6f-9102-142557A3F4C7}")". And the GUID i have copied by right-clicking in the element from the browser and copying the GUID. Here it is the code i have been working with. I am sorry, i do not understand what is the t_object.ea_guid you asked me.

Code: [Select]
option explicit 
 
!INC Local Scripts.EAConstants-VBScript 

sub main 

 

Dim Repository 
Dim Diagram 
Dim Element1
Dim Element2
Dim Connector 
 

Set Repository = CreateObject("EA.Repository") 
 

Set Diagram = Repository.GetCurrentDiagram() 
 

Set Element1 = Repository.GetElementByGuid("{53C6DD5C-04D6-4b6f-9102-142557A3F4C7}")
Set Element2 = Repository.GetElementByGuid("{49602501-62AA-4426-A862-45B066F62DF0}")

Set Connector = Element1.Connectors.AddNew("", "Association")
 
Connector.SupplierID = Element2.ElementID 
 
Diagram.DiagramLinks.Refresh() 
Diagram.Update() 

end sub 
 
main 

23
Nice. Thanks Geert. Should i get the element by GUID? If yes, i am trying to use the code, but it says that there is a "Internal Application Error".
Code: [Select]
' Active Diagram 
Set Diagram = Repository.GetCurrentDiagram() 
 
' Get 2 elements from their GUID 
Set Element1 = Repository.GetElementByGuid("{53C6DD5C-04D6-4b6f-9102-142557A3F4C7}")   
Set Element2 = Repository.GetElementByGuid("{49602501-62AA-4426-A862-45B066F62DF0}") 

24
Thanks Geert. But how do i put the Source, Target and Type of the connector? Shoud i use the name of Source and Target or their GUIDs?

25
Hi guys,
just to say that i could make an interface with Excel, from a VBscript in Enterprise Architect, in order to generate the elements in Enterprise Architect within a package with the value of the cells of the Excel. Another script is udes to show the elements in the diagram. Next step is to discover how to add the connections between the elements.

27
Thanks Geert. I will read and i will arrive with more questions :)

28
Ok Qwerty, thanks for your attention.
Would you recomend a course or some materials i could use to learn?
 Unfortunately, i have been looking for materials, but i did not find a lot. Iam not expert in Programming and in Enterprise Architect, but i do want to learn and produce content and important tools for me.

29
Ok, thanks for your help; i will go step by step then :)
I do not understand and i can't find how to add an element from VBScript in EA.
Should i use this command?
Code: [Select]
Set newElement = eaElement.AddNew(name,type)
I want to read the Excel and generate from the columns new elements.

30
Hi guys,
i have been working with Enterprise Architect for 2 months and my objective is, from a Excel file, generate a diagram within the relations between the elements(mainly "InformationFlow", "Derive","Usage"). In order to achieve this, i use the MDG Integration Office Add-in and i could do it, but i need to do the process in an automatic way: Run a script inside EA should be enough. I have developed a code in VBScript but it is not working - in fact, i can run the script but anything happens/changes in the software. Can you help me with the code or suggest any other way to achieve my objective? Unfortunately i only have 2 months to finish this project... Here i let the code that was written in the scripting Window of my Enterprise Architect.
Code: [Select]
option explicit

!INC Local Scripts.EAConstants-VBScript

'
' Script Name: import excel into EA
' Author:  Andre
' Purpose: import an excel file in order to generate a diagram and its elements
' Date: 19/06/2023
'
Sub importexcel()   


    ' Set the path and filename of the Excel file to import 
    Dim filePath
    Dim fileName
    filePath = "MyPathtomyFile" 
    fileName = "my_file.xlsx" 
     
    ' Set the name of the package to import the data into 
   Dim packageName
    packageName = "New Package" 
     
    ' Set the name of the object profile and connector profile to use 
   Dim objProfileName
   Dim conProfileName 
    objProfileName = "my_objprofile_name" 
    conProfileName = "my_conprofile_name" 
     
    ' Import the data from the Excel file 
    Dim repository As EA.Repository 
    Set repository = GetObject("MyPathtomyFile", "EA.App").Repository 
    repository.ImportCSVEx filePath & fileName, objProfileName, conProfileName, packageName, False, False, False, False, False, False 
     
    ' Create a new diagram to represent the imported data 
    Dim diagram As EA.Diagram 
    Set diagram = repository.Diagrams.AddNew("name_of_diagram", "ActivityDiagram") 
     diagram.PackageID = repository.GetPackageByGuid(repository.Models.GetAt(0).PackageGUID).PackageID 
     diagram.Update 
     
 
 

    ' Find the objects that were imported and add them to the diagram 
    Dim objects As EA.Collection 
    Set objects = repository.GetElementsByQuery("SELECT Object_ID FROM t_object WHERE Stereotype = 'YourStereotypeName' AND Package_ID = " & repository.GetPackageByName(packageName).PackageID) 
    Dim obj As EA.Element 
    For Each obj In objects 
        Dim diagramObject As EA.DiagramObject 
        Set diagramObject = diagram.DiagramObjects.AddNew("", "") 
        diagramObject.ElementID = obj.ElementID 
        diagramObject.Update 
    Next   
     
    ' Find the connectors that were imported and add them to the diagram 
    Dim connectors As EA.Collection 
    Set connectors = repository.GetElementsByQuery("SELECT Connector_ID FROM t_connector WHERE Package_ID = " & repository.GetPackageByName(packageName).PackageID) 
    Dim con As EA.Connector 
    For Each con In connectors 
        Dim diagramLink As EA.DiagramLink 
        Set diagramLink = diagram.DiagramLinks.AddNew("", "") 
        diagramLink.ConnectorID = con.ConnectorID 
        diagramLink.Update 
    Next 
     
    ' Refresh the view to show the imported data and the new diagram 
    repository.RefreshModelView (packageName) 
     
End Sub 

Pages: 1 [2] 3