# Select vertices on one side of a cube

The aim is to select the vertices of one side of a cube.

My intention was to change the view's orientation using bpy.ops.view3d.viewnumpad and then select the vertices that are visible, using bpy.ops.vew3d.select_border.

    def changeView(view):
for area in bpy.context.screen.areas:
if area.type == 'VIEW_3D':
override = bpy.context.copy()
override['area'] = area
break

def select_border(mesh,context, view3dAreaAndRegion=None, extend=True):
if not view3dAreaAndRegion:
view3dAreaAndRegion = getView3dAreaAndRegion(context)
view3dArea, view3dRegion = view3dAreaAndRegion

override = context.copy()
override['area'] = view3dArea
override['region'] = view3dRegion

#change orientation to Front side
changeView('FRONT');

bpy.ops.view3d.select_border(override,
gesture_mode=3,
xmin=0,
xmax=view3dArea.width,
ymin=0,
ymax=view3dArea.height,
extend=extend)
return view3dAreaAndRegion


This works, so long as I click 'Run Script' twice, or if the View is already set manually by hitting 1 on the number pad.

However the problem is, if I pan around,then hit 'Run Script' once, it selects all the vertices that are visible from that angle, before changing the view's orientation to Front.

• If using predefined options, you can try Select > Side Of Active and set up its options (Axis of selection, Positive/Negative etc) or Shift+G > Co-Planar (in face selection mode), it might be similar to your needs. – Mr Zak Jan 8 '18 at 21:06
• Comparing face normal to views' normal could be another way to do this without operators. Also Related – batFINGER Jan 9 '18 at 5:21

from bpy import context as C