From: Jonathan B. <jbr...@ea...> - 2004-02-20 10:37:22
|
On Fri, 2004-02-20 at 02:16, Alan Littleford wrote: > Hi all, > > Just started looking at VPython and instantly got confused by the > reference manual (!): > > In one section I read > > "visible If false (0), object is not displayed; e.g. ball.visible = 0 > Use ball.visible = 1 to make the ball visible again." > > Whereas in another I read > > "To delete a Visual object just make it invisible: ball.visible = 0 > > Technical detail: If you later re-use the name ball, for example by > creating a new object and naming it ball, Python will be free to release > the memory used by the object formerly named ball" > > So which is it? I tried a test and created a frame with a number of > objects, walked the objects attribute setting them to invisible. When I > looked at the objects attribute again it was empty - certainly implying > the latter case is correct and once I set something invisible I should > assume it is gone forever. > > Is this true? How can I set something to be invisible and then make it > visible again without having to reconstruct the object? > > Tnx > Alan The idea is this: when an object is visible, the display that the object is being rendered in owns at least one reference to the object. So, as long as you also own a reference to the object (by having it as a named variable), it will not be deleted. Recall that Python's garbage collection is a reference-counting system. When the reference count reaches zero, the object's memory is freed. Does that help? -Jonathan Brandmeyer |