PDA

View Full Version : relative folder paths


Pongoloid!
02-08-2006, 02:06 AM
I have a project folder that contains a "scenes" folder and a "meshes" folder. I'm trying to write a script that will let me save a node from a file in the scenes folder to a new max file in the meshes folder. My problem is I can't figure out how to tell it to save to a folder that is a level above the current folder. I can't use the absolute file path becuase this will have to work from multiple project folders. Any help would be appreciated.

Bobo
02-08-2006, 03:46 AM
I have a project folder that contains a "scenes" folder and a "meshes" folder. I'm trying to write a script that will let me save a node from a file in the scenes folder to a new max file in the meshes folder. My problem is I can't figure out how to tell it to save to a folder that is a level above the current folder. I can't use the absolute file path becuase this will have to work from multiple project folders. Any help would be appreciated.

You can parse the path and replace the string yourself.
Assuming the string to replace exists just once in the path name, you could say

fn switchPath thePath oldString newString =
(
theIndex = findString thePath oldString
if theIndex != undefined then
thePath = replace thePath theIndex oldString.count newString
thePath
)

switchPath (getDir #export) "meshes" "scenes"


Since the above condition cannot be guaranteed, you could parse the path yourself and replace the last sub-directory instead.

fn removeLastDir thePath =
(
theFS = filterString thePath "\\"
theNewPath = ""
for i = 1 to theFS.count-1 do theNewPath += theFS[i] + "\\"
theNewPath
)

(removeLastDir (getDir #export)) + "scenes"

galagast
02-08-2006, 04:54 AM
Hi, this may also work, but its not very UI friendly (i think)

the_file = (getdir #maxroot) + "\.." + "/myfile.txt"
createfile the_file

the script will create a "myfile.txt" to whatever drive the 3dsmax folder is located.

Pongoloid!
02-08-2006, 10:48 PM
Thanks for all the help guys! I got it working now.

CGTalk Moderation
02-08-2006, 10:48 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.