编程笔记

lifelong learning & practice makes perfect

maxscript|基础

file/文件系统

dir/文件夹/目录

创建文件夹

makeDir all:

1
2
-- 传true将路径上所有子目录都会自动创建
makeDir @"c:\temp\test\deleteme\if\you\can" all:true

删除目录

maxscript 2014,2015没有提供内置函数删除目录,需要调用.net类或者外部命令删除,下面的案例使用rmDir命令删除

HiddenDOSCommand [ startpath:unsupplied] [ prompt:unsupplied] [ donotwait:false] [ ExitCode:&variable]

1
2
3
4
5
6
makeDir "C:\\doscmdtest\\"
str = "rmDir C:\\doscmdtest\\"
hiddendoscommand str startpath:"$max" exitCode:&exitcode
exitcode --> 0
hiddendoscommand str startpath:"$max" exitCode:&exitcode
exitcode --> 2 (error since directory does not exist anymore)

File Name Parsing/获取文件名,路径

filenameFromPath

filenameFromPath

返回文件名(包含后缀)

1
2
file="g:\\subdir1\\subdir2\\myImage.jpg"
filenameFromPath file -- returns: "myImage.jpg"
getFilenamePath

getFilenamePath

1
2


参考:

UI

1
2
3
4
5
6
7
8
9
10
11
12
-- 按钮,点击按钮弹窗展示一张图片
-- layout是弹出窗口的布局,只有一张图片

rollout layout "示例图"
(
bitmap bmp fileName: ("img\\example.png")
)
button displayImg "查看示例图" across:1 offset:[0,0] align:#center width:100 height:35
on displayImg pressed do
(
createDialog layout 1920 1080
)

欢迎关注我的其它发布渠道