Скрипт Maxscript в Rollout выдает ошибку

Я пытаюсь создать графический интерфейс для этого скрипта, но каждый раз, когда я нажимаю кнопку «Создать», появляется ошибка "Unable to convert: undefined to type: Float" в front_shape.pos=[0,canopy_width,0] в строке 20.

Сценарий работает нормально без развертывания, поэтому я предполагаю, что это как-то связано с областью действия переменной. Я мало что знаю о maxscript, буду признателен за любую помощь. Спасибо.

theGroup= #()
try(closerolloutfloater MainFloater)catch()
fn posts_pads gap pos post_count=
(   post_pad=ChamferCyl radius:90 height:1200 Fillet:20 Fillet_Segments:10 sides:18
    addModifier post_pad (materialModifier materialID:2 )
    append theGroup post_pad
    post_pad.pos=[0,pos,0]
    for i=1 to post_count-1 do
    (
        post_pad_instance= instance post_pad
        append theGroup post_pad_instance
        post_pad_instance.pos=[i*gap,pos,0]
    )
)

fn front_posts=
(   
    front_shape=Rectangle length:80 width:80
    append theGroup front_shape
    front_shape.pos=[0,canopy_width,0]
    if canopy_width<=4000 then(
        post_gap=3500.0
        )
    else(
        post_gap=3000.0
        )
    front_post_count=ceil(canopy_length/post_gap)+1
    front_post_gap= ((canopy_length/1000.0)/(front_post_count-1))*1000
    for i=1 to front_post_count-1 do
    (   

        post_instance=instance front_shape
        append theGroup post_instance
        post_instance.pos=[i*front_post_gap,canopy_width,0]

    )
    post=select front_shape
    ex= Extrude()
    my_post=$
    addmodifier my_post ex
    my_post.modifiers[#Extrude].amount =  (front_height+40)
    addModifier front_shape (materialModifier materialID:1 )
    posts_pads front_post_gap canopy_width front_post_count
)



Rollout Menu "Sample Canopy" width:200 height:64
(
    Spinner len "Canopy Length" range:[2000, 20000, 2000]
    Spinner width "Canopy Width" range:[1500, 6000,1500 ]
    Spinner height "Front Height" range:[1800, 4000, 1800]
    Spinner b_height "Back Height" range:[2000, 6000, 2000]


    button create "Create" pos:[55,120] width:80 height:20
    on create pressed do
    (   
        canopy_length=len.value
        canopy_width=width.value
        front_height=height.value
        back_height=b_height.value

        max create mode
        with redraw off
        (   
            front_posts()
            $.name= uniquename "Sample canopy"
            obj = getCurrentSelection()
            tempLib = loadTempMaterialLibrary "H:\script\sample.mat"
            mat= tempLib[1]
            obj.material = mat
        )
        closerolloutfloater MainFloater
        actionMan.executeAction 0 "310" 
    )
)


MainFloater= NewRolloutFloater ""   200 200
addRollout Menu MainFloater

person Amit Singh    schedule 10.06.2017    source источник


Ответы (1)


Это потому, что вы ссылаетесь на некоторые переменные infront_posts, которые не являются частью области действия функции.

Передайте необходимые переменные функции front_posts и вызовите ее соответствующим образом.


   (...)

    fn front_posts canopy_length canopy_width front_height = ...
    Rollout Menu "Sample Canopy" width:200 height:64
    (
        Spinner spn_cnpy_len "Canopy Length" range:[2000, 20000, 2000]
        Spinner spn_cnpy_wid "Canopy Width" range:[1500, 6000,1500 ]
        Spinner spn_front_height "Front Height" range:[1800, 4000, 1800]
        Spinner spn_back_height "Back Height" range:[2000, 6000, 2000]

        button create "Create" pos:[55,120] width:80 height:20

        on create pressed do
        (   

            max create mode
            with redraw off
            (   
                front_posts (spn_cnpy_len.value) (spn_cnpy_wid.value) (spn_front_height.value) (spn_back_height.value)
                (...)
            )
            closerolloutfloater MainFloater
            actionMan.executeAction 0 "310" 
        )
    )

person Benjamin Fichet    schedule 13.06.2017