2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2011-02-27 20:10:08 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup pythonintern
|
2011-02-27 20:10:08 +00:00
|
|
|
*/
|
|
|
|
|
|
2012-02-17 18:59:41 +00:00
|
|
|
#pragma once
|
python operators (in bpy_opwrapper.*)
This means you can define an operator in python that is called from C or Python - like any other operator.
Python functions for invoke and exec can be registered with an operator name.
keywords are read from the python exec() function, then used to create operator properties. The default python values are used to set the property type and defaults.
def exec(size=2.0, text="blah"): ...
is equivalent to...
prop = RNA_def_property(ot->srna, "size", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_default(prop, 2.0f);
prop = RNA_def_property(ot->srna, "size", PROP_STRING, PROP_NONE);
RNA_def_property_string_default(prop, "blah");
TODO -
* make use of events
* return OPERATOR_CANCELLED/OPERATOR_FINISHED.. etc
* add support for array args
* more testing
2008-12-27 14:52:49 +00:00
|
|
|
|
2025-01-07 12:39:13 +01:00
|
|
|
#include <Python.h>
|
|
|
|
|
|
2011-02-15 03:20:12 +00:00
|
|
|
struct wmOperatorType;
|
|
|
|
|
|
2024-06-01 16:17:02 +10:00
|
|
|
/**
|
|
|
|
|
* These are used for operator methods, used by `bpy_operator.cc`.
|
|
|
|
|
*
|
|
|
|
|
* Accessed via sub-classes of `bpy.types.Macro` using the `define` method.
|
|
|
|
|
*/
|
2009-12-05 19:27:26 +00:00
|
|
|
PyObject *PYOP_wrap_macro_define(PyObject *self, PyObject *args);
|
2011-02-15 03:20:12 +00:00
|
|
|
|
2022-11-02 10:14:37 +11:00
|
|
|
/* Exposed to RNA/WM API. */
|
|
|
|
|
|
2021-12-02 17:24:04 +11:00
|
|
|
/**
|
|
|
|
|
* Generic function used by all Python defined operators
|
|
|
|
|
* it's passed as an argument to #WM_operatortype_append_ptr in for operator registration.
|
|
|
|
|
*/
|
2024-09-24 12:23:25 +02:00
|
|
|
void BPY_RNA_operator_wrapper(wmOperatorType *ot, void *userdata);
|
2021-12-02 17:24:04 +11:00
|
|
|
/**
|
|
|
|
|
* Generic function used by all Python defined macro-operators
|
|
|
|
|
* it's passed as an argument to #WM_operatortype_append_ptr in for operator registration.
|
|
|
|
|
*/
|
2024-09-24 12:23:25 +02:00
|
|
|
void BPY_RNA_operator_macro_wrapper(wmOperatorType *ot, void *userdata);
|