[Closed] startup script not evaluated?
I’ve written a macroscript which works fine if evaluated manually (Evaluate All… or ctrl + e in the maxscript editor). This very same script generates errors when put in max’s UI/macroscript folder or startup folder for an automatic evaulation at startup. I think some rollouts, variables or arrays are not set or are out of scope. Seems like the script is only partially evaluated or not evaluated in the same way as when done manually? When I manually evalute the script (in the same max session after an error) everything works fine again…
The script is large and messy, but i’ll leave part of it here:
macroScript viseno_tools category:“Viseno” tooltip:“Viseno Pipeline Tools”
(
on execute do
(
global true_ambient_color_value = ambientColor.value
global new_si_value = 100 * true_ambient_color_value / 255
global reset_si_value = 100
global new_light_value = new_si_value / 100
global new_ambient_color = [0,0,0]
global scene_lights = lights
global reset_scene_lights = #()
global reset_self_illumination = #()
global multi_sub_check_value = true
global blinn_check_value = true
global shadows_check_value = true
global lights_shadow_check_value = true
global lights_check_value = true
global total_error_array = #()
global fn_mat_check
global fn_shadow_check
global fn_lights_check
global fn_scene_materials
global fn_export_camera
global fn_render_preview
global fn_apply_bake
global fn_set_mental_ray
global fn_display_errors
global fn_select_errors
global fn_test
————————FUNCTIONS——————————–
fn fn_display_errors error_msg error_nodes= (
global checkbox_status = #()
global error_nodes = error_nodes
errorFloater = newRolloutFloater “Check Scene Results” 500 500
str = “rollout error_rollout “Potential problems found:” (
“
str += “group “Potential Problems” (
“
for i = 1 to error_nodes.count do
(
node_name = error_nodes[i].name
label_name = node_name + i as string
checkbox_name = i as string
str += “label” + ” ” + label_name + ” ” + ““Node name: ” + node_name + “”” + ” ” + “align:#left across:2
“
str += “checkbox checkbox_” + checkbox_name + ” ” + “””” + ” ” + “checked:true align:#right
“
checkbox_status[i] = true
for j = (i-1)*10+1 to (i-1)*10+9 do
(
node_name = error_nodes[i].name
if total_error_array[j] != undefined do
(
label_name = “label” + i as string + j as string
current_errormsg = total_error_array[j] as string
str += “label” + ” ” + label_name + ” ” + “”” + current_errormsg + “”” + ” ” + “align:#left
“
)
)
str += “label” + ” ” + label_name + “end” + ” ” + “”————-“” + ” ” + “align:#left
“
)
str += “)
” –end group Potential Problems
for i = 1 to error_nodes.count do
(
checkbox_nr = i as string
str += “on checkbox” + checkbox_nr + ” ” + “changed theChange do checkbox_status[” + checkbox_nr +”] = theChange
“
)
str += “group “Select Tools” (
“
str += “checkbox isolate “Isolate Selection” offset:[290,0] across:2
“
str += “button select_button “Select” offset:[0,-5]align:#right
“
str += “)
“–end group Select Tools
str += “on select_button pressed do (fn_select_errors error_nodes checkbox_status isolate.state )
“
str += “)
“–end rolloutout error_rollout
str += “addRollout” + ” ” + “error_rollout” + ” ” + “errorFloater”
execute str
addRollout error_rollout errorFloater
)–end fn_display_errors
…etc…
PART OF ERROR REPORT
[color=white]– Frame:
– error_nodes: #()
– errorFloater: <RolloutFloater:0x000028cc>
– str: “rollout error_rollout “Potential problems found:” (
group “Potential Problems” (
)
group “Select Tools” (
checkbox isolate “Isolate Selection” offset:[290,0] across:2
button select_button “Select” offset:[0,-5]align:#right
)
on select_button pressed do (fn_select_errors error_nodes checkbox_status isolate.state )
)
addRollout error_rollout errorFloater”
– error_rollout: undefined
– error_msg: #()
[/color]– called in fn_scene_materials(); filename: C:\Program Files\Autodesk\3dsMax8\UI\MacroScripts\Viseno_Toolkit3.mcr; position: 5747
[color=white]– Frame:
– error_found: false
– current_selection: #()
– total_error_nodes: #()
[/color]– called in check_scene.pressed(); filename: C:\Program Files\Autodesk\3dsMax8\UI\MacroScripts\Viseno_Toolkit3.mcr; position: 14517
– Frame:
– blin_check_value: undefined
– current_selection: undefined
>> MAXScript Rollout Handler Exception: – Type error: addRollout requires RolloutFloater, got: undefined <<
- Restart max and try to run it again. If it doesn’t work, then it’s because some arrays are not set just like you say.
- It’s also a Macroscript. This is not the way I would do it myself. Do a “normal” script instead.
So just a zzz.ms file with the code in it. This should work fine when you have it in the startup folder.
I think Macroscripts should only be used for shortcuts, but they should not have the code itself.
Hope that helps
/Andreas