How to kill all objects including Gizmo 3D plots at once

Hi all, 

I was wondering how I can kill Gizmo objects in an Igor pro experiment. What I need to do is to kill ALL objects at once in an Igor experiment to initiate a new run. I got the following code section from the wavemetrics which works well for killing all the objects when the experiment does not contain any Gizmo object. If the experiment contains a Gizmo object, it can not kill the wave which is being used by the Gizmo and immediately throws up a bug. Any suggestions will be much appreciated.

Thanks,

Ann

//_____________________________________________________________________________________________________________________________________
// KillOrHideAnyWindow
//________________________________
// 'KillOrHideAnyWindow' kills any graphs, tables, layouts, notebook, panel or XOP window and then kill all the waves
//  Parameters:
//        -winMask:     bitmask of window types to kill
//                       - 0x0 kill everything possible
//                       - 0x01 graphs
//                       - 0x02 tables
//                       - 0x04 layouts
//                       - 0x10 notebooks
//                       - 0x40 panels
//                       - 0x1000 XOP target windows
//______________________________________________________________________________________________________________________________________                      
   
// Code for killing all objects
   
Function KillOrHideAnyWindow(  ) // from wavemetrics
    Variable winMask
    Variable i, n
    Variable all = 0x1000+0x40+0x10+0x4+0x2+0x1
    string theWins
   
    winMask = !winMask ? all : winMask
   
    theWins = winList("*", ";", "WIN:"+num2str(winMask & all))
    for(i=0, n=itemsInList(theWins,";"); i<n; i++)
        DoWindow/K $stringFromList(i, theWins, ";")
    endfor
End
   

  

The code you posted selects the type of window which is killed, and the variable 'all' does not contain Gizmo windows. If you simply want to kill all and every window, then run this function without the WIN option, i.e.:

Function KillOrHideAnyWindow()
    Variable i, n
    String theWins = winList("*", ";", "")
    for(i=0, n=itemsInList(theWins,";"); i<n; i++)
        DoWindow/K $stringFromList(i, theWins, ";")
    endfor
End
   

If you only want to extend the code to Gizmo windows, then simply add the parameter for Gizmo windows to 'all' (this only works in Igor 7 or later):

Variable all = 0x10000+0x1000+0x40+0x10+0x4+0x2+0x1

Thanks a lot! 

One thing I noticed is that if I execute 

Function KillOrHideAnyWindow()
    Variable i, n
    String theWins = winList("*", ";", "")
    for(i=0, n=itemsInList(theWins,";"); i<n; i++)
        DoWindow/K $stringFromList(i, theWins, ";")
    endfor
End
 

it spits an error and the deugger says "error: names must start with a letter and contain letters, digits or '_'". But if I just simply replace "Variable all = 0x1000+0x40+0x10+0x4+0x2+0x1" in my code section with "Variable all = 0x10000+0x1000+0x40+0x10+0x4+0x2+0x1", the execution does not show any error. 

This probably means that there is a non-standard name in one of the additional windows you are closing with the more general function. If you are curious you can check the remaining items via ...

print RemoveFromList(winList("*", ";", "WIN:"+num2str(0x10000+0x1000+0x40+0x10+0x4+0x2+0x1)), winList("*", ";", ""))