Accessing Properties using OpenAPI

MagicDraw OpenAPI, scripting related questions and discussions

Moderator: Moderators

Accessing Properties using OpenAPI

Postby ivan.baeriswyl@hefr.ch » Mon May 06, 2019 6:13 am

Hello,

I am currently working on a Cameo plugin using OpenAPI, and I find myself in quite some troubles to access elements' properties.

As an example, I have a flow property in an interfaceBlock, and I'd like to access its direction property programmatically, in Java. Is there a convenient way to do so ?

interfaceblock.png

specification.png


Thanks in advance,
Ivan
You do not have the required permissions to view the files attached to this post.
ivan.baeriswyl@hefr.ch
Forum Newbie
Forum Newbie
 
Posts: 6
Posts Rating:1
Joined: Wed Dec 12, 2018 12:39 am

Re: Accessing Properties using OpenAPI

Postby cpadilla@tamu.edu » Mon May 06, 2019 12:05 pm

Yes, first find the element and store it as an Element in Java

Code: Select all
Element directionElement = (Element)elementVariable.refGetValue(PropertyNames.DIRECTION)


It returns an Object, but you are able to get its human name and cast it however you want. Here I'm casting it as an Element, but it could just be a String or Boolean depending on the specific property (though I think yours is a generic Element). You can do this for all properties listed in the PropertyNames class.
cpadilla@tamu.edu
Forum Newbie
Forum Newbie
 
Posts: 6
Posts Rating:0
Joined: Tue Feb 12, 2019 3:00 pm

Re: Accessing Properties using OpenAPI

Postby ivan.baeriswyl@hefr.ch » Tue May 07, 2019 12:25 am

Thank you very much !! Works perfectly :D
ivan.baeriswyl@hefr.ch
Forum Newbie
Forum Newbie
 
Posts: 6
Posts Rating:1
Joined: Wed Dec 12, 2018 12:39 am


Return to Programmatic Extendibility

Who is online

Users browsing this forum: No registered users and 0 guests