|
From: Aaron M. <mav...@gm...> - 2011-08-29 19:44:33
|
On Thu, Aug 25, 2011 at 8:04 AM, Ben Axelrod <be...@be...> wrote:
> 1. is there a way to delete all objects in the scene? i don't see a
> scene.clear() type of function.
The visual.ui.display object (by default, the active one is
visual.scene) maintains a tuple with references to all visible objects
called (oddly enough) 'objects'. You can clear the scene by making
them all invisible.
for obj in visual.scene.objects:
obj.visible = False
If there are no external references to the objects, since 'objects'
only refers to *visible* objects, this will also (I think) remove the
last reference and the objects will be GC'd by Python, so this
shouldn't be leaky.
> 2. is there a way to programatically close the visual python window?
The visual.ui.display object has a 'visible' property also; setting
display.visible = False closes the window.
Strangely, however, display.visible.objects continues to refer to all
previously visible objects, yet setting display.visible = True does
not bring them back (and even attempting to manually make them visible
via these references doesn't appear to work). Thus, it is probably
prudent to at least do the above "clearing" if you're going to do
this, as it is evidently leaky otherwise.
--
Aaron Mavrinac
www.mavrinac.com
|