多个If表达式的MAXSCRIPT错误

时间:2016-07-27 05:14:48

标签: max maxscript

我已经开始学习Maxscripts,而且我现在已经碰壁了, 我试图得到我的选择的名称,如果它是一个单一的对象和 然后如果它超过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))
)   

1 个答案:

答案 0 :(得分:0)

看起来这个问题超出了您提供的代码范围,而且没有看到其他代码,这很难说。无论如何,这是一个使用case表达式而不是多个ifs的工作示例:

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