2012年2月7日 星期二

MAXscript : 控制外部文件

MAXscript 控制外部文件的函數 (適用於max檔案及非max檔案)


getFiles "wild_card_filename_string"
Returns an array of file names that match the given wild-card path name. The following example gets an array of all the .max scene files in c:\foo and then loops over the array, opening each file and printing the objects in each:
files = getFiles "c:\\foo\\*.max"
for f in files do (loadMAXFile f; print objects)
getFiles() can also be used to determine if a file exists.


getDirectories "wild_card_directory_name_string"
Returns an array of directory paths that match the given wild-card directory path name.


makeDir "directorypath_string" all:
Return false on failure (either because the path could not be created or because the path already existed).


deleteFile "filename_string"
Fails if the file is open in MAXScript.


renameFile "old_filename_string" "new_filename_string"
Renames the old file to the new file. This can also be used to move a file between directories. Fails if new file already exists or if the old file is open in MAXScript. Returns true on success, false on failure.


copyFile "existing_filename_string" "new_filename_string"
Copies the existing file to the new file. Fails if the new file already exists, the new file cannot be created, or the existing file is open in MAXScript. Returns true on success, false on failure.


getFileSize "filename_string"
Returns the size of the specified file in bytes. Returns 0 if the file could not be found.


getFileAttribute "filename_string" "attribute"
setFileAttribute "filename_string" "attribute"
The valid values are:
#readOnly #hidden #system #directory #archive #temporary #normal


getFileModDate "filename_string"
getFileCreateDate "filename_string"


getFileVersion "filename_string"
This data is typically specified only for executable and application extension (i.e., .dll) files.


FileStream Values


createFile


openFile [ mode: ]


close filepath


Standard Open and Save File Dialogs


getOpenFileName
getSaveFileName
Both functions return a fully-specified file path name or undefined if the user cancels out.
When the optional keyword filename: is supplied, the string is used to define the path and file name of the file to be loaded or saved. The dialog automatically navigates to the specified path (if available on the disk/network), displays its content in the browsing area and suggests the file name in the "File name" field. If the path does not exist, the current path is used and only the file name is displayed as requested.

getMAXFileObjectNames
傳回該檔案內物件的字串陣列


checkForSave()
儲存確認視窗


shellLaunch "notepad.exe" filepath
執行外部程式 eg. Notepad


File Name Parsing 檔名的解析
filenameFromPath "filename_string"
從完整的檔案路徑中擷取檔名(包含副檔名)


getFilenamePath " filename_string "
getFilenameFile " filename_string "
getFilenameType " filename_string "
從完整的檔案路徑中獲得目錄路徑、檔案檔名(不含副檔名)、副檔名


doesFileExist " filename_string "
return True or False

沒有留言:

張貼留言