Post #5597: execute_script() fundamentally returns True by specification, so it cannot b

๐Ÿ“‹ Metadata

๐Ÿท๏ธ Tags

python-scripting intermediate solved

  • Python Scripting
  • Macro Editor

๐Ÿ’ฌ Content

execute_script() fundamentally returns True by specification, so it cannot be used as a function object, which is why the error occurs.

When passing arguments to a script, they should be passed as kwargs to execute_script().

# command tab
execute_script("greeting.py", msg="Hello")
# scripts/greeting.py
def say_hello(msg):
    print(msg)
say_hello(kwargs["msg"])

When you want to get a return value from a script, store it in a variable called return_value.

# command tab
msg = execute_script("hi.py"); print(msg)
# scripts/hi.py
return_value = "Hi!"

If this explanation doesnโ€™t clarify things for you, please share the scripts youโ€™re using and details about your setup.


๐Ÿ”— View on Blender Artists