0
$\begingroup$

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')
$\endgroup$

1 Answer 1

0
$\begingroup$

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')
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .