Set "Path Variable" Programmatically

MagicDraw OpenAPI, scripting related questions and discussions

Moderator: Moderators

Set "Path Variable" Programmatically

Postby fred.eisele@vanderbilt.edu » Thu Sep 05, 2019 10:13 am

I have a plugin from which I want to set a "Path Variable" programmatically.
Is this possible?
I have some sample models and profiles which are delivered with the plugin and I want the profiles to be visible to the models.
fred.eisele@vanderbilt.edu
Forum Newbie
Forum Newbie
 
Posts: 2
Posts Rating:0
Joined: Thu Sep 05, 2019 9:46 am

Re: Set "Path Variable" Programmatically

Postby fred.eisele@vanderbilt.edu » Thu Sep 05, 2019 11:21 am

The following seems to do the trick.
Code: Select all

@Override
    public void init()
    {
...

final PathVariable pv =  new PathVariable(
                                    "plugin.root",
                                    this.getDescriptor().getPluginDirectory().getAbsolutePath(),
                                    "plugin root");
final PathVariablesOptionsGroup pvog = Application
                .getInstance()
                .getEnvironmentOptions()
                .getPathVariablesOptions();
        pvog.addPathVariable(pv);

for ( PathVariable pvo : pvog.getPathVariables() ) {
            log.trace("path var: {} {}", pvo.getName(), pvo.getPath());
}
fred.eisele@vanderbilt.edu
Forum Newbie
Forum Newbie
 
Posts: 2
Posts Rating:0
Joined: Thu Sep 05, 2019 9:46 am


Return to Programmatic Extendibility

Who is online

Users browsing this forum: No registered users and 1 guest