ATTENTION

This 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

Go Back   FlexSim Community Forum > FlexSim Software > Tips and Tricks
FAQ Downloads Calendar Search Mark Forums Read

Tips and Tricks Share helpful modeling ideas

Reply
 
Thread Tools Display Modes
  #1  
Old 08-03-2007
Regan Blackett Regan Blackett is offline
Flexsim Consultant, Forum Moderator
 
Join Date: Jul 2007
Posts: 14
Downloads: 19
Uploads: 16
Thanks: 0
Thanked 14 Times in 6 Posts
Rep Power: 179
Regan Blackett will become famous soon enoughRegan Blackett will become famous soon enough
Default 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();
Note the above code will work in the script window as Flexscript. In C++, you have to modify the first line to the following to be able to compile it:

Code:
string winTitle = getviewtext((treenode)systemwindow(0));
Reply With Quote
  #2  
Old 03-31-2008
Sung Kim Sung Kim is offline
Flexsim User
 
Join Date: Jan 2008
Location: York, PA
Posts: 85
Downloads: 70
Uploads: 0
Thanks: 70
Thanked 9 Times in 6 Posts
Rep Power: 156
Sung Kim is on a distinguished road
Default 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?
Reply With Quote
  #3  
Old 03-31-2008
Jeff Nordgren's Avatar
Jeff Nordgren Jeff Nordgren is offline
Technical Support Manager
 
Join Date: Jul 2007
Location: Orem, UT
Posts: 65
Downloads: 79
Uploads: 0
Thanks: 40
Thanked 21 Times in 17 Posts
Rep Power: 229
Jeff Nordgren is just really niceJeff Nordgren is just really niceJeff Nordgren is just really niceJeff Nordgren is just really nice
Default

Quote:
Originally Posted by Sung Kim View Post
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?

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
Reply With Quote
  #4  
Old 04-01-2008
Brandon Peterson's Avatar
Brandon Peterson Brandon Peterson is offline
The Flexsim Consultant
 
Join Date: Jul 2007
Location: Salt Lake City, Utah
Posts: 382
Downloads: 29
Uploads: 6
Thanks: 192
Thanked 516 Times in 235 Posts
Rep Power: 486
Brandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant futureBrandon Peterson has a brilliant future
Default

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.
Reply With Quote
  #5  
Old 04-01-2008
Anthony Johnson's Avatar
Anthony Johnson Anthony Johnson is offline
Manager of Product Development
 
Join Date: Jul 2007
Posts: 440
Downloads: 86
Uploads: 4
Thanks: 171
Thanked 899 Times in 288 Posts
Rep Power: 731
Anthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond repute
Default

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.
Reply With Quote
  #6  
Old 04-17-2008
Regan Blackett Regan Blackett is offline
Flexsim Consultant, Forum Moderator
 
Join Date: Jul 2007
Posts: 14
Downloads: 19
Uploads: 16
Thanks: 0
Thanked 14 Times in 6 Posts
Rep Power: 179
Regan Blackett will become famous soon enoughRegan Blackett will become famous soon enough
Default

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();
Under Vista, this would be fine, since it'll give the proper trailing slash, so the result would read: "C:\Program Files\Flexsim4\userprojects\myfile". However under XP, the result would read "C:\Program Files\Flexsim4\userprojectsmyfile". If you're using XP, you would have to add the slash yourself as follows

Code:
string path = concat(modeldir(),"\\myfile");
pt(path);pr();
Note the double slash since a single slash is an "escape" character. It'd probably be a good rule of thumb to just do things the XP way to avoid any confusion, since any extra slashes in the path string will be ignored.

Last edited by Regan Blackett; 04-17-2008 at 10:25 AM.
Reply With Quote
The Following User Says Thank You to Regan Blackett For This Useful Post:
Jörg Vogel (08-01-2014)
  #7  
Old 04-17-2008
Lars-Olof Leven Lars-Olof Leven is offline
Flexsim Distributor
 
Join Date: Aug 2007
Location: Sweden, Borlnge
Posts: 312
Downloads: 278
Uploads: 2
Thanks: 300
Thanked 256 Times in 139 Posts
Rep Power: 326
Lars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to behold
Default

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
Reply With Quote
  #8  
Old 04-17-2008
Regan Blackett Regan Blackett is offline
Flexsim Consultant, Forum Moderator
 
Join Date: Jul 2007
Posts: 14
Downloads: 19
Uploads: 16
Thanks: 0
Thanked 14 Times in 6 Posts
Rep Power: 179
Regan Blackett will become famous soon enoughRegan Blackett will become famous soon enough
Default

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.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -6. The time now is 03:43 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.