draw seperate objects. (help)

I have a problem with the following code.
there are 4 objects this script creates.
the problem is, each time a new object is created,
the old object is replaced.
here is the relevant part of the code.

def make_teapot(FileName, Resolution):
    FileNames = [None, teapot, teaspoon, teacup, onepatch]
    FileName = FileNames[FileName]
    Patches = read_indexed_patch_file(FileName)
    Raw = patches_to_raw(Patches, Resolution)
    Verts, Faces = raw_to_indexed(Raw)
    create_mesh(Verts, Faces, "Teapot")

# ===========================
# === Create Blender Mesh ===
# ===========================
def create_mesh(verts, faces, objname, norms=[], uvs=[]):
    me = Blender.Mesh.New(objname)
    #    # if norms:
    #      for i in range(len(norms)):
    #          me.verts[i].no = Blender.Mathutils.Vector(norms[i])
    #          me.vertexUV = 1
    #          me.verts[i].uvco = Blender.Mathutils.Vector(uvs[i])
    #      for face in me.faces:
    #          face.smooth = 1
    scn = Blender.Scene.GetCurrent()
    for ob in scn.objects:
        if ob.name.find(objname) == 0:
    ob = scn.objects.new(me, objname)

so how would I change this to create a new object, without replacing the old, each time the script is run?

Well unless I’m mistaken the lines

for ob in scn.objects:
        if ob.name.find(objname) == 0:

Are going to unlink any object whose name starts with the string value contained in “objname”.

The script then proceeds to create the new object.

If you want a new set of objects each time just remove those lines. The two calls that take the name (1st to create the mesh structure and 2nd to create the object) use that name as a starting point only. If that name is already in use a new unique name will be used. Teapot, Teapot.001, Teapot.002, etc…

Thanks, that was indeed the problem.
that leads to one more.

When I create an object it is selected.
when I create another, both are selected.
how do I make the new object the selected/active object?

I suppose the quickest (and dirtiest?) way would be to set the scenes selected object list to an empty list. And then call the object’s select method (err… function) and pass the value True. Calling that will mark the object as selected and make it the active object.

hmm, maybe,
I will look into it later.
the quicker dirtier fixed it enough.
now I can have a tea party.

he he, 100% scripted objects in the scene.

WooHoo! Tea Party! Don’t forget to include Mr. French and Mrs. Beasley *** jeez I’m old ***

well, we had a small party last night for my birthday on irc #blenderwiki
you should join us there tonight for a chat.
in about 3 hours time I will log in.
thanks for your help 4mm.
I want to get this out in a bundle tonight.

Well then, Happy Birthday to you!

In 3 hours time I will be about 2 hours and 45 minutes in to my sleep, but thanks for the invite just the same.