Blender
V3.3
|
#include <Python.h>
#include <structmember.h>
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "bpy_utils_units.h"
#include "../generic/py_capi_utils.h"
#include "BKE_unit.h"
Go to the source code of this file.
Macros | |
#define | PY_SSIZE_T_CLEAN |
Functions | |
BLI_STATIC_ASSERT (ARRAY_SIZE(bpyunits_ucategories_items)==B_UNIT_TYPE_TOT+1, "`bpyunits_ucategories_items` should match `B_UNIT_` enum items in `BKE_units.h`") | |
static PyObject * | py_structseq_from_strings (PyTypeObject *py_type, PyStructSequence_Desc *py_sseq_desc, const char **str_items) |
static bool | bpyunits_validate (const char *usys_str, const char *ucat_str, int *r_usys, int *r_ucat) |
PyDoc_STRVAR (bpyunits_to_value_doc, ".. method:: to_value(unit_system, unit_category, str_input, str_ref_unit=None)\n" "\n" " Convert a given input string into a float value.\n" "\n" " :arg unit_system: The unit system, from :attr:`bpy.utils.units.systems`.\n" " :type unit_system: string\n" " :arg unit_category: The category of data we are converting (length, area, rotation, " "etc.),\n" " from :attr:`bpy.utils.units.categories`.\n" " :type unit_category: string\n" " :arg str_input: The string to convert to a float value.\n" " :type str_input: string\n" " :arg str_ref_unit: A reference string from which to extract a default unit, if none is " "found in ``str_input``.\n" " :type str_ref_unit: string or None\n" " :return: The converted/interpreted value.\n" " :rtype: float\n" " :raises ValueError: if conversion fails to generate a valid python float value.\n") | |
static PyObject * | bpyunits_to_value (PyObject *UNUSED(self), PyObject *args, PyObject *kw) |
PyDoc_STRVAR (bpyunits_to_string_doc, ".. method:: to_string(unit_system, unit_category, value, precision=3, " "split_unit=False, compatible_unit=False)\n" "\n" " Convert a given input float value into a string with units.\n" "\n" " :arg unit_system: The unit system, from :attr:`bpy.utils.units.systems`.\n" " :type unit_system: string\n" " :arg unit_category: The category of data we are converting (length, area, " "rotation, etc.),\n" " from :attr:`bpy.utils.units.categories`.\n" " :type unit_category: string\n" " :arg value: The value to convert to a string.\n" " :type value: float\n" " :arg precision: Number of digits after the comma.\n" " :type precision: int\n" " :arg split_unit: Whether to use several units if needed (1m1cm), or always only " "one (1.01m).\n" " :type split_unit: bool\n" " :arg compatible_unit: Whether to use keyboard-friendly units (1m2) or nicer " "utf-8 ones (1m²).\n" " :type compatible_unit: bool\n" " :return: The converted string.\n" " :rtype: str\n" " :raises ValueError: if conversion fails to generate a valid python string.\n") | |
static PyObject * | bpyunits_to_string (PyObject *UNUSED(self), PyObject *args, PyObject *kw) |
PyDoc_STRVAR (bpyunits_doc, "This module contains some data/methods regarding units handling.") | |
PyObject * | BPY_utils_units (void) |
Variables | |
static PyTypeObject | BPyUnitsSystemsType |
static PyTypeObject | BPyUnitsCategoriesType |
static const char * | bpyunits_usystem_items [] |
static const char * | bpyunits_ucategories_items [] |
static PyStructSequence_Desc | bpyunits_categories_desc |
static PyMethodDef | bpyunits_methods [] |
static struct PyModuleDef | bpyunits_module |
This file defines a singleton py object accessed via 'bpy.utils.units', which exposes various data and functions useful in units handling.
Definition in file bpy_utils_units.c.
#define PY_SSIZE_T_CLEAN |
Definition at line 11 of file bpy_utils_units.c.
BLI_STATIC_ASSERT | ( | ARRAY_SIZE(bpyunits_ucategories_items) | = = B_UNIT_TYPE_TOT + 1 , |
"`bpyunits_ucategories_items` should match `B_UNIT_` enum items in `BKE_units.h`" | |||
) |
Definition at line 55 of file bpy_utils_units.c.
References ARRAY_SIZE.
PyObject* BPY_utils_units | ( | void | ) |
Definition at line 349 of file bpy_utils_units.c.
References bpyunits_categories_desc, bpyunits_module, bpyunits_ucategories_items, bpyunits_usystem_items, BPyUnitsCategoriesType, BPyUnitsSystemsType, and py_structseq_from_strings().
Referenced by BPy_init_modules().
|
static |
Definition at line 246 of file bpy_utils_units.c.
References BKE_unit_name_to_alt(), BKE_unit_value_as_string_adaptive(), bpyunits_validate(), NULL, PyC_ParseBool(), result, and str.
|
static |
Definition at line 160 of file bpy_utils_units.c.
References BKE_unit_replace_string(), BLI_strncpy(), bpyunits_validate(), NULL, PyC_RunString_AsNumber(), result, ret, and str.
|
static |
Definition at line 115 of file bpy_utils_units.c.
References BKE_unit_is_valid(), BLI_str_index_in_array(), bpyunits_ucategories_items, and bpyunits_usystem_items.
Referenced by bpyunits_to_string(), and bpyunits_to_value().
|
static |
Simple utility function to initialize #PyStructSequence_Desc
Definition at line 83 of file bpy_utils_units.c.
References BLI_assert, NULL, and pos.
Referenced by BPY_utils_units().
PyDoc_STRVAR | ( | bpyunits_to_string_doc | , |
".. method:: to_string(unit_system, unit_category, value, precision=3, " "split_unit=False, compatible_unit=False)\n" "\n" " Convert a given input float value into a string with units.\n" "\n" " :arg unit_system: The unit | system, | ||
from :attr:`bpy.utils.units.systems`.\n" " :type unit_system:string\n" " :arg unit_category:The category of data we are | convertinglength, area, " "rotation, etc., | ||
\n" " from :attr:`bpy.utils.units.categories`.\n" " :type unit_category:string\n" " :arg value:The value to convert to a string.\n" " :type value:float\n" " :arg precision:Number of digits after the comma.\n" " :type precision:int\n" " :arg split_unit:Whether to use several units if | needed1m1cm, | ||
or always only " "one(1.01m).\n" " :type split_unit:bool\n" " :arg compatible_unit:Whether to use keyboard-friendly units(1m2) or nicer " "utf-8 ones(1m²).\n" " :type compatible_unit:bool\n" " :return:The converted string.\n" " :rtype:str\n" " :raises ValueError:if conversion fails to generate a valid python string.\n" | |||
) |
PyDoc_STRVAR | ( | bpyunits_to_value_doc | , |
".. method:: to_value(unit_system, unit_category, str_input, str_ref_unit=None)\n" "\n" " Convert a given input string into a float value.\n" "\n" " :arg unit_system: The unit | system, | ||
from :attr:`bpy.utils.units.systems`.\n" " :type unit_system:string\n" " :arg unit_category:The category of data we are | convertinglength, area, rotation, " "etc., | ||
\n" " from :attr:`bpy.utils.units.categories`.\n" " :type unit_category:string\n" " :arg str_input:The string to convert to a float value.\n" " :type str_input:string\n" " :arg str_ref_unit:A reference string from which to extract a default | unit, | ||
if none is " "found in ``str_input``.\n" " :type str_ref_unit:string or None\n" " :return:The converted/interpreted value.\n" " :rtype:float\n" " :raises ValueError:if conversion fails to generate a valid python float value.\n" | |||
) |
|
static |
Definition at line 73 of file bpy_utils_units.c.
Referenced by BPY_utils_units().
|
static |
Definition at line 323 of file bpy_utils_units.c.
|
static |
Definition at line 335 of file bpy_utils_units.c.
Referenced by BPY_utils_units().
|
static |
Definition at line 38 of file bpy_utils_units.c.
Referenced by BPY_utils_units(), and bpyunits_validate().
|
static |
Definition at line 31 of file bpy_utils_units.c.
Referenced by BPY_utils_units(), and bpyunits_validate().
|
static |
Definition at line 28 of file bpy_utils_units.c.
Referenced by BPY_utils_units().
|
static |
Definition at line 27 of file bpy_utils_units.c.
Referenced by BPY_utils_units().