I'm trying to use Blender without invoking the GUI. How do you invoke the bpy.ops functions without a GUI? Is there a bpy.data.objects equivalent of by.ops.object.modifier_apply for instance?
As far as I know, there's no single low-level command that does this like the
bpy.ops.object.modifier_apply operator, but this is possible without operators.
You can do this by using the to_mesh method, which generates a new version of the object's mesh data, if you wish - with modifier's applied.
In this example I'm generating a version of the mesh data with modifier's applied, and assigning it directly back into the source object's data.
This updates the mesh geometry, but doesn't remove the modifier (since we simply generated a copy, and haven't actually applied the modifier yet).
So eventually all we need to do is to remove the modifier using the
import bpy obj = bpy.context.object myModifier = obj.modifiers['Subsurf'] # Apply modifier to existing object data obj.data = obj.to_mesh( apply_modifiers = True, scene = bpy.context.scene, settings = 'PREVIEW' ) # Remove modifier from modifier's list obj.modifiers.remove( myModifier )