← All ideas
  • Published 17 Dec 2019

Feature Request: Apply Modifier without byp.ops

I have a very time intensive script that operates 1000's of boolean Unions.

bpy.ops.object.modifier_apply(modifier='bool 1')

bpy.ops commands have several flaws when scripting, notably slow downs based on # of objects, and incompatibility with threading.

"new_wall.modifier_apply(modifier='bool 1')" type command added would be greatly appreciated.

If curious, I'm making a highly detailed random building/city/world generator, and the booleans adds random windows to the walls.

I apologize if this is the wrong location to post... navigation of blender websites are exceptionally obtuse.

100%

Development Status: Open

Upvote 4 Downvote 0
fibulator777
17 Dec 2019

4 Comments

andrej730

That would be nice, besides perfomance reasons also don't like operators because of the selection management.

Josephbburg

I'm pretty sure bpy.data.meshes.new_from_object() does this if you give it the evaluated depsgraph (which I think comes from bpy.context.scene).

fibulator777 Author

* @Josephbburg * I have no idea what you're saying.
From my understanding all the bpy. commands performs scene refresh. Is this not the case? And your link is broken.

Josephbburg

* @fibulator777 * I've fixed the link. And no, that's not the case. "Scene refresh" as you call it is a depsgraph update, which is an expensive operation so it doesn't happen in most of the bpy functions. I was wrong, it comes from the viewlayer, not the scene:

Here's the way to use it:

import bpy
someOb = bpy.context.active_object
DG = bpy.context.view_layer.depsgraph
DG.update()
ob = someOb.evaluated_get(DG)
someMesh = bpy.data.meshes.new_from_object(ob, depsgraph=DG)

Alternately, you can use bpy.ops.object.convert(target='MESH', keep_original=False) as a single bpy.ops call, instead of doing it for each modifier.

I'm sure there are other ways of doing it, too, but these are the two I have now.

1