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 ...
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 ...
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 ...
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).
...
11
votes
11
votes
Accepted
Create a UV Sphere / Object in Blender from Python
EDIT: Updated for 2.8x, for prior see revision
...
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 ...
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 ...
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 ...
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, ...
9
votes
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 ...
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.
...
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):
...
8
votes
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 ...
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)
...
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 ...
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 ...
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 ...
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
...
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 ...
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
...
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 ...
6
votes
Accepted
Cut BMesh with python
This code snippet assumes some existing variables which were pre-calculated
...
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 ...
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 ...
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 ...
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.
...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
bmesh × 386python × 296
scripting × 127
mesh × 117
vertices × 31
modeling × 24
faces × 23
modifiers × 16
edges × 16
uv × 14
add-on × 12
mathematics × 10
transforms × 9
geometry × 9
selection-tools × 8
objects × 7
animation × 6
normals × 6
topology × 6
extrude × 6
operator × 6
knife-tool × 6
texturing × 5
materials × 5
import × 5