Hot answers tagged

17 votes

Efficient way to get selected vertices via python (without iterating over the entire mesh)

Just building on Gwenn's great answer, If you are in Edit Mode, all the vertices may appear selected. Switch to Object Mode so the vertex selection gets updated. You can directly access the vertices ...
endavid's user avatar
  • 301
13 votes

Closing "Fibonacci's Hole"

Oh gosh, I spent ages with it. On the pictures you posted it looks particularly nice because of lines are actually spirals. If they were straight it won't look nice. On your picture pole doesn't have ...
Noidea's user avatar
  • 1,256
11 votes

How do I prevent particle objects from intersecting each other and going though the floor?

I'm going to give this a shot as I think that rigid bodies are a viable solution. Start with a cylinder, scale it as needed but keep in mind that sometimes Blender can act strangely with objects that ...
Timaroberts's user avatar
  • 12.3k
11 votes
Accepted

Is there a way to select edges marked as sharp via python?

There isn't a single command for this, but a script to do this is quite simple: Note that with BMesh, the same smooth option is used for faces and edges (not smooth == sharp). ...
ideasman42's user avatar
11 votes

Efficient way to get selected vertices via python (without iterating over the entire mesh)

...
Rich Colburn's user avatar
11 votes
Accepted

Create a UV Sphere / Object in Blender from Python

EDIT: Updated for 2.8x, for prior see revision ...
Dimali's user avatar
  • 1,675
10 votes

Scripting: low level join meshes / elements (hopefully with bmesh)?

The best solution I found so far is using the bmesh.from_mesh( mesh ) method. Apparently, if you call this method more than once, it will add the 2nd mesh to the ...
TLousky's user avatar
  • 16k
10 votes
Accepted

How to find a mesh loops and rings

The image below will be used as a reference. For clarity's sake, only the normal for face 12 is displayed. The normal is the arrow pointing away from the face, the other two arrows indicate the first ...
nBurn's user avatar
  • 156
9 votes

Efficient way to get selected vertices via python (without iterating over the entire mesh)

Edit mode bmesh & numpy Thought I'd throw this one in the ring as an example to speed up getting selection purely from an ...
batFINGER's user avatar
  • 83.5k
9 votes
Accepted

When to use bmesh.update_edit_mesh and when Mesh.update?

The mesh data used by an object is stored within object.data, the most obvious data being stored within the vertices, ...
sambler's user avatar
  • 55.1k
9 votes

how to create and extrude a bmesh face

Here is the extrusion part filled in: ...
kheetor's user avatar
  • 1,418
9 votes
Accepted

BMesh get edge loop

The solution is to use BMLoop, as it is the only element that has constant direction and doesn't depend on the order of other elements. This example code works only with manifold geometry where all ...
Mikhail Rachinskiy's user avatar
9 votes

How can I generate a correct polygon from an array of unordered vertices?

The Blender function that makes a poly from a point cloud is BM_vert_sort_radial_plane. ...
scurest's user avatar
  • 9,486
8 votes

Efficient way to get selected vertices via python (without iterating over the entire mesh)

In newer versions of Blender you can use (while in Edit Mode): ...
DolphinDream's user avatar
8 votes

Applying per-vertex colors to new Bmesh

Loop over face loops. ...
batFINGER's user avatar
  • 83.5k
8 votes
Accepted

How to create a tetrakaidecahedron and keep only the edges?

Here is a different method using the same Truncated Octahedron. Under the user preferences make sure you activate the default bundled addon Add Mesh Extra Objects. Add a new mesh of the type Math ...
Duarte Farrajota Ramos's user avatar
7 votes

Scripting: low level join meshes / elements (hopefully with bmesh)?

Here's what i'm using in Sverchok at the moment, it's not heavily tested yet. It is derived from Sverchok's bmesh_from_pydata function (which is extensively tested) ...
zeffii's user avatar
  • 39.4k
7 votes

Rotate bmesh around Vector with Python

Rotate bmesh vertices around a vector defined by two selected verts. Test script, rotates 45 degrees around the vector defined by two selected verts. Select two vertices and run script. Running 8 ...
batFINGER's user avatar
  • 83.5k
7 votes

How to create a tetrakaidecahedron and keep only the edges?

Under the user preferences make sure you activate the default bundled addon Add Mesh Extra Objects. Add a new mesh of the type Math Function > Regular Solid and from the presets at the bottom pick ...
Duarte Farrajota Ramos's user avatar
7 votes
Accepted

Using python and bmesh to scale/resize a face in place

Scale the distance from face centre to vert. Propose in this case could simply use the face centre as stationary point, and reposition each vertex coordinate by a scale factor. For a face ...
batFINGER's user avatar
  • 83.5k
7 votes
Accepted

Remesh a selected surface

Yes, you can! with Boundary Aligned Remesh Go into Edit Mode Select the messy part of the mesh or just one face Press P to separate the selection Switch to Object Mode and select the separated mesh ...
Oliver's user avatar
  • 94
7 votes
Accepted

What is the bmesh equivalent to bpy.ops.mesh.shortest_path_select()?

Shortest Path algorithms Dijkstra's algorithm Dijkstra's algorithm to find the shortest path between a and b. It picks the unvisited vertex with the lowest distance, calculates the distance through ...
batFINGER's user avatar
  • 83.5k
7 votes
Accepted

How do I measure the length of a selected edge with Python?

In the simplest form, if you don't want to use bmesh, or any vector operations you can use ...
Marty Fouts's user avatar
  • 32.7k
6 votes
Accepted

How do I stop vertex normals getting overwritten when I enter edit mode?

You want to use Mesh.normals_split_custom_set(normals). Custom normals are always set per loop (i.e. face corners), but this utility set those per-vertex (it ...
mont29's user avatar
  • 3,437
6 votes
Accepted

Cut BMesh with python

This code snippet assumes some existing variables which were pre-calculated ...
patmo141's user avatar
  • 777
6 votes

how to create and extrude a bmesh face

Similarly to the link in your q, can use bmesh operators, in this case I've used solidify, Note you must set the normal before calling the operator to get the desired result. Also note that ...
batFINGER's user avatar
  • 83.5k
6 votes
Accepted

Python: Bisect mesh into n parts, without separate 'LOOSE'

Using clear inner and outer on bisect plane operator. Further to my comment, think this may be the simplest way. Test script, which I've tested on Suzanne (who has seperate eye objects) and appears ...
batFINGER's user avatar
  • 83.5k
6 votes
Accepted

Setting mesh's origin in python (2.8)

Bmesh script This can be done similarly by using me.transform(T) with a translation matrix T. I have used an edit mode bmesh as it is simple to set the active ...
batFINGER's user avatar
  • 83.5k
6 votes
Accepted

How to assign a material to a single face of a mesh using Python API

You can assign the materials using MeshPolygon.material_index in Object Mode without Bmesh. ...
brockmann's user avatar
  • 12.3k
6 votes

How to assign a material to a single face of a mesh using Python API

If you'd like to assign material(s) to certain faces in Edit Mode, just assign the index of the material slot to BMFace.material_index on a Bmesh representation of ...
brockmann's user avatar
  • 12.3k

Only top scored, non community-wiki answers of a minimum length are eligible