scene.addObject() but no scene.removeObject() ?

What am I missing here ? If there is a scene.addObject() how come there is no scene.removeObject() ?
I know I’m a noob but still, I can’t find any global scene function to remove objects.
I checked the API and there is no mention of such a function in the scene class.
Only gameobject has that property or function.

So, that’s bug number 1 but there is also another bug where lamps don’t interact with the generated terrain.

Don’t you use endObject?

adding and deleting is not necessarily symmetrical.

While you can let an object delete itself, it is impossible to create itself. Therefore you need another object (a builder) to create the object.

Well here is the thing. I managed to crash Blender when I tried this:

for obj in scene.objects:
if ‘tile’ or ‘road’ in obj:
obj.endObject()

And it crashed right there. That code was supposed to activate on some button press like MMB.
The idea is to have some way to remove some tiles if I add too many or some need to be regenerated.

Considering how the scene is in charge of all objects, even if you have an endObject() on the object
the scene should have a way to clear or end objects too aside from the gameObject class.

Your OR statement is a bit off there. "If “tile”: " will always come back True, because “tile” is not an empty string ( “” ). You need to tell it what to look for “tile” in before you give the OR statement. Your code needs just a dash more redundancy in it, and it should work :wink:


if 'tile' in obj or 'road' in obj:

OR if you want to get fancy:


if ('tile', 'road') in obj:

should give you the same result.

That should not be “crashing Blender” though. In fact, what it should be doing is ending every object in the scene (since “tile” is always True), which will leave you with an empty scene…which (logic demands) would probably indeed crash Blender, since your camera is being ended as well! That is my hypothesis, at least.

I agree it sounds like ending the active camera

Thanks for your help. I’ll have to try it again. So I guess it was a syntax problem.
Hopefully I don’t crash it again with my super noob code. LOL