I have a grid of objects that each have 2 separate shells in them (cube and sphere) What I want to do is delete the mesh in front, which would be all vertices where their Y position is less than 5. And then select the rest of the vertices and move them along the Y axis by -15.
For the deletion part I have found this script in another question:
import bpy
import bmesh
ob = bpy.context.object
assert ob.type == "MESH"
mat = ob.matrix_world
me = ob.data
global_z_plane = False
if me.is_editmode:
bm = bmesh.from_edit_mesh(me)
else:
bm = bmesh.new()
bm.from_mesh(me)
for v in bm.verts:
co = mat * v.co if global_z_plane else v.co
if co.z < 0:
bm.verts.remove(v)
if bm.is_wrapped:
bmesh.update_edit_mesh(me)
else:
bm.to_mesh(me)
me.update()
This seems to work if I change the Z for a Y and the 0 for 5 but only for the selected object. I need it to do it with all objects in a collection with a specific name like 'Collection'. I've tried grafting together the code from another question I made previously, but I don't really know enough python to make it work. Can anyone help me with this?
bpy.data.objects["Cube"].data = bpy.data.objects["Suzanne"].data
$\endgroup$