[Closed] Test and prompt dir for import file
Hi guys,
I have what is probably a simple problem that I just cant get my head around.
I’m trying to import a specific fbx file into an existing scene via a button press.
My script is working just fine providing the file is located in the max/imports folder
The problem occurs when the file isn’t there.
I want to test for the file, and throw a prompt asking the user to locate the file if its missing.
Would anyone be kind enough to give me hand?
Thanks.
I’ve got this up and running. Thoughts?
It still borks out if the user cant find the file
importFile “filetoimport.fbx” #noPrompt using:FBXIMP – if only this returned a bool
try
(
select $objectinfbxfile – This object is the one I’m importing
)
catch
(
messagebox “Please find the file, filetoimport.fbx”
path = getOpenFileName caption:“Select filetoimport.fbx”
types:“FBX(.FBX)|.fbx*|” filename: “.\import\filetoimport.fbx”
importFile (path) #noPrompt using:FBXIMP
)
oops looks like the above import does return a bool
I now have.
if importFile "filetoimport.fbx" #noPrompt using:FBXIMP == false then
(
messagebox "Please locate filetoimport.fbx"
path = getOpenFileName caption:"Select filetoimport.fbx" \
types:"FBX(*.FBX)|*.fbx*|" filename: ".\import\filetoimport.fbx"
importFile (path) #noPrompt using:FBXIMP
)
instead of trying to import you can check the file existence first. (doesfileexist …) . To call this function you have to create full path (probably using default #import directory as path name).