Skip to main content
Code markdown: Select the code and hit {} button or ctrl-K. For blocks markdown is all indented one right, inline markdown will add backticks.
Source Link
batFINGER
  • 85.2k
  • 10
  • 114
  • 244

Suppose I have an object, for simplicity, created as a grid and two circles. How can I extract a mesh, which satisfies a condition: x>=0 and y>=0. This implies that the faces associated with the circles have to be bisected. I am wondering if there is a relatively easy solution to this. May be, bmesh.ops.bisect_plane can be of any help in this situation, but I do not know how to apply it.

import bpy

import bmesh

bpy.ops.object.select_all(action='SELECT')

bpy.ops.object.delete()

bpy.ops.mesh.primitive_circle_add(vertices=32, radius=2, location=(0.5, 0.5, 0.0), fill_type='NGON')

bpy.ops.object.mode_set(mode='EDIT')

bpy.ops.mesh.select_all(action="DESELECT")

bpy.ops.mesh.primitive_circle_add(vertices=32, radius=3, location=(0.5, 0.5, 0.0), fill_type='NGON')

bpy.ops.object.mode_set(mode='EDIT')

bpy.ops.mesh.select_all(action="DESELECT")

bpy.ops.mesh.primitive_grid_add(x_subdivisions=3, y_subdivisions=3, radius=4.0, location=(0.0,0.0,0.0))

bpy.ops.object.mode_set(mode='EDIT')

bpy.ops.mesh.select_all(action="DESELECT")

bpy.ops.object.mode_set(mode='OBJECT')

obj = bpy.context.selected_objects[0]

import bpy

import bmesh

bpy.ops.object.select_all(action='SELECT')

bpy.ops.object.delete()

bpy.ops.mesh.primitive_circle_add(vertices=32, radius=2, 
                                  location=(0.5, 0.5, 0.0), fill_type='NGON')

bpy.ops.object.mode_set(mode='EDIT')

bpy.ops.mesh.select_all(action="DESELECT")

bpy.ops.mesh.primitive_circle_add(vertices=32, radius=3, 
                                  location=(0.5, 0.5, 0.0), fill_type='NGON')

bpy.ops.object.mode_set(mode='EDIT')

bpy.ops.mesh.select_all(action="DESELECT")

bpy.ops.mesh.primitive_grid_add(x_subdivisions=3, y_subdivisions=3, 
                                radius=4.0, location=(0.0,0.0,0.0))

bpy.ops.object.mode_set(mode='EDIT')

bpy.ops.mesh.select_all(action="DESELECT")

bpy.ops.object.mode_set(mode='OBJECT')

obj = bpy.context.selected_objects[0]

Suppose I have an object, for simplicity, created as a grid and two circles. How can I extract a mesh, which satisfies a condition: x>=0 and y>=0. This implies that the faces associated with the circles have to be bisected. I am wondering if there is a relatively easy solution to this. May be, bmesh.ops.bisect_plane can be of any help in this situation, but I do not know how to apply it.

import bpy

import bmesh

bpy.ops.object.select_all(action='SELECT')

bpy.ops.object.delete()

bpy.ops.mesh.primitive_circle_add(vertices=32, radius=2, location=(0.5, 0.5, 0.0), fill_type='NGON')

bpy.ops.object.mode_set(mode='EDIT')

bpy.ops.mesh.select_all(action="DESELECT")

bpy.ops.mesh.primitive_circle_add(vertices=32, radius=3, location=(0.5, 0.5, 0.0), fill_type='NGON')

bpy.ops.object.mode_set(mode='EDIT')

bpy.ops.mesh.select_all(action="DESELECT")

bpy.ops.mesh.primitive_grid_add(x_subdivisions=3, y_subdivisions=3, radius=4.0, location=(0.0,0.0,0.0))

bpy.ops.object.mode_set(mode='EDIT')

bpy.ops.mesh.select_all(action="DESELECT")

bpy.ops.object.mode_set(mode='OBJECT')

obj = bpy.context.selected_objects[0]

Suppose I have an object, for simplicity, created as a grid and two circles. How can I extract a mesh, which satisfies a condition: x>=0 and y>=0. This implies that the faces associated with the circles have to be bisected. I am wondering if there is a relatively easy solution to this. May be, bmesh.ops.bisect_plane can be of any help in this situation, but I do not know how to apply it.

import bpy

import bmesh

bpy.ops.object.select_all(action='SELECT')

bpy.ops.object.delete()

bpy.ops.mesh.primitive_circle_add(vertices=32, radius=2, 
                                  location=(0.5, 0.5, 0.0), fill_type='NGON')

bpy.ops.object.mode_set(mode='EDIT')

bpy.ops.mesh.select_all(action="DESELECT")

bpy.ops.mesh.primitive_circle_add(vertices=32, radius=3, 
                                  location=(0.5, 0.5, 0.0), fill_type='NGON')

bpy.ops.object.mode_set(mode='EDIT')

bpy.ops.mesh.select_all(action="DESELECT")

bpy.ops.mesh.primitive_grid_add(x_subdivisions=3, y_subdivisions=3, 
                                radius=4.0, location=(0.0,0.0,0.0))

bpy.ops.object.mode_set(mode='EDIT')

bpy.ops.mesh.select_all(action="DESELECT")

bpy.ops.object.mode_set(mode='OBJECT')

obj = bpy.context.selected_objects[0]
Source Link

How to get part of a mesh with Python API, which requires breaking down some faces?

Suppose I have an object, for simplicity, created as a grid and two circles. How can I extract a mesh, which satisfies a condition: x>=0 and y>=0. This implies that the faces associated with the circles have to be bisected. I am wondering if there is a relatively easy solution to this. May be, bmesh.ops.bisect_plane can be of any help in this situation, but I do not know how to apply it.

import bpy

import bmesh

bpy.ops.object.select_all(action='SELECT')

bpy.ops.object.delete()

bpy.ops.mesh.primitive_circle_add(vertices=32, radius=2, location=(0.5, 0.5, 0.0), fill_type='NGON')

bpy.ops.object.mode_set(mode='EDIT')

bpy.ops.mesh.select_all(action="DESELECT")

bpy.ops.mesh.primitive_circle_add(vertices=32, radius=3, location=(0.5, 0.5, 0.0), fill_type='NGON')

bpy.ops.object.mode_set(mode='EDIT')

bpy.ops.mesh.select_all(action="DESELECT")

bpy.ops.mesh.primitive_grid_add(x_subdivisions=3, y_subdivisions=3, radius=4.0, location=(0.0,0.0,0.0))

bpy.ops.object.mode_set(mode='EDIT')

bpy.ops.mesh.select_all(action="DESELECT")

bpy.ops.object.mode_set(mode='OBJECT')

obj = bpy.context.selected_objects[0]