Notifications
Clear all

[Closed] 3DSMax open file for read and file path

Hi

I am a maya user but recently need to write a small script in 3dsmax to boost my workflow.

In Maya, I output a to a file with name like this example.txt with path: C:\example.txt

Data in this file a path to a file that is written from Maya, like this

Z:/dataserver/lajesh/FBX_file/model.fbx

so my question.

  1. How to get data from this file into a variable of max script
  2. Then import model.fbx to 3dsmax. As the moment, I see that the “/” is not supported from 3dsmax, so any chance to force 3dsmax import a path file with “/” format, or it must be “”

Thanks for any help

3 Replies
	  -- to open a .txt file from a window and store each line in a variable
 	  fName = getOpenFileName types:"Blah Blah (*.txt)|*.txt|"	 
 	  txtFile = openFile fName mode:"r"
 		   while not (eof txtFile) do
 			(
 			 tmp = readline txtFile
 			 ...
 			 ...
 			)
 
 	  -- to find the directory of a .bmp file in maxroot  + "UI/Icons" path
 	  (getdir #maxroot+"UI\Icons\myIconFile.bmp")

Look at: [color=white]How To … Output Geometry Data To Text File
[/color]
at the reference file

Actually, both “/” and “” are supported by MAXScript in file names (although Windows does not support / in general, MAXScript does). You can either use / or, if entering your own path, enter “\”. But when reading single backslashes from a text file, you do NOT have to do anything special.

If c:\example.txt is where the FBX path is, you can say

(
theFileHandle = openFile "c:\\example.txt" --open the file for reading
theLine = readLine theFileHandle --reads first line, assuming that's where the path is
close theFileHandle --close the file
if doesFileExist theLine do importFile theLine #noPrompt --if the FBX exists, import it silently
)

If you have to set up the FBX Import settings before importing, take a look at the “FBX Import Dialog Access” topic in the MAXScript Reference which shows how to do that.

Thanks alot,