我已经开始学习Maxscript了,现在我遇到了困难,如果是单个对象并且如果它超过1,则让标签将对象的数量显示为字符串。
但我总是犯错误。。。知道吗?
group "Current Selection:"
(
label lbl_01 "Nothing Selected"
)
---------------------------------------------------------------------------------------------------------------//电流选择功能
fn letmeknow obj=
(
local contador = (selection.count as string)
if selection.count != 0 then
(
lbl_01.text = ("Name: " + obj.name)
)
else
(
lbl_01.text = "Nothing Selected"
)
if selection.count >= 2 do (lbl_01.text = ("Objects: " + contador))
)
问题似乎不在您提供的代码范围内,如果看不到代码的其余部分,很难判断。无论如何,这里有一个使用case表达式而不是多个if的工作示例:
rollout test "Test"
(
group "Current Selection:"
(
label lbl_01 "Nothing Selected"
)
button btnTest "Test"
fn getSelectionString =
(
case selection.count of
(
0 : "Nothing Selected"
1 : "Name: " + selection[1].name
default : "Objects: " + selection.count as string
)
)
on btnTest pressed do
lbl_01.text = getSelectionString()
)
createDialog test