2
$\begingroup$

I have several objects which have boolean relationships to each other. The end object still depends on all sub-objects, so that if I delete one of them it goes away in the end object. Is there a way to convert the end object to a single independent mesh? I tried this but it didn't work:

    end_mesh = end_object.data
    bm_end = bmesh.new()
    bm_end.from_mesh(end_mesh)    
    bm_end.to_mesh(end_mesh)
    bm_end.free()  
$\endgroup$
0

2 Answers 2

3
$\begingroup$

You can also use bpy.ops (to change a little), so it is simply:

import bpy

bpy.ops.object.duplicate()
bpy.ops.object.convert(target='MESH')
$\endgroup$
2
$\begingroup$

This script will add a copy of all selected objects in the scene's main collection with all modifiers applied.

It works with objects that have geometry, not only mesh objects. (Don't select a lamp or camera)

import bpy

context = bpy.context

for obj in context.selected_objects:
    depsgraph = context.evaluated_depsgraph_get()
    m = obj.evaluated_get(depsgraph).to_mesh()
    o = bpy.data.objects.new(obj.name + "_applied", m.copy())
    o.matrix_world = obj.matrix_world.copy()
    # Link the new object to the scene collection if it isn't yet :
    coll = context.scene.collection
    coll.objects.get(o.name, coll.objects.link(o))
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .