Write to Instance Table

MagicDraw OpenAPI, scripting related questions and discussions

Moderator: Moderators

Write to Instance Table

Postby cpadilla@tamu.edu » Mon Feb 25, 2019 10:08 am

Is there a way to write values to instance table cells using the OpenAPI? I have a .csv file I want to read from using Java's File I/O and write its values into an instance table. I'm trying create something similar to the Import/Export feature on the Table Toolbar but without needing to click it using the UI. I've looked at the GenericTableManager class, but that seems to be useful only for reading from the table, not writing to the table.

Also, unfortunately the Table Import/Export Plugin (which contains exactly the functionality I'm looking for) is not OpenAPI (and I've tried to trace its code to figure out what it's doing, but it's impossible to read). :cry:

Thanks,
Chris
cpadilla@tamu.edu
Forum Newbie
Forum Newbie
 
Posts: 6
Posts Rating:0
Joined: Tue Feb 12, 2019 3:00 pm

Re: Write to Instance Table

Postby gdhardy1 » Wed Mar 13, 2019 11:59 am

See API for StereotypesHelper class.

Use StereotypesHelper.setPropertyValue() method to set the value of the "rowElements" property on the "DiagramTable" stereotype for the Instance Table element you are writing to.

The "rowElements" property value object should be a list of "Element Server ID" strings corresponding to the list of elements that you wish to add to the table.

Considering you are trying to import from an excel sheet, you'll need to first create the instance specification elements using the ElementsFactory class.
gdhardy1
Forum Newbie
Forum Newbie
 
Posts: 8
Posts Rating:2
Joined: Thu Oct 18, 2018 11:24 am

Re: Write to Instance Table

Postby cpadilla@tamu.edu » Wed Mar 13, 2019 1:08 pm

gdhardy1 wrote:See API for StereotypesHelper class.

Use StereotypesHelper.setPropertyValue() method to set the value of the "rowElements" property on the "DiagramTable" stereotype for the Instance Table element you are writing to.

The "rowElements" property value object should be a list of "Element Server ID" strings corresponding to the list of elements that you wish to add to the table.

Considering you are trying to import from an excel sheet, you'll need to first create the instance specification elements using the ElementsFactory class.



Thanks for the response, I ended up using an internal API call (not ideal) which works for now. But I will go back and try this more lucrative method when I get the chance.
cpadilla@tamu.edu
Forum Newbie
Forum Newbie
 
Posts: 6
Posts Rating:0
Joined: Tue Feb 12, 2019 3:00 pm


Return to Programmatic Extendibility

Who is online

Users browsing this forum: No registered users and 0 guests