AREA forums upgrade
Read more about the planned upgrade of our forums
  • 1/3
You are here: Forum Home / Autodesk 3ds® Max® / MaxScript / Getting a floater to open another floater
IMPORTANT ANNOUNCEMENT ABOUT AREA FORUMS
  RSS 2.0 ATOM  

Getting a floater to open another floater
Rate this thread
 
21368
 
Permlink of this thread  
avatar
  • Location: Quebec City, QC -- Canada
  • Total Posts: 53
  • Joined: 28 August 2006 10:51 PM

Is there a way to get an open floater to open another floater (on a button pressed action)?

I keep getting a compile error with I simply have:

on sets_export_sets_button pressed do
(
createDialog modal_collada_rollout modal:true
) --end if want to export

I get “No outer local variable references permitted here: modal_collada_rollout “

===================

I searched the all-knowing-and-seeing internet and came up with this:

-- create several rollouts , save them in a dir .eg:
-- rollout xxx1 “xxx1” (button lanhaibo “lanhaibo1” )
-- rollout xxx2 “xxx2” (button lanhaibo “lanhaibo2” )
-- rollout xxx3 “xxx3” (button lanhaibo “lanhaibo3” )
--....
-- then save them as d:\test\test_1.ms .... test_2.ms .... test_3.ms

-- below is the new script to collect the old ones into a newRolloutFloater.
theOldRollouts = getfiles “d:\\test\\*.ms”—collect old rollouts .
for i in theOldRollouts do filein i—filein them .
newFloater = newRolloutFloater “collect old rollouts “ 200 400—create a new container.
addrollout xxx1 newfloater
addrollout xxx2 newfloater
addrollout xxx3 newfloater
--…

this came via : http://forums.cgsociety.org/showthread.php?t=413386

=====================

so then I took my rollout definition out to another file as the instructions say and changed my code accordingly to this:

----------------------------------------------------------------------

global bhg_xporterDials = #("$max\\scripts\\bhg_collada_shell.ms")—declare location of external dialogs

for d in bhg_xporterDials do
(
filein d
)

function add_collada_exporter =
(
ColladaFloater = newRolloutFloater “Collada Options” 552 232
addrollout modal_collada_rollout ColladaFloater

)—end add_collada_exporter function

AND LOWER DOWN THE FILE:

on sets_export_sets_button pressed do
(
add_collada_exporter()
) --end if want to export

================================================

To which I get this error now: “No outer local variable references permitted here: add_collada_exporter”

I basically have a scripted utility that launches a floater, this floater needs to launch other modal floaters.

MB



Replies: 0
avatar

It sounds like you mean this:
-------

rollout rollone “One”
(
button buttwo “Press for floater 2”
button butthree “Press for floater 3”

on buttwo pressed do
(
createDialog rolltwo 100 100 100 100 modal:true
)
on butthree pressed do
(
createDialog rollthree 100 100 200 200 modal:true
)
)
rollout rollTwo “Two”
(
)
rollout rollThree “Three”
(
)
createDialog rollone 450 400 10 10

------
Have I got the wrong end of the stick?



Replies: 0
avatar
  • Location: Quebec City, QC -- Canada
  • Total Posts: 53
  • Joined: 28 August 2006 10:51 PM
  • Permlink of this post

The problem is, this does not work WITHIN A SCRIPTED UTILITY.

Which is what I need to do.

:(

MB



Replies: 0
avatar

Remove any code you don’t want to show us and post the WHOLE utility with all rollout definitions so we can see what you are doing.
Obviously you have some scope issues, but it is difficult to fix without seeing what the scopes are. When in doubt, pre-declare any variables you are using in a higher scope.

Here is a simple example of a utility and a cascade of three dialogs:

(--# start local scope
--# Pre-declare all rollouts to be defined later as local 
--# This will make them visible to any code in lower scopes.
--# Alternatively, declare them as global (if you want to see them from outside code
--# Or if you are going to fileIn() their definitions from external .MS files    
local myTestRollout01myTestRollout02myTestRollout03

--# Now define all rollouts. Here I have a cascade of 3 dialogs, each modal.    
rollout myTestRollout01 "Rollout 01"
(
    
button btn_openDialog "Open Dialog 2"
    
on btn_openDialog pressed do
        
createDialog myTestRollout02 100 30 110 150 modal:true
)

rollout myTestRollout02 "Rollout 02"
(
    
button btn_openDialog "Open Dialog 3"
    
on btn_openDialog pressed do
        
createDialog myTestRollout03 100 30 120 200 modal:true
)

--
# Last rollout has a button calling a function in the parent utility to close them all
rollout myTestRollout03 "Rollout 03"
(
    
button btn_closeDialogs "Close All Dialogs"
    
on btn_closeDialogs pressed do testRollouts.closeAllDialogs()
)

--
# And this is the parent utility which opens the first dialog
--# and contains the function for closing them all.
utility testRollouts "Test Rollouts"
(
    
button btn_openDialog "Open Dialog 1" width:120 align:#center
    
    
fn createModalDialog =
    (
        
createDialog myTestRollout01 100 30 100 100 modal:true
    
)
    
fn closeAllDialogs =
    (
        try(
destroyDialog myTestRollout01)catch()
        try(
destroyDialog myTestRollout02)catch()
        try(
destroyDialog myTestRollout03)catch()
    )
    
on btn_openDialog pressed do createModalDialog()
)

)--
# end local scope


Borislav “Bobo” Petrov

Replies: 0
avatar
  • Location: Quebec City, QC -- Canada
  • Total Posts: 53
  • Joined: 28 August 2006 10:51 PM
  • Permlink of this post

Thanks Bobo,

Ok, here is what’s going on, I took your code, verbatim, and saved it as “Bobo_floater.ms”

Then I wrote a utility (posted here) and saved said utility to scripts\startup:

utility test_util "Test Util"
    
(
    
rollout test_rollout "Test Rollout" category:1
        
( -- begin rollout "test"
        
button but_test "Launch Floaters"
        
on but_test pressed do
            ( --
begin but_test
            
include "bobo_floater.ms"
            
) -- end but_test
        
) -- end rollout "test"

    
on test_util open do
        (
        
addRollout test_rollout
        

    
    ) -- 
end utility

When max launches I get the all familiar error:
-- Compile error: No outer local variable references permitted here: myTestRollout02
-- In line: createDialog myTestRollout02 1

changing the scope (to global) of the floater variables fixed the evaluation error. But nothing happens when I press the button “but_test”

so, I went ahead and played a bit with your code, to see if I could get it to work, and ended up with this:

(--# start local scope
--# Pre-declare all rollouts to be defined later as local 
--# This will make them visible to any code in lower scopes.
--# Alternatively, declare them as global (if you want to see them from outside code
--# Or if you are going to fileIn() their definitions from external .MS files    
global myTestRollout01myTestRollout02myTestRollout03Bobo_test

--# Now define all rollouts. Here I have a cascade of 3 dialogs, each modal.    
rollout myTestRollout01 "Rollout 01"
(
    
button btn_openDialog "Open Dialog 2"
    
on btn_openDialog pressed do
        
createDialog myTestRollout02 100 30 110 150 modal:true
)

rollout myTestRollout02 "Rollout 02"
(
    
button btn_openDialog "Open Dialog 3"
    
on btn_openDialog pressed do
        
createDialog myTestRollout03 100 30 120 200 modal:true
)

--
# Last rollout has a button calling a function in the parent utility to close them all
rollout myTestRollout03 "Rollout 03"
(
    
button btn_closeDialogs "Close All Dialogs"
    
on btn_closeDialogs pressed do testRollouts.closeAllDialogs()
)

--
# And this is the parent utility which opens the first dialog
--# and contains the function for closing them all.
-- utility testRollouts "Test Rollouts"
--(
  --  
button btn_openDialog "Open Dialog 1" width:120 align:#center
    
    
fn createModalDialog =
    (
        
createDialog myTestRollout01 100 30 100 100 modal:true
    
)
    
fn closeAllDialogs =
    (
        try(
destroyDialog myTestRollout01)catch()
        try(
destroyDialog myTestRollout02)catch()
        try(
destroyDialog myTestRollout03)catch()
    )
    --
on btn_openDialog pressed do createModalDialog()
    
    
Bobo_test newRolloutFloater "Bobo Test" 100 30 100 100
    addRollout myTestRollout01 Bobo_test
    
--)

)--
# end local scope

This works wonderfully, so thank you so much for your help! it all stemmed from the fact that I did not know that I could make a floater declaration global by declaring an empty variable first.

Also, not that this is dire, but in the mess that I just made of your code, the close function no longer works.

Thank you so much

MB



Replies: 0
avatar
  • Location: Quebec City, QC -- Canada
  • Total Posts: 53
  • Joined: 28 August 2006 10:51 PM
  • Permlink of this post

Darned globals again!!

global closeAllDialogs

and this:

on btn_closeDialogs pressed do closeAllDialogs()

make it work!

Thank you so much!

MB



Replies: 0