How 2 mod import script to create text labels for each object, & color each object ?

I have a script which imports .stl files and names the resultant objects with the files names; I’d like to modify the script to also create text “labels” for each object based on each objects file name, (it would be nice if the text was also made initially invisible); and also color each object with the same color.

(This is for Blender 2.49b & the script is named “stl_batch.py”)

(edit) I wonder if I should move this to the Python support forum? If so, how?

The labels can all be positioned at the same place (either hard specified in the script, or input during script execution), and can have dummy text in them.

How could I do this?

This may be the relevant place in the script?:


######################################################
# === Create Blender Mesh ===
######################################################
def create_mesh(verts, faces, objname, facesuv=[], uvcoords=[], normals=[]):
 if normals: normal_flag = 0
 else: normal_flag = 1
 mesh = Blender.NMesh.GetRaw()
 append_verts(mesh, verts, normals)
 append_faces(mesh, faces, facesuv, uvcoords)
 if not g_overwrite_mesh_name.val:
  objname = versioned_name(objname)
 new_obj = Blender.NMesh.PutRaw(mesh, objname, normal_flag) # Name the Mesh
 
 if new_obj != None:
  new_obj.name=objname  # Name the Object if its new
  objname = new_obj.name
 Blender.Redraw()
 return objname

I don’t think this script was included in Blender, I think I found it, and it’s rather long, but I could copy it all here or store it and make a link to it, if that’s legal, it has a GNU General Public License.