From: Bruce S. <ba...@an...> - 2000-11-23 17:28:26
|
--On Thursday, November 23, 2000, 5:31 PM +0100 Rochus Schmid <roc...@ch...> wrote: > is there a way to delete a vpython object? > I know that I can make it invisible. > > but if I say: > > s=sphere() > del(s) > > the sphere remains (I just lost the python object to tweak it :-) The only way to make a Visual object disappear is to make it invisible. If you in addition do del(s) as you say, or simply assign something else to s, it is my understanding that eventually Python will garbage collect the object structure. So the rule is, make the object invisible, then use the name for something else (or use del). > in my case a molecule is displayed along a reaction coordinate. the > number of bonds (=cylinders) varies with the geometry. > soemtimes a bond may appear and vanish a couple of frames later. > it would be a lot of bookkeeping to decide whether there are still > invisible objects to switch on or a new cylinder must be created. > I could just generate a lot of cylinders and switch them to invisible > but that seems not very elegant to me? You need not do any special bookkeeping. Just make the object invisible before deleting or reusing the name. I guess the documentation should explain that del doesn't make an object invisible, just inaccessible. Bruce Sherwood |