Q: Which method to use to program "almost static" objects in Python?

Hello,
I have a question: for some generator script, I want to
include subobjects (screw heads in this case).

I have modeled the screw heads in blender and found
that I need to set

  • the vertices
  • the faces (of course)
  • edge creases
  • some faces to be smooth, others not

Such subobjects would need to be scaled, translated
and rotated depending on the script’s input parameters.
Currently I do not care about materials and textures.

I want to avoid to explicitly call “me.verts.append” etc.
around one hundred times, so I’m thinking of some
list to be initialized, then calling a library function to just
create this for me (like embedding a file of .obj format
or similar into the Python script)

Is there some standard utility function, or do I need to create my own?

Best regards,
Michael

you pretty much need to use either 1 mesh or many objects.
Dupliverts verts are good but in this case you probably want to give it a direction. (Duplifaces would be nice here)
Dupliframes could do this, by having 1 frame at each location, but could be very messy to work with after creating if you wanted to move a screw head.

In your case, 1 object for the screw head may result in too many objects scattered over the scene which can slow down general operations when working with the scene (10000 objects+ result in a noticible slowdown)

Id suggest make 1 screw head, and then many objects, but add them to a group using Blender.Group module, then you can have 1 object as a group instance for the group that contains all teh screw heads
and your scene wont slowdown,.

code that may even work :wink:

make a list of new objects, dont think they need to be in a scene

screw_heads = gen_screws()
grp= Blender.Group.New()
grp.objects= screw_heads
instance= Object.New(‘Empty’)
scn= Scene.GetCurrent()
scn.link(instance)
instance.group= grp
instance.enableDupGroup = True # need to turn it on as well as assign a group.

Now you shoud see the screw objects from the instance empty