1
$\begingroup$

This script produces error: object_update<> takes 0 positional arguments but 1 was given

import bpy

def object_update():
    object = bpy.data.objects['Cube']
    bpy.ops.object.explode_refresh(modifier="Explode")

bpy.app.handlers.render_pre.append(object_update)

Script is a kind of working, but how to remove this error?

$\endgroup$

1 Answer 1

2
$\begingroup$

The functions assigned to bpy.app.handlers need to accept one parameter, even if they don't use it. While you can ignore the scene parameter I would suggest using it, rather than directly accessing global data (not that you are making use of the object variable you set).

import bpy

def object_update(scn):
    object = scn.objects['Cube']
    bpy.ops.object.explode_refresh(modifier="Explode")

bpy.app.handlers.render_pre.append(object_update)

Note that the explode_refresh operator will only work on the active object if it has an explode modifier named "Explode", so I'm not sure what you want to achieve will work, or that it is really necessary.

$\endgroup$
2
  • $\begingroup$ Thanks for answering. But now I get another error: Traceback <most recent call last>: line 5, in object_update File "...blender-2.79-windows64\2.79\scripts\modules\bpy\ops.py", line 189, in call ret = op_call<self.idname_py<>, None, kw> RuntimeError: Operator bpy.ops.object.explode_refresh.poll<> failed, context is incorrect $\endgroup$
    – Serge L
    Commented Jan 7, 2018 at 10:49
  • $\begingroup$ That would indicate that you can't run the explode_refresh operator from a handler. Have a look at the addon made for this answer as another approach that might work. $\endgroup$
    – sambler
    Commented Jan 8, 2018 at 11:28

You must log in to answer this question.

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