Skip to main content
Became Hot Network Question
added 114 characters in body
Source Link
Megan Love
  • 1.5k
  • 4
  • 26

I have empty squares (those with exactly 4 edges only) in my 2D mesh and I need to fill them with faces via python but I don't know how to automatically select these edges. Is it possible to select all of these regions marked in orange via python?

enter image description here

This is what I tried. I selected all edges that have linked exactly only 1 face. Unfortunately it selects the boundary edges as well so I tried doing an and not edge.is_boundary but then nothing gets selected since the small squares inside are apparently also boundary edges.

import bpy
import bmesh

obj = bpy.context.active_object
mesh = obj.data

bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_all(action='DESELECT')

bm = bmesh.from_edit_mesh(mesh)

for edge in bm.edges:
    edge.select = False

edges_to_select = []

for edge in bm.edges:
    if len(edge.link_faces) == 1: #and not edge.is_boundary:
        edges_to_select.append(edge)

for edge in edges_to_select:
    edge.select = True

bmesh.update_edit_mesh(mesh)

Here's another try where I almost got the result:

enter image description here

import bpy
import bmesh

obj = bpy.context.active_object
mesh = obj.data

bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_all(action='DESELECT')

bm = bmesh.from_edit_mesh(mesh)

for edge in bm.edges:
    edge.select = False

edges_to_select = []

for edge in bm.edges:
    if len(edge.link_faces) == 1:
        vertices_with_four_edges = all(len(v.link_edges) == 4 for v in edge.verts)
        if vertices_with_four_edges:
            edges_to_select.append(edge)

for edge in edges_to_select:
    edge.select = True

bmesh.update_edit_mesh(mesh)

I have empty squares (those with exactly 4 edges only) in my 2D mesh and I need to fill them with faces via python but I don't know how to automatically select these edges. Is it possible to select all of these regions marked in orange via python?

enter image description here

This is what I tried. I selected all edges that have linked exactly only 1 face. Unfortunately it selects the boundary edges as well so I tried doing an and not edge.is_boundary but then nothing gets selected since the small squares inside are apparently also boundary edges.

import bpy
import bmesh

obj = bpy.context.active_object
mesh = obj.data

bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_all(action='DESELECT')

bm = bmesh.from_edit_mesh(mesh)

for edge in bm.edges:
    edge.select = False

edges_to_select = []

for edge in bm.edges:
    if len(edge.link_faces) == 1: #and not edge.is_boundary:
        edges_to_select.append(edge)

for edge in edges_to_select:
    edge.select = True

bmesh.update_edit_mesh(mesh)

Here's another try where I almost got the result:

enter image description here

import bpy
import bmesh

obj = bpy.context.active_object
mesh = obj.data

bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_all(action='DESELECT')

bm = bmesh.from_edit_mesh(mesh)

for edge in bm.edges:
    edge.select = False

edges_to_select = []

for edge in bm.edges:
    if len(edge.link_faces) == 1:
        vertices_with_four_edges = all(len(v.link_edges) == 4 for v in edge.verts)
        if vertices_with_four_edges:
            edges_to_select.append(edge)

for edge in edges_to_select:
    edge.select = True

bmesh.update_edit_mesh(mesh)

I have empty squares (those with exactly 4 edges only) in my 2D mesh and I need to fill them with faces via python but I don't know how to automatically select these edges. Is it possible to select all of these regions marked in orange via python?

enter image description here

This is what I tried. I selected all edges that have linked exactly only 1 face. Unfortunately it selects the boundary edges as well so I tried doing an and not edge.is_boundary but then nothing gets selected since the small squares inside are apparently also boundary edges.

import bpy
import bmesh

obj = bpy.context.active_object
mesh = obj.data

bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_all(action='DESELECT')

bm = bmesh.from_edit_mesh(mesh)

for edge in bm.edges:
    edge.select = False

edges_to_select = []

for edge in bm.edges:
    if len(edge.link_faces) == 1: #and not edge.is_boundary:
        edges_to_select.append(edge)

for edge in edges_to_select:
    edge.select = True

bmesh.update_edit_mesh(mesh)

Here's another try where I almost got the result:

enter image description here

import bpy
import bmesh

obj = bpy.context.active_object
mesh = obj.data

bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_all(action='DESELECT')

bm = bmesh.from_edit_mesh(mesh)

for edge in bm.edges:
    edge.select = False

edges_to_select = []

for edge in bm.edges:
    if len(edge.link_faces) == 1:
        vertices_with_four_edges = all(len(v.link_edges) == 4 for v in edge.verts)
        if vertices_with_four_edges:
            edges_to_select.append(edge)

for edge in edges_to_select:
    edge.select = True

bmesh.update_edit_mesh(mesh)
added 826 characters in body
Source Link
Megan Love
  • 1.5k
  • 4
  • 26

I have empty squares (those with exactly 4 edges only) in my 2D mesh and I need to fill them with faces via python but I don't know how to automatically select these edges. Is it possible to select all of these regions marked in orange via python?

enter image description here

This is what I tried. I selected all edges that have linked exactly only 1 face. Unfortunately it selects the boundary edges as well so I tried doing an and not edge.is_boundary but then nothing gets selected since the small squares inside are apparently also boundary edges.

import bpy
import bmesh

obj = bpy.context.active_object
mesh = obj.data

bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_all(action='DESELECT')

bm = bmesh.from_edit_mesh(mesh)

for edge in bm.edges:
    edge.select = False

edges_to_select = []

for edge in bm.edges:
    if len(edge.link_faces) == 1: #and not edge.is_boundary:
        edges_to_select.append(edge)

for edge in edges_to_select:
    edge.select = True

bmesh.update_edit_mesh(mesh)

Here's another try where I almost got the result:

enter image description here

import bpy
import bmesh

obj = bpy.context.active_object
mesh = obj.data

bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_all(action='DESELECT')

bm = bmesh.from_edit_mesh(mesh)

for edge in bm.edges:
    edge.select = False

edges_to_select = []

for edge in bm.edges:
    if len(edge.link_faces) == 1:
        vertices_with_four_edges = all(len(v.link_edges) == 4 for v in edge.verts)
        if vertices_with_four_edges:
            edges_to_select.append(edge)

for edge in edges_to_select:
    edge.select = True

bmesh.update_edit_mesh(mesh)

I have empty squares (those with exactly 4 edges only) in my 2D mesh and I need to fill them with faces via python but I don't know how to automatically select these edges. Is it possible to select all of these regions marked in orange via python?

enter image description here

This is what I tried. I selected all edges that have linked exactly only 1 face. Unfortunately it selects the boundary edges as well so I tried doing an and not edge.is_boundary but then nothing gets selected since the small squares inside are apparently also boundary edges.

import bpy
import bmesh

obj = bpy.context.active_object
mesh = obj.data

bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_all(action='DESELECT')

bm = bmesh.from_edit_mesh(mesh)

for edge in bm.edges:
    edge.select = False

edges_to_select = []

for edge in bm.edges:
    if len(edge.link_faces) == 1: #and not edge.is_boundary:
        edges_to_select.append(edge)

for edge in edges_to_select:
    edge.select = True

bmesh.update_edit_mesh(mesh)

I have empty squares (those with exactly 4 edges only) in my 2D mesh and I need to fill them with faces via python but I don't know how to automatically select these edges. Is it possible to select all of these regions marked in orange via python?

enter image description here

This is what I tried. I selected all edges that have linked exactly only 1 face. Unfortunately it selects the boundary edges as well so I tried doing an and not edge.is_boundary but then nothing gets selected since the small squares inside are apparently also boundary edges.

import bpy
import bmesh

obj = bpy.context.active_object
mesh = obj.data

bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_all(action='DESELECT')

bm = bmesh.from_edit_mesh(mesh)

for edge in bm.edges:
    edge.select = False

edges_to_select = []

for edge in bm.edges:
    if len(edge.link_faces) == 1: #and not edge.is_boundary:
        edges_to_select.append(edge)

for edge in edges_to_select:
    edge.select = True

bmesh.update_edit_mesh(mesh)

Here's another try where I almost got the result:

enter image description here

import bpy
import bmesh

obj = bpy.context.active_object
mesh = obj.data

bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_all(action='DESELECT')

bm = bmesh.from_edit_mesh(mesh)

for edge in bm.edges:
    edge.select = False

edges_to_select = []

for edge in bm.edges:
    if len(edge.link_faces) == 1:
        vertices_with_four_edges = all(len(v.link_edges) == 4 for v in edge.verts)
        if vertices_with_four_edges:
            edges_to_select.append(edge)

for edge in edges_to_select:
    edge.select = True

bmesh.update_edit_mesh(mesh)
edited title
Link
Megan Love
  • 1.5k
  • 4
  • 26

How can I select all edges that form part of a square without a facesface via python?

added 865 characters in body
Source Link
Megan Love
  • 1.5k
  • 4
  • 26
Loading
Source Link
Megan Love
  • 1.5k
  • 4
  • 26
Loading