PDA

View Full Version : DRToggle-Toolbar, and an issue with unRegisterDialogBar?


Vsai
03-20-2009, 08:34 PM
So I've got what I figured was a simple script..

A toolbar with 2 checkbuttons, one for the status of vray DR, one for the status of Autosave. simple enough, see below. problem is i can't seem to get it to unRegisterDialogBar at any point so that i can destroy the dialog before recreating it. is there some magic syntax that i'm missing?


(
--needs to be global for the callback to be usable?!
global g_roll_CheckDRSave

rollout g_roll_CheckDRSave "Toggles" width:100
(
checkbutton CheckDR "DR" width:30 pos:[2,2]
checkbutton CheckAsave "ASave" pos:[34,2]

fn updateChkButtons =
(
CheckAsave.checked = autosave.enable
if (matchpattern (renderers.current as string) pattern:"*V_Ray*") then (
CheckDR.enabled = true
CheckDR.checked = renderers.current.system_distributedRender
)else CheckDR.enabled = false
)

on g_roll_CheckDRSave open do updateChkButtons()
on CheckDR changed val do renderers.current.system_distributedRender = CheckDR.checked
on CheckAsave changed val do autosave.enable = CheckAsave.checked

timer timerCheckDR active:true interval:250
on timerCheckDR tick do updateChkButtons()

--autosave.Interval


)

callbacks.removeScripts id:#UpdateDRToolbar
callbacks.addScript #postRendererChange "try(g_roll_CheckDRSave.updateChkButtons())catch(print \"fail while updating the DRToolbar\")" id:#UpdateDRToolbar

try(cui.FloatDialogBar g_roll_CheckDRSave)catch()
try(cui.unRegisterDialogBar g_roll_CheckDRSave)catch()
try(DestroyDialog g_roll_CheckDRSave)catch()
CreateDialog g_roll_CheckDRSave
cui.RegisterDialogBar g_roll_CheckDRSave style:#(#cui_dock_horz,#cui_floatable,#cui_handles)
cui.DockDialogBar g_roll_CheckDRSave #cui_dock_top

)

ZeBoxx2
03-20-2009, 09:26 PM
Try unregistering/destroying any dialogs -before- you re-define the rollout from which they'r made. Once you have redefined the rollout, any previous definition is no longer accessible.

I.e.
rollout test "test" ( ) -- first definition
createDialog test -- rollout from first definition
rollout test "test 2" ( ) -- second definition, the first one is now inaccessible
destroyDialog test -- destroys second definition only

Vsai
03-20-2009, 09:47 PM
Doh! Thanks.

CGTalk Moderation
03-20-2009, 09:47 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.