35 PyErr_Format(PyExc_RuntimeError,
"bmesh operator: %.200s", errmsg);
56 const char *slot_name,
60 PyErr_Format(PyExc_TypeError,
61 "%.200s: keyword \"%.200s\" %.200s, expected a %.200s not *.200s",
66 Py_TYPE(value)->tp_name);
69 if (value->
bm ==
nullptr) {
70 PyErr_Format(PyExc_TypeError,
71 "%.200s: keyword \"%.200s\" %.200s invalidated element",
77 if (value->
bm !=
bm) {
78 PyErr_Format(PyExc_TypeError,
79 "%.200s: keyword \"%.200s\" %.200s invalidated element",
100 const char htype_bmo,
103 const char *slot_name,
106 if (value->
bm ==
nullptr) {
107 PyErr_Format(PyExc_TypeError,
108 "%.200s: keyword \"%.200s\" %.200s, invalidated sequence",
114 if (value->
bm !=
bm) {
115 PyErr_Format(PyExc_TypeError,
116 "%.200s: keyword \"%.200s\" %.200s, invalidated sequence",
122 if ((htype_py & htype_bmo) == 0) {
125 PyErr_Format(PyExc_TypeError,
126 "%.200s: keyword \"%.200s\" %.200s, expected "
127 "a sequence of %.200s not %.200s",
148 const char *slot_name)
155 PyErr_Format(PyExc_TypeError,
156 "%.200s: keyword \"%.200s\" expected True/False or 0/1, not %.200s",
159 Py_TYPE(value)->tp_name);
171 const char *enum_str = PyUnicode_AsUTF8(value);
173 if (enum_str ==
nullptr) {
174 PyErr_Format(PyExc_TypeError,
175 "%.200s: keyword \"%.200s\" expected a string, not %.200s",
178 Py_TYPE(value)->tp_name);
199 const int param = PyC_Long_AsI32(value);
201 if (param == -1 && PyErr_Occurred()) {
202 PyErr_Format(PyExc_TypeError,
203 "%.200s: keyword \"%.200s\" expected an int, not %.200s",
206 Py_TYPE(value)->tp_name);
215 const float param = PyFloat_AsDouble(value);
216 if (param == -1 && PyErr_Occurred()) {
217 PyErr_Format(PyExc_TypeError,
218 "%.200s: keyword \"%.200s\" expected a float, not %.200s",
221 Py_TYPE(value)->tp_name);
238 PyErr_Format(PyExc_TypeError,
239 "%.200s: keyword \"%.200s\" expected a 3x3 or 4x4 matrix",
262 "single element") == -1)
287 "element buffer") == -1)
301 "element buffer") == -1)
315 "element buffer") == -1)
335 "element buffer") == -1)
343 tot = Py_TYPE(value)->tp_as_sequence->sq_length(value);
354 else if (PySequence_Check(value)) {
355 BMElem **elem_array =
nullptr;
356 Py_ssize_t elem_array_len;
358 elem_array =
static_cast<BMElem **
>(
370 if (elem_array ==
nullptr) {
375 memcpy(slot->
data.
buf, elem_array,
sizeof(
void *) * elem_array_len);
376 PyMem_FREE(elem_array);
379 PyErr_Format(PyExc_TypeError,
380 "%.200s: keyword \"%.200s\" expected "
381 "a bmesh sequence, list, (htype, flag) pair, not %.200s",
384 Py_TYPE(value)->tp_name);
393 if (!PyDict_Check(value)) {
394 PyErr_Format(PyExc_TypeError,
395 "%.200s: keyword \"%.200s\" expected "
396 "a dict, not %.200s",
399 Py_TYPE(value)->tp_name);
404 if (!PySet_Check(value)) {
405 PyErr_Format(PyExc_TypeError,
406 "%.200s: keyword \"%.200s\" expected "
410 Py_TYPE(value)->tp_name);
417 if (PyDict_Size(value) > 0) {
418 PyObject *arg_key, *arg_value;
419 Py_ssize_t arg_pos = 0;
420 while (PyDict_Next(value, &arg_pos, &arg_key, &arg_value)) {
426 "invalid key in dict") == -1)
436 "invalid value in dict") == -1)
448 if (PyDict_Size(value) > 0) {
449 PyObject *arg_key, *arg_value;
450 Py_ssize_t arg_pos = 0;
451 while (PyDict_Next(value, &arg_pos, &arg_key, &arg_value)) {
459 "invalid key in dict") == -1)
464 value_f = PyFloat_AsDouble(arg_value);
466 if (value_f == -1.0f && PyErr_Occurred()) {
467 PyErr_Format(PyExc_TypeError,
468 "%.200s: keyword \"%.200s\" expected "
469 "a dict with float values, not %.200s",
472 Py_TYPE(arg_value)->tp_name);
482 if (PyDict_Size(value) > 0) {
483 PyObject *arg_key, *arg_value;
484 Py_ssize_t arg_pos = 0;
485 while (PyDict_Next(value, &arg_pos, &arg_key, &arg_value)) {
493 "invalid key in dict") == -1)
498 value_i = PyC_Long_AsI32(arg_value);
500 if (value_i == -1 && PyErr_Occurred()) {
501 PyErr_Format(PyExc_TypeError,
502 "%.200s: keyword \"%.200s\" expected "
503 "a dict with int values, not %.200s",
506 Py_TYPE(arg_value)->tp_name);
516 if (PyDict_Size(value) > 0) {
517 PyObject *arg_key, *arg_value;
518 Py_ssize_t arg_pos = 0;
519 while (PyDict_Next(value, &arg_pos, &arg_key, &arg_value)) {
527 "invalid key in dict") == -1)
532 value_i = PyC_Long_AsI32(arg_value);
534 if (value_i == -1 && PyErr_Occurred()) {
535 PyErr_Format(PyExc_TypeError,
536 "%.200s: keyword \"%.200s\" expected "
537 "a dict with bool values, not %.200s",
540 Py_TYPE(arg_value)->tp_name);
550 if (PySet_GET_SIZE(value) > 0) {
551 PyObject *it = PyObject_GetIter(value);
553 while ((arg_key = PyIter_Next(it))) {
562 "invalid key in set") == -1)
579 PyErr_Format(PyExc_NotImplementedError,
580 "This arguments mapping subtype %d is not supported",
589 PyErr_Format(PyExc_NotImplementedError,
590 "%.200s: keyword \"%.200s\" type %d not working yet!",
608 PyObject *item =
nullptr;
629 item = Py_NewRef(Py_None);
641 item = PyList_New(
size);
642 for (j = 0; j <
size; j++) {
655 item = _PyDict_NewPresized(slot_hash ?
BLI_ghash_len(slot_hash) : 0);
664 PyDict_SetItem(item, py_key, py_val);
672 item = _PyDict_NewPresized(slot_hash ?
BLI_ghash_len(slot_hash) : 0);
679 PyObject *py_val = PyFloat_FromDouble(*(
float *)&ele_val);
681 PyDict_SetItem(item, py_key, py_val);
689 item = _PyDict_NewPresized(slot_hash ?
BLI_ghash_len(slot_hash) : 0);
696 PyObject *py_val = PyLong_FromLong(*(
int *)&ele_val);
698 PyDict_SetItem(item, py_key, py_val);
706 item = _PyDict_NewPresized(slot_hash ?
BLI_ghash_len(slot_hash) : 0);
713 PyObject *py_val = PyBool_FromLong(*(
bool *)&ele_val);
715 PyDict_SetItem(item, py_key, py_val);
723 item = PySet_New(
nullptr);
730 PySet_Add(item, py_key);
739 item = Py_NewRef(Py_None);
758 if ((PyTuple_GET_SIZE(args) == 1) && (py_bm = (
BPy_BMesh *)PyTuple_GET_ITEM(args, 0)) &&
764 if (
bm->use_toolflags ==
false) {
765 PyErr_SetString(PyExc_ValueError,
"bmesh created with 'use_operators=False'");
773 PyErr_SetString(PyExc_TypeError,
774 "bmesh operators expect a single BMesh positional argument, all other args "
783 if (kw && PyDict_Size(kw) > 0) {
787 PyObject *key, *value;
789 while (PyDict_Next(kw, &
pos, &key, &value)) {
790 const char *slot_name = PyUnicode_AsUTF8(key);
794 PyErr_Format(PyExc_TypeError,
795 "%.200s: keyword \"%.200s\" is invalid for this operator",
819 ret = Py_NewRef(Py_None);
834 if (item ==
nullptr) {
835 item = Py_NewRef(Py_None);
842 const char *ch = strchr(slot->
slot_name,
'.');
845 memcpy(slot_name_strip, slot->
slot_name, tot);
846 slot_name_strip[tot] =
'\0';
847 PyDict_SetItemString(
ret, slot_name_strip, item);
#define BLI_STATIC_ASSERT(a, msg)
BLI_INLINE void * BLI_ghashIterator_getKey(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
BLI_INLINE void * BLI_ghashIterator_getValue(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
#define GHASH_ITER(gh_iter_, ghash_)
unsigned int BLI_ghash_len(const GHash *gh) ATTR_WARN_UNUSED_RESULT
void BMO_error_clear(BMesh *bm)
bool BMO_error_occurred_at_level(BMesh *bm, eBMOpErrorLevel level)
void bool BMO_error_get(BMesh *bm, const char **r_msg, BMOperator **r_op, eBMOpErrorLevel *r_level)
const char bm_iter_itype_htype_map[BM_ITYPE_MAX]
void * BMO_slot_buffer_alloc(BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, int len)
void * BMO_slot_buffer_get_single(BMOpSlot *slot)
#define BMO_SLOT_AS_VECTOR(slot)
void BMO_slot_mat_set(BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const float *mat, int size)
#define BMO_SLOT_AS_FLOAT(slot)
@ BMO_OP_SLOT_SUBTYPE_ELEM_IS_SINGLE
@ BMO_OP_SLOT_ELEMENT_BUF
void BMO_slot_buffer_from_single(BMOperator *op, BMOpSlot *slot, BMHeader *ele)
BMOpSlot * BMO_slot_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *identifier)
BMESH OPSTACK GET SLOT.
void BMO_op_exec(BMesh *bm, BMOperator *op)
BMESH OPSTACK EXEC OP.
#define BMO_SLOT_AS_BUFFER(slot)
@ BMO_OP_SLOT_SUBTYPE_MAP_ELEM
@ BMO_OP_SLOT_SUBTYPE_MAP_BOOL
@ BMO_OP_SLOT_SUBTYPE_MAP_INTERNAL
@ BMO_OP_SLOT_SUBTYPE_MAP_INT
@ BMO_OP_SLOT_SUBTYPE_MAP_EMPTY
@ BMO_OP_SLOT_SUBTYPE_MAP_FLT
@ BMO_OP_SLOT_SUBTYPE_INT_FLAG
@ BMO_OP_SLOT_SUBTYPE_INT_ENUM
#define BMO_SLOT_AS_GHASH(slot)
void BMO_op_init(BMesh *bm, BMOperator *op, int flag, const char *opname)
BMESH OPSTACK INIT OP.
#define BMO_SLOT_AS_BOOL(slot)
#define BMO_SLOT_AS_MATRIX(slot)
void BMO_op_finish(BMesh *bm, BMOperator *op)
BMESH OPSTACK FINISH OP.
void BMO_slot_buffer_from_all(BMesh *bm, BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, char htype)
BMO_ALL_TO_SLOT.
#define BMO_FLAG_DEFAULTS
bool BMO_slot_exists(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *identifier)
BMESH OPSTACK HAS SLOT.
#define BMO_SLOT_AS_INT(slot)
BLI_INLINE void BMO_slot_map_int_insert(BMOperator *op, BMOpSlot *slot, void *element, const int val)
BLI_INLINE void BMO_slot_map_elem_insert(BMOperator *op, BMOpSlot *slot, const void *element, void *val)
BLI_INLINE void BMO_slot_map_float_insert(BMOperator *op, BMOpSlot *slot, void *element, const float val)
BLI_INLINE void BMO_slot_map_empty_insert(BMOperator *op, BMOpSlot *slot, const void *element)
BLI_INLINE void BMO_slot_map_bool_insert(BMOperator *op, BMOpSlot *slot, void *element, const bool val)
PyObject * BPy_BMO_call(BPy_BMeshOpFunc *self, PyObject *args, PyObject *kw)
static int bpy_bm_op_as_py_error(BMesh *bm)
static int bpy_slot_from_py_elemseq_check(BPy_BMGeneric *value, BMesh *bm, const char htype_py, const char htype_bmo, const char *opname, const char *slot_name, const char *descr)
Utility function to check BMVertSeq/BMEdgeSeq/BMFaceSeq's.
static int bpy_slot_from_py_elem_check(BPy_BMElem *value, BMesh *bm, const char htype, const char *opname, const char *slot_name, const char *descr)
Utility function to check BMVert/BMEdge/BMFace's.
static PyObject * bpy_slot_to_py(BMesh *bm, BMOpSlot *slot)
static int bpy_slot_from_py(BMesh *bm, BMOperator *bmop, BMOpSlot *slot, PyObject *value, const char *opname, const char *slot_name)
PyObject * BPy_BMElem_CreatePyObject(BMesh *bm, BMHeader *ele)
void * BPy_BMElem_PySeq_As_Array(BMesh **r_bm, PyObject *seq, Py_ssize_t min, Py_ssize_t max, Py_ssize_t *r_seq_num, const char htype, const bool do_unique_check, const bool do_bm_check, const char *error_prefix)
char * BPy_BMElem_StringFromHType(const char htype)
char * BPy_BMElem_StringFromHType_ex(const char htype, char ret[32])
#define BPY_BM_CHECK_OBJ(obj)
#define BPy_BMVertSeq_Check(v)
#define BPy_BMFaceSeq_Check(v)
#define BPy_BMElemSeq_Check(v)
#define BPy_BMElem_Check(v)
#define BPy_BMesh_Check(v)
#define BPy_BMEdgeSeq_Check(v)
#define BM_ITER_BPY_BM_SEQ(ele, iter, bpy_bmelemseq)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
int mathutils_array_parse(float *array, int array_num_min, int array_num_max, PyObject *value, const char *error_prefix)
PyObject * Matrix_CreatePyObject(const float *mat, const ushort col_num, const ushort row_num, PyTypeObject *base_type)
int Matrix_ParseAny(PyObject *o, void *p)
PyObject * Vector_CreatePyObject(const float *vec, const int vec_num, PyTypeObject *base_type)
int PyC_FlagSet_ValueFromID(const PyC_FlagSet *item, const char *identifier, int *r_value, const char *error_prefix)
int PyC_Long_AsBool(PyObject *value)
int PyC_FlagSet_ToBitfield(const PyC_FlagSet *items, PyObject *value, int *r_value, const char *error_prefix)
union BMOpSlot::@313121210037300127305053354046356312170117023254 data
eBMOpSlotSubType_Union slot_subtype
struct BMOpSlot::@313121210037300127305053354046356312170117023254::@263061076130337244124145337307265057223360175210 enum_data
struct BMOpSlot slots_out[BMO_OP_MAX_SLOTS]
struct BMOpSlot slots_in[BMO_OP_MAX_SLOTS]
PyObject_VAR_HEAD BMesh * bm
PyObject_VAR_HEAD BMesh * bm
PyObject_VAR_HEAD BMesh * bm
eBMOpSlotSubType_Int intg
eBMOpSlotSubType_Elem elem