关于 MAXScript 逐行写入文本

官方帮助文档FileStream Values部分有相关介绍.

fn format_txt filepath filetext =

(

    if doesFileExist filepath == true 

        then

    (

        fin = openfile filepath mode:"r+"

        seek fin #eof

        txt = filetext + "\n"

        format txt to:fin

        close fin

    )

    else

    (

        newfile = createFile filepath

        close newfile

        format_txt filepath filetext

        )

    )  -- 逐行写入文本

format_txt "C:\Users\Administrator\Desktop\2.txt" "你好MAXScript"

每次都会在文档结尾处写入,如果文件不存在则自动创建.

你可能感兴趣的:(script)