ATTENTIONThis FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices. |
flexsim.com |
|
Downloads |
Tips and Tricks Share helpful modeling ideas |
#1
|
|||
|
|||
How to get a full path of the current open Flexsim model file.
Unfortunately, there is no direct command to do that. However, since the model file path is in the title of the Flexsim window. You may use the following command to get the Flexsim window title, then parse it to get the path. See:
Code:
string winTitle = getviewtext(systemwindow(0)); pt("Window title is ");pt(winTitle);pr(); string fullModelPath = stringpart(winTitle,10,stringlen(winTitle)); pt("Model file path is ");pt(fullModelPath);pr(); Code:
string winTitle = getviewtext((treenode)systemwindow(0)); |
#2
|
|||
|
|||
modeldir command
I found modeldir flexscript command. Based on the description, it is supposed to return the path of the currently open model's directory. I tried it, but null value is returned.
pt(modeldir());pr(); Could anybody tell what is wrong? |
#3
|
||||
|
||||
Quote:
Are you looking in the output console or in the Script window? It will "print" to the output console. It works fine on my machine.
__________________
Jeff Flexsim Support |
#4
|
||||
|
||||
Sung,
If you want to see the directory in the script window just put in the following code: modeldir() And then hit Execute. Please note, that if you do this when you are viewing a blank model or a model that has not been saved yet then you will get NULL as the answer because there is no model directory yet. You have to load a model that has been saved or save the model you are looking at first. Good Luck, Brandon
__________________
thats not normal. |
#5
|
||||
|
||||
Also, you can use the currentfile() command to access the full model path. Note that when Regan initially posted (August 2007), these commands did not exist, so the very first post for this thread was correct at the time it was posted, but modeldir() and currentfile() now give you access to the path of the model and its directory. These commands were added to 4.3.
|
#6
|
|||
|
|||
It's also important to note that modeldir() appears to behave differently on MS Vista compared to XP. Under Vista calling modeldir() will return something like "C:\Program Files\Flexsim4\userprojects\", note the trailing slash at the end of the userprojects directory. Under XP that slash is omitted, and would appear like: "C:\Program Files\Flexsim4\userprojects". Where this gets important is if you wanted to get access to a file that was in the same directory as the model and did the following:
Code:
string path = concat(modeldir(),"myfile"); pt(path);pr(); Code:
string path = concat(modeldir(),"\\myfile"); pt(path);pr(); Last edited by Regan Blackett; 04-17-2008 at 10:25 AM. |
The Following User Says Thank You to Regan Blackett For This Useful Post: | ||
Jörg Vogel (08-01-2014) |
#7
|
|||
|
|||
Hi Regan,
Are you sure about the behaviour of modeldir() under XP? When I try modeldir() on my system that is Win XP, I get a trailing slash. I get "C:\Program Files\Flexsim4\userprojects\" under XP. Lars-Olof |
#8
|
|||
|
|||
I've heard from a couple of people now that they are getting the correct trailing slash when using modeldir under XP. Which is troubling since, I'd "discovered" the inconsistency during a support issue this morning where the user's XP machine wasn't adding the trailing slash, but my Vista machine was. The way we fixed the issue was by adding slashes to the file name he was concating with.
|