From: Rochus S. <roc...@ch...> - 2000-11-23 16:32:38
|
Hi, sorry to bug you with one more question: 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 :-) 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? did I miss something? couldnt find anything in the docs, nor looking at the functions in the visual module or in the demos. what can I do? all the best, rochus -- Dr. Rochus Schmid Technische Universität München Lehrstuhl f. Anorganische Chemie Lichtenbergstrasse 4, 85747 Garching Tel. ++49 89 2891 3174 Fax. ++49 89 2891 3473 Email roc...@ch... |
From: Hans F. <H.F...@so...> - 2005-03-07 12:15:58
|
Dear all, I was trying to delete visual python objects. Following the suggestions made in this email http://sourceforge.net/mailarchive/forum.php?thread_id=6392639&forum_id=3591, I thought this should be straightforward as follows from visual import * x = sphere() #window appears, sphere appears in window del x #delete x, therefore removing reference to x #here I expected the sphere to disappear but this was not the case. What am I getting wrong here? Thank you, Hans |
From: Jonathan B. <jbr...@ea...> - 2005-03-07 13:11:10
|
On Mon, 2005-03-07 at 12:15 +0000, Hans Fangohr wrote: > Dear all, > > I was trying to delete visual python objects. Following the suggestions > made in this email > http://sourceforge.net/mailarchive/forum.php?thread_id=6392639&forum_id=3591, > > I thought this should be straightforward as follows > > > from visual import * > > x = sphere() > > #window appears, sphere appears in window > > del x #delete x, therefore removing reference to x > > #here I expected the sphere to disappear but this was not the case. > > What am I getting wrong here? It appears you missed the point of the message you are referring to. Visual still owns a reference to the object, which you must destroy first by setting x.visible = False before deleting it. -Jonathan |
From: Hans F. <H.F...@so...> - 2005-03-07 13:46:18
|
Dear Jonathan, >> I was trying to delete visual python objects. Following the suggestions >> made in this email >> http://sourceforge.net/mailarchive/forum.php?thread_id=6392639&forum_id=3591, >> >> I thought this should be straightforward as follows >> >> >> from visual import * >> >> x = sphere() >> >> #window appears, sphere appears in window >> >> del x #delete x, therefore removing reference to x >> >> #here I expected the sphere to disappear but this was not the case. >> >> What am I getting wrong here? > > It appears you missed the point of the message you are referring to. > Visual still owns a reference to the object, which you must destroy > first by setting x.visible = False before deleting it. I did indeed ;) Thank you for clearing this up. Hans > > -Jonathan > > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real users. > Discover which products truly live up to the hype. Start reading now. > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > _______________________________________________ > Visualpython-users mailing list > Vis...@li... > https://lists.sourceforge.net/lists/listinfo/visualpython-users > |
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 |