I have a big terrain object, I'm trying to write a script that cut it in smaller pieces and then I will export the pieces to other formats. This is required by a game engine because the mesh, if not subdivided at export time, is not properly culled, resulting in slow rendering.
I tried to use
bpy.ops.view3d.select_border() but it fails with message:
RuntimeError: Operator bpy.ops.view3d.select_border.poll() expected a view3d region
A search revealed that
select_border must be called from 3d view, probably by clicking a button. But this is not a generalized script, it is specific to this model, I will rewrite parts of it if I need it for another model. I want to run it from text editor directly.
The only solution I can see for now is to iterate every vertex of the selected object and if they are inside the defined tile size, then duplicate, separate, export, delete, and repeat moving one tile to the left, starting at object dimensions / 2 * -1, dimensions / 2 * -1. Iterate vertices and select them can be done from text editor.
Is there a more convenient way of doing this?