0
$\begingroup$

I can't apply the modifier programmatically via Python, but clicking the GUI button works.

Some answers on this site say bpy.ops commands usually demand the current active object be proper.

>>> bpy.context.scene.objects.active
bpy.data.objects['Icosphere']

tells me my active object is proper.

But still, I get

>>> bpy.ops.object.modifier_apply(apply_as='DATA')
{'CANCELLED'}

Again, clicking the GUI button works without problems. How may I do it via script?


$\endgroup$
2
$\begingroup$
bpy.ops.object.modifier_apply(modifier='Mirror')

This command requires you to give it a modifier name.

bpy.ops.object.apply_all_modifiers()

This will apply all modifiers. Note, this is a operator from addon 'Modifier Tools'. You have to have this addon enabled to be able to use that command.

$\endgroup$
  • $\begingroup$ AttributeError: Calling operator "bpy.ops.object.apply_all_modifiers" error, could not be found $\endgroup$ – Sibbs Gambling Jun 20 '17 at 4:31
  • 1
    $\begingroup$ Sorry, that command is a subtool from the addon 'Modifier Tools'. Do you have this addon? If you do, enable it and try again. If not, you have to get this addon, or just upgrade your blender to the newest version. Then make sure it's enabled. $\endgroup$ – TeaCrab Jun 20 '17 at 6:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.