WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   removing multiple objects (https://forum.worldviz.com/showthread.php?t=2196)

durf 08-04-2009 08:29 AM

removing multiple objects
 
Hello,

I cannot figure out how to remove or delete multiple objects that have been created this way:

Code:

        def balls():
                ball = ballOriginal.copy()
                ball.scale(.5,.5,.5)
                ball.collideSphere()
                ball.setPosition([0,20,0])
        vizact.ontimer2(0,200,balls)

How can I remove all 200 of those balls?

Thanks

farshizzo 08-04-2009 03:55 PM

You should save each object you create into a global list. Then you can periodically go through the list and remove the objects.

durf 08-04-2009 04:01 PM

Is there a good example of this to follow?

farshizzo 08-04-2009 04:09 PM

I'm not sure there is an example that does exactly what you want, but the Duck Court example script that comes with Vizard shows how to save objects into a global list so they can be referenced later.

durf 08-05-2009 07:31 AM

Code:

       
ballList = []       

def balls():
    ball = ballOriginal.copy()
    ball.scale(.5,.5,.5)
    ball.collideSphere()
    ball.setPosition([0,20,0])
    ballList.append(ball)
vizact.ontimer2(0,200,balls)

So I added a global list... how do you "periodically go through the list and remove the objects"? I tried ballList.remove() and that didn't work.

GiudiceLab 08-05-2009 09:02 AM

I'm not sure if I understand exactly what you want to do, but if you first make the global list and then want to take all the balls out of it, you could:

Code:

for row in range(len(ballList)):
                ballList[row].remove()

which will cycle through your list and remove each item.

Or, you could just erase your list by re-initializing it (I think):
Code:

ballList = []

durf 08-05-2009 09:13 AM

Ok I will give that a try later... thanks for the feedback

durf 08-05-2009 09:15 AM

Great I think it worked.


All times are GMT -7. The time now is 10:43 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2021, vBulletin Solutions, Inc.
Copyright 2002-2018 WorldViz LLC