Hello. I’m new to blender python coding, and Im having trouble with a simple script, can you help ?
What am I trying to do ?
To duplicate the selected faces of a mesh and create a new object with them
import bpy, bmesh #getting the object to where faces copy from obj = bpy.context.object #Im going to work with bmesh, so #mesh is the source obj mesh #out is the output where I store the faces mesh = bmesh.from_edit_mesh(obj.data) out = bmesh.new() #list to store selected faces myfaces =  #loop through mesh and get selected faces for f in mesh.faces: if f.select: myfaces.append(f) #loop through selected faces list and input them in the output mesh for f in myfaces: out.faces.new(f.verts) #Creating the mesh in blender data outMesh = bpy.data.meshes.new("New Mesh") #transfering bmesh data to mesh out.to_mesh(outMesh) #Creating obj and linking to outMesh outObj = bpy.data.objects.new("New Obj",outMesh) #linking obj to scene bpy.context.scene.objects.link(outObj) mesh.free() out.free()
I keep getting the error: “ValueError: faces.new(…): 0 (BMVert) is from another mesh”. I don’t know what that means at all.