How to retrieve the filepath of a model

Hello forum!

I read the following thread which helps a lot. https://mps-support.jetbrains.com/hc/en-us/community/posts/206440149-How-to-Retreive-Project-Path?flash_digest=df9b7b44b66dfd7212588dc4a4fbf5a38613e6e2

Unfortunately, I can't get the path of the current model.

I tried the following code samples, but I wasn't able to get the path of the smodel or rather the suitable method.

MPSDataKeys.Model.getData(DataManager.getInstance().getDataContext())

Has someone an idea?

2 comments

model m = ...;

#print m/.getSource().getLocation()

This will give you the path to the .mps file. If you want to have the path to the folder you could use

#print new File(m/.getSource().getLocation()).getParent();

1

Thanks Alexander! Works as expected for me.

0

Please sign in to leave a comment.