Sparx Systems Forum

Enterprise Architect => General Board => Topic started by: mse on February 21, 2020, 07:01:02 pm

Title: How do I check whether an embeddedElement is visible in VB script?
Post by: mse on February 21, 2020, 07:01:02 pm
My script finds the right diagram object, but then it goes through every port embedded in that object. I only want to iterate through those ports that are visible on the object. Can I do this? Which method is available for this? I have tried with .IsActive, .Visibility. I think those are for different purposes however.
Title: Re: How do I check whether an embeddedElement is visible in VB script?
Post by: qwerty on February 21, 2020, 07:28:57 pm
I usually just run a short test to see the outcome. Took me 30 seconds. The Port just is not in the list of diagram objects if you hide it.

q.
Title: Re: How do I check whether an embeddedElement is visible in VB script?
Post by: mse on February 21, 2020, 07:33:33 pm
Given that explanation, then I know where my problem is. While I can get the diagram objects and their shown ports. When I find a displayed class for example, I request its embedded elements. This gives me ALL embedded elements for that displayed class and not the ones shown on the class border.

I will have to be careful then on iterating through the diagram. I don't know if it will go in order such as finding the class, then the ports on that class, then moving on to the next class, and so on.
Title: Re: How do I check whether an embeddedElement is visible in VB script?
Post by: qwerty on February 21, 2020, 08:27:54 pm
A little SQL can find things in no time.

q.
Title: Re: How do I check whether an embeddedElement is visible in VB script?
Post by: mse on February 21, 2020, 10:19:47 pm
I'm having trouble getting the dependency information from the ports. For some reason, only 2 ports show dependency information while others (which have dependencies) are not detected by my script.

Code: [Select]
   set itsRealizations = Element.Connectors
   for each aRealization in itsRealizations
      if (aRealization.Type = "Dependency") then
         Session.Output "Port " & Element.Name   & " requires "
      end if
   next

I know I wrote "Realization" in there, but that is for my next step when I get information on which ports are realizing the interface. For now I'm trying to account for all requires dependencies. Only 2 show up, the rest are not. I have at least two more ports where in the properties window under links, I clearly see "Dependency" and the interface it refers to.
Title: Re: How do I check whether an embeddedElement is visible in VB script?
Post by: Uffe on February 21, 2020, 10:31:54 pm
Try outputting the connector type, and its ID (which you can then verify against the database).

/U
Title: Re: How do I check whether an embeddedElement is visible in VB script?
Post by: qwerty on February 21, 2020, 11:11:48 pm
AFAIK the Realisation (with British "s") is still lurking around.

q.
Title: Re: How do I check whether an embeddedElement is visible in VB script?
Post by: mse on February 22, 2020, 12:10:40 am
I changed the name of the two ports that were showing up to see exactly which ones they were on the diagram. They are the outermost ports of my composite structure diagram. That means the other ports that belong to the parts are somehow not being included even though they show up.

Here is what I have:

Code: [Select]
elseif(Element.Type = "Port" ) then
Session.Output "Port " & Element.Name
dim connector as EA.Connector
dim connectorCollection as EA.Collection
set connectorCollection = Element.Connectors
for each connector in connectorCollection
if (connector.Type = "Dependency") then
Session.Output "Port " & Element.Name   & " requires an interface "
elseif (connector.Type = "Realization") then
Session.Output "Port " & Element.Name   & " provides an interface "
end if
next
else
end if
Title: Re: How do I check whether an embeddedElement is visible in VB script?
Post by: qwerty on February 22, 2020, 02:06:30 am
What did I say above?

Try adding

Code: [Select]
else
Session.Output "Port " & Element.Name   & "has " & connector.Typ

q.