0

I'm trying to use the circle select to select only the faces on top of a mesh. But i got RuntimeError: Operator bpy.ops.view3d.select_circle.poll() expected a view3d region. How can i set the view3d region? Or is there a better way to select only the top faces? PS: The actual mesh would be procedurally generated.

def select_faces(obj):    
    context = bpy.context
    context.view_layer.objects.active = context.scene.objects[obj]
    if context.object.mode != 'EDIT':
        bpy.ops.object.mode_set(mode='EDIT')
context.area.type = 'VIEW_3D'
bpy.ops.view3d.view_axis(type='TOP')
bpy.ops.view3d.select_circle(radius=100,mode='ADD')

select_faces('Plane')

Markus von Broady
  • 36,563
  • 3
  • 30
  • 99
Thiago M.
  • 55
  • 5

1 Answers1

0

Your code should be like this

 def select_faces(obj):    
    context = bpy.context
    context.view_layer.objects.active = context.scene.objects[obj]
    if context.object.mode != 'EDIT':
        bpy.ops.object.mode_set(mode='EDIT')
context.area.type = 'VIEW_3D'
if bpy.ops.view3d.view_axis.poll():
   bpy.ops.view3d.view_axis(type='TOP')
   bpy.ops.view3d.select_circle(radius=100,mode='ADD')

select_faces('Plane')