|
Blender V4.3
|
#include <Python.h>#include <structmember.h>#include "BLI_string.h"#include "BLI_utildefines.h"#include "bpy_utils_units.hh"#include "../generic/py_capi_utils.hh"#include "../generic/python_compat.hh"#include "BKE_unit.hh"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 PyStructSequence_Field bpyunits_systems_fields[ARRAY_SIZE(bpyunits_usystem_items)] | |
| 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: str\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: str\n" " :arg str_input: The string to convert to a float value.\n" " :type str_input: str\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: str | 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 *, 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: str\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: str\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 *, PyObject *args, PyObject *kw) |
| PyDoc_STRVAR (bpyunits_doc, "This module contains some data/methods regarding units handling.") | |
| PyObject * | BPY_utils_units () |
Variables | |
| static PyTypeObject | BPyUnitsSystemsType |
| static PyTypeObject | BPyUnitsCategoriesType |
| static const char * | bpyunits_usystem_items [] |
| static const char * | bpyunits_ucategories_items [] |
| static PyStructSequence_Field | bpyunits_categories_fields [ARRAY_SIZE(bpyunits_ucategories_items)] |
| static PyStructSequence_Desc | bpyunits_systems_desc |
| static PyStructSequence_Desc | bpyunits_categories_desc |
| static PyMethodDef | bpyunits_methods [] |
| static 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.cc.
| #define PY_SSIZE_T_CLEAN |
Definition at line 13 of file bpy_utils_units.cc.
| 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`" | ) |
These fields are just empty placeholders, actual values get set in initializations functions. This allows us to avoid many handwriting, and above all, to keep all systems/categories definition stuff in BKE_unit.hh.
| PyObject * BPY_utils_units | ( | ) |
Definition at line 375 of file bpy_utils_units.cc.
References bpyunits_categories_desc, bpyunits_module, bpyunits_systems_desc, bpyunits_ucategories_items, bpyunits_usystem_items, BPyUnitsCategoriesType, BPyUnitsSystemsType, and py_structseq_from_strings().
Referenced by BPy_init_modules().
|
static |
Definition at line 257 of file bpy_utils_units.cc.
References BKE_unit_name_to_alt(), BKE_unit_value_as_string_adaptive(), bpyunits_validate(), PY_ARG_PARSER_HEAD_COMPAT, PyC_ParseBool(), result, and str.
|
static |
Definition at line 167 of file bpy_utils_units.cc.
References BKE_unit_replace_string(), BLI_strncpy(), bpyunits_validate(), PY_ARG_PARSER_HEAD_COMPAT, PyC_RunString_AsNumber(), result, ret, and str.
|
static |
Definition at line 121 of file bpy_utils_units.cc.
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 89 of file bpy_utils_units.cc.
References BLI_assert, 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:str\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:str\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:str\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:str\n" " :arg str_input:The string to convert to a float value.\n" " :type str_input:str\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:str|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 79 of file bpy_utils_units.cc.
Referenced by BPY_utils_units().
|
static |
Definition at line 71 of file bpy_utils_units.cc.
|
static |
Definition at line 342 of file bpy_utils_units.cc.
|
static |
Definition at line 363 of file bpy_utils_units.cc.
Referenced by BPY_utils_units().
|
static |
Definition at line 73 of file bpy_utils_units.cc.
Referenced by BPY_utils_units().
|
static |
Definition at line 41 of file bpy_utils_units.cc.
Referenced by BPY_utils_units(), and bpyunits_validate().
|
static |
Definition at line 34 of file bpy_utils_units.cc.
Referenced by BPY_utils_units(), and bpyunits_validate().
|
static |
Definition at line 31 of file bpy_utils_units.cc.
Referenced by BPY_utils_units().
|
static |
Definition at line 30 of file bpy_utils_units.cc.
Referenced by BPY_utils_units().