Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: RobCDeJong on November 18, 2013, 08:18:09 pm

Title: Get ports classified by an interface block
Post by: RobCDeJong on November 18, 2013, 08:18:09 pm
I want, via the EA object model API, to get all ports (or all elements) where an interfaceblock is the classifier of.

For an element, the classifierID is a property but I want to see which elements use a specific interface block. Is there a single API-call to get this information?

Cheers,
Rob
Title: Re: Get ports classified by an interface block
Post by: Helmut Ortmann on November 18, 2013, 09:33:27 pm
Hi,

there is no simple API to find the ports of an InterfaceBlock.

You may:
- Iterate over all ports
- use SQL

Helmut
Title: Re: Get ports classified by an interface block
Post by: qwerty on November 18, 2013, 10:23:06 pm
Try
Code: [Select]
Repository.SQLQuery ("SELECT * FROM t_object as o1, t_object as o2 WHERE o1.object_type = "Port" AND o2.object_type = "Interface" AND o1.PDATA1 = o2.ea_guid AND o2.object_id = <theid>")where <theid> is the ObjectID of the interface.

q.
Title: Re: Get ports classified by an interface block
Post by: RobCDeJong on November 19, 2013, 12:01:13 am
Thank you, that helped!

@qwerty, i revised the code a bit to the snippet below. This because the object_type for a InterfaceBlock is a Class and because the object_id is a unique id it is not needed to give a good answer.
Code: [Select]
SELECT * FROM t_object as o1, t_object as o2 WHERE o1.object_type = "Port"  AND o1.PDATA1 = o2.ea_guid AND o2.object_id = <id>