# Call a blueprint class function from Python

**URL:** <https://forums.unrealengine.com/t/call-a-blueprint-class-function-from-python/146171>\
**Category:** Editor Scripting\
**Tags:** unreal-engine\
**Created:** [June 20, 2020, 4:10pm UTC](https://forums.unrealengine.com/t/call-a-blueprint-class-function-from-python/146171 "2020-06-20T16:10:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![younesouhbi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@younesouhbi](https://forums.unrealengine.com/u/younesouhbi)\
**Post date:** [June 20, 2020, 4:10pm UTC](https://forums.unrealengine.com/t/call-a-blueprint-class-function-from-python/146171/1 "2020-06-20T16:10:04Z")

</div>

It is possible to set variables of blueprint classes from Python as shown here: [Can you edit a Blueprint Variable from Python? - Editor Scripting - Unreal Engine Forums](https://forums.unrealengine.com/development-discussion/python-scripting/1591378-can-you-edit-a-blueprint-variable-from-python). However, it is possible to call a function that is marked as “Call in Editor”?

My specific use case is to spawn and configure a blueprint class in a level in the editor.

---

<div class="post-metadata">

**Author:** ![ernest\_darewise](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ernest\_darewise](https://forums.unrealengine.com/u/ernest_darewise)\
**Post date:** [December 14, 2021, 4:16pm UTC](https://forums.unrealengine.com/t/call-a-blueprint-class-function-from-python/146171/2 "2021-12-14T16:16:48Z")

</div>

Once you have a reference to your Blueprint you can call one of his functions by using the method `call_method(...)`

> Methods inherited from \_ObjectBase:
> 
> call\_method(…)  
> x.call\_method(name, args=tuple(), kwargs=dict()) → object – call a method on this object via Unreal reflection using the given ordered (tuple) or named (dict) argument data - allows calling methods that don’t have Python glue

[https://docs.unrealengine.com/4.26/en-US/PythonAPI/class/\_ObjectBase.html#unreal.\_ObjectBase.call\_method](https://docs.unrealengine.com/4.26/en-US/PythonAPI/class/_ObjectBase.html#unreal._ObjectBase.call_method)

`your_ref.call_method("YourFunctionName")`

---

<div class="post-metadata">

**Author:** ![TON14](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TON14](https://forums.unrealengine.com/u/TON14)\
**Post date:** [December 13, 2022, 12:25pm UTC](https://forums.unrealengine.com/t/call-a-blueprint-class-function-from-python/146171/3 "2022-12-13T12:25:39Z")

</div>

if inside function exist local variables it’s work wierd!  
`actor.call_method("Test")`  
It always need arguments for all local variables  
`actor.call_method("Test", kwargs={local_var_int': 0})`

But after it ask arguments for all nodes than uses local variable!  
I just print this int local variable and get this

`LogPython: Error: TypeError: test() required argument 'call_func_conv_int_to_string_return_value' (pos 2) not found`

But you can create new function without local variables and inside it call old function with local variables. And it work perfect!

---

<div class="post-metadata">

**Author:** ![DW\_MaxR](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DW\_MaxR](https://forums.unrealengine.com/u/DW_MaxR)\
**Post date:** [August 31, 2023, 7:50am UTC](https://forums.unrealengine.com/t/call-a-blueprint-class-function-from-python/146171/4 "2023-08-31T07:50:29Z")

</div>

Hello!

For future reference, here is a more complete example of how to do this, because it is not that trivial to find out exactly what to do:  
[Call functions or modify properties of a Blueprint from Python | Epic Developer Community (epicgames.com)](https://dev.epicgames.com/community/snippets/aAlM/unreal-engine-call-functions-or-modify-properties-of-a-blueprint-from-python)
