Creating simple meshes from scratch, how (noob warning)


  1. How can I, in a simple line by line fashion, create i.e. a pyramid object?

  2. How can I move specific points in a created cube to desired locations, and possibly merge 4 points sharing location to obtain a pyramid that way?

I’ve check out, but I’m clueless on Python and programming in general, and it seems to do a lot more than I want (add box appear in add mesh menu and so on), and I’m not able to grab what I need and put it in my own script and have it working.

Similarly I’ve looked at, which moves all verts. I’ve watched tutorials how to stop at one vert, which works ok, but I can’t figure out the syntax how to move specific verts to specific precalculated locations.

I’ve also looked at addons, but the syntax for a complete noob is utter greek to me.

Edit: For #1, I found this which I think will help me, I can make the object I want and looks straightforward to use. Although problem solved for now, answer to #2 would still be welcome.

this is also call creating new primitive using old fashion API or the newest Bmesh data.

there is an example in template script edtitor
or the old wiki code snippets examples

but it is a bit difficult to understand at first
but after a while you get use to it !

Bmesh allows much more powerful commands then the old API
but it is slower
The fastest way might be the old API but more difficult to do.

give us what you have up to now then we might help further.

happy bl

Old API, new API? Okay, didn’t know they had different ages :slight_smile: Anyhow, I have created my pyramids with bmesh (vertex by vertex, given the example I found above and implemented in my “script”) and rectangle with create (and modify size and rotation). So I basically have what I need for now regarding objects I want to create in the scene (although there is still lots to do like linking in and assigning material libraries, linking in and positioning objects).

So yeah, I’m still learning. But still, given the default cube in the fabric startup, how do I relocate vertex #2 and #5 to some new positions? I’m basically after the basic syntax here.

can you upload what you got and what else need to be done

again for mat depends if you simply add mat or check before if mat already exist

so many things to think of !

again with Bmesh there are 3 methods you can use !
Old API does not have Ngons
Bmesh has Ngons and a lot more LOL

happy bl

Assume I have nothing to upload. Just select the default cube and with script, move vertex #2 and #5 to new locations, say [-5, 7, 9] and [2, 6, 13].

here is one example

make a cylinder 

import bpy, bmesh

bm =

ret = bmesh.ops.create_circle(		# Add a new circle

#						 We can do simpler in this case, just use all edges

ret = bmesh.ops.extrude_edge_only(bm, edges=bm.edges)

verts = [v for v in ret['geom'] if isinstance(v, bmesh.types.BMVert)]
bmesh.ops.translate(bm, verts=verts, vec=(0, 0, 2.5))

						# add new object to scene 
me ="Mesh")
ob ="Cone", me)

happy bl

here is one to remove verts with Bmesh

Remove verts in object mode with Bmesh 

import bpy
import bmesh

def main(context):
    me =
    bm =
    for v in bm.verts:
        if v.index % 3 == 0:

class SimpleOperator(bpy.types.Operator):
    bl_idname = "object.simple_operator"
    bl_label = "Simple Object Operator"

    def poll(cls, context):
        return (context.object is not None and
                context.object.mode == 'OBJECT' and
                context.object.type == 'MESH')

    def execute(self, context):
        return {'FINISHED'}

def register():

def unregister():

if __name__ == "__main__":

    # test call

happy bl

here is one to move verts with Bmesh

move verts

If you just want to move a vertex to a new position, and you know what that position is, it's simpler to assign the coordinates directly:

 v = bmesh.verts[i] = Vector( [x,y,z] )

 if you want to move it relative to its current position, just add values to its current coordinates: = + Vector( [ dx, dy, dz ] )

happy bl

1st example:
verts = [v for v in ret[‘geom’] if isinstance(v, bmesh.types.BMVert)]
What the heck is v and what does this even mean? In English I mean. Again, I’m completely new to programming, haven’t really done it since the 6510 (34 years ago according to wiki, lol).

2nd example:
for v in bm.verts:
if v.index % 3 == 0:
v.index is probably what I’m looking for, but where does index come from? I thought [] was how to access arrays. And, do I really have to go through the whole thing? Is there no way to access them directly, like (plain English) vert[2] setcoord (x,y,z) or something?

3rd example:
Where does the [i] come from?

Will see more about this tomorrow.

first example is for making a new primitive Cylinder
could be anything else

but this is how Bmesh works for creating primitive
I did like over 100 different primitives that way

v is a temporary variable for a loop
you need to also brush up a bit more with how python works before I think!

find some good free tut on python and learn more how to !
how to work with list , list comprehension ,tuples vectors

different type of loops and controls

follow tut at python site

happy bl