2017-06-10 2 views
0

Je suis en train de créer une interface utilisateur graphique pour ce script, mais chaque fois que je frappe « créer » bouton, il me donne l'erreur "Unable to convert: undefined to type: Float" à front_shape.pos=[0,canopy_width,0] sur la ligne 20.Maxscript Script dans Rollout donne erreur

Le script fonctionne très bien sans déploiement donc je suppose que cela a quelque chose à voir avec la portée de la variable. Je ne sais pas grand-chose à propos de maxscript, toute aide sera appréciée.Thankyou.

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 

Répondre

0

C'est parce que vous êtes à certaines variables se référant à front_posts qui ne font pas partie du champ d'application de la fonction.

Transmettez les variables nécessaires à la fonction front_posts et appelez-la en conséquence.

 

    (...) 

    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" 
     ) 
    )