file [FeatureRequest] macros/lib in jython standard path

8 years 9 months ago #2201 by jmfavre
Bonsoir,
in order to develop modular jython code and useful libraries to be used in the script view, it would be really nice if a directory (let's say <CurrentWorkspace>/macro/lib) could be added systematically in the jython path when the script view is launched (and in all other interpreters). I mean, this would allow one to develop some nice functions and deliver these functions to users who want to reuse them either interactively or in macros.

Currently what I'm doing is starting each "script view with the following snippet. Since it as to to be copied each time this is not really convenient...
try:
  from org.modelio.api.modelio import Modelio
  orgVersion = True
except:
  orgVersion = False
import os
import sys 
WORKSPACE_PATH=Modelio.getInstance().getContext().getWorkspacePath()
if orgVersion:
  SCRIPT_LIBRARY_PATH=os.path.join(WORKSPACE_PATH.toString(),'macros','lib')
else:
  SCRIPT_LIBRARY_PATH=os.path.join(WORKSPACE_PATH.toString(),'.config','macros','lib')
sys.path.append(SCRIPT_LIBRARY_PATH)

Note that the code above works both for Modelio 2 and Modelio 3 (.config/macros becomes macros so we need an adjustement here).

Moreover, it would be nice to have (as mentionned before) the class of the metamodel automagically imported like in Modelio 2.x. Currently one have even to import "Modelio" before to start playing ;-)
The following user(s) said Thank You: andy

Please Log in or Create an account to join the conversation.

Moderators: chmcma
Time to create page: 0.029 seconds
^ Back to Top