Book a Demo

Author Topic: How do I check whether an embeddedElement is visible in VB script?  (Read 4760 times)

mse

  • EA User
  • **
  • Posts: 308
  • Karma: +1/-0
    • View Profile
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.
« Last Edit: February 21, 2020, 07:05:23 pm by mse »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: How do I check whether an embeddedElement is visible in VB script?
« Reply #1 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.

mse

  • EA User
  • **
  • Posts: 308
  • Karma: +1/-0
    • View Profile
Re: How do I check whether an embeddedElement is visible in VB script?
« Reply #2 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.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: How do I check whether an embeddedElement is visible in VB script?
« Reply #3 on: February 21, 2020, 08:27:54 pm »
A little SQL can find things in no time.

q.

mse

  • EA User
  • **
  • Posts: 308
  • Karma: +1/-0
    • View Profile
Re: How do I check whether an embeddedElement is visible in VB script?
« Reply #4 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.

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: How do I check whether an embeddedElement is visible in VB script?
« Reply #5 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
My theories are always correct, just apply them to the right reality.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: How do I check whether an embeddedElement is visible in VB script?
« Reply #6 on: February 21, 2020, 11:11:48 pm »
AFAIK the Realisation (with British "s") is still lurking around.

q.

mse

  • EA User
  • **
  • Posts: 308
  • Karma: +1/-0
    • View Profile
Re: How do I check whether an embeddedElement is visible in VB script?
« Reply #7 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

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: How do I check whether an embeddedElement is visible in VB script?
« Reply #8 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.