I am new to Blender scripting and am trying to write a script which selects only the visible faces or vertices of a mesh, while rotating automatically that objet. I have some ideas for the aglorithm but am stuck with the basics of the API.
When I run the piece of script below from the script editor window in Blender (which is open beside the 3d view where my mesh is), the instructions supposed to configure the 3D view are not processed (those in the for loop). However, the other ones addressing the object directly are processed. Therefore it seems the reference to the 3D view is wrong. Any idea how to solve this ?
import bpy import mathutils bpy.ops.object.editmode_toggle() areas = bpy.context.screen.areas for area in areas: if area.type == 'SpaceView3D' : area.active_space.viewport_shade = 'SOLID' area.active_space.use_occlude_geometry = True bpy.ops.mesh.select_mode(use_extend=False, use_expand=True, type='EDGE') bpy.ops.mesh.select_all(action='TOGGLE')