Sunday, April 12, 2009

How to delete an object from Blender

Objects in Blender are linked to Scenes. There may be more than one scene in Blender at any given moment. The following code snippet demonstrates how to remove the cube that is in the default scene in Blender using Pyhton.

Preparation:

  1. Open Blender
  2. Split the windows to see an outline view, a script view, and a 3-D view. This will help see what happens when the object is deleted.
  3. Manually enter the python script. When the last line is entered, the views will be updated and the default cube will disappear.
import Blender from Blender import Scene # get a list of all scenes in Blender scns = Scene.Get() # get the first scene in the list scn = scns[0] # get the first object in the scene, # this should be the cube obs = list(scn.objects) # unlink the object from the scene scn.unlink(obs[0]) # update all of the views in the user inteface Window.RedrawAll()

No comments:

Post a Comment