Hello,
is there a way to copy faces from one object to another?
(Update) I have found my error and have updated the sample code. Can be closed.
import bpy
import bmesh
# api shortcuts
ops = bpy.ops
ctx = bpy.context
opo = bpy.ops.object
cube = bpy.data.objects['Cube']
verts = []
faces = []
opo.mode_set(mode='EDIT', toggle=False)
sel_mode = ctx.tool_settings.mesh_select_mode
ctx.tool_settings.mesh_select_mode = [True, True, True]
mesh = bmesh.from_edit_mesh(cube.data)
for v in mesh.verts:
verts.append(v.co)
for f in mesh.faces:
fs = []
for v in f.verts:
fs.append(v.index)
faces.append(fs)
opo.mode_set(mode='OBJECT', toggle=False)
cp_mesh = bpy.data.meshes.new('Copy')
cp_obj = bpy.data.objects.new('Copy', cp_mesh)
cp_obj.location = cube.location
bpy.context.scene.objects.link(cp_obj)
cp_mesh.from_pydata(verts, [], faces)
cp_mesh.update(calc_edges=True)