Blender V5.3
bpy_utils_units.cc File Reference
#include <Python.h>
#include <structmember.h>
#include "BLI_string.hh"
#include "BLI_utildefines.hh"
#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.

Namespaces

namespace  blender
 BMesh Iterators.

Macros

#define PY_SSIZE_T_CLEAN

Functions

 blender::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 * blender::py_structseq_from_strings (PyTypeObject *py_type, PyStructSequence_Desc *py_sseq_desc, const char **str_items)
static bool blender::bpyunits_validate (const char *usys_str, const char *ucat_str, int *r_usys, int *r_ucat)
 blender::PyDoc_STRVAR (bpyunits_to_value_doc, ".. function:: 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" " :param unit_system: The unit system, from :attr:`bpy.utils.units.systems`.\n" " :type unit_system: str\n" " :param 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" " :param str_input: The string to convert to a float value.\n" " :type str_input: str\n" " :param 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 * blender::bpyunits_to_value (PyObject *, PyObject *args, PyObject *kw)
 blender::PyDoc_STRVAR (bpyunits_to_string_doc, ".. function:: 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" " :param unit_system: The unit system, from :attr:`bpy.utils.units.systems`.\n" " :type unit_system: str\n" " :param 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" " :param value: The value to convert to a string.\n" " :type value: float\n" " :param precision: Number of digits after the decimal point.\n" " :type precision: int\n" " :param split_unit: Whether to use several units if needed (1m1cm), or always only " "one (1.01m).\n" " :type split_unit: bool\n" " :param compatible_unit: Whether to use keyboard-friendly units (1m2) or nicer " "UTF8 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 * blender::bpyunits_to_string (PyObject *, PyObject *args, PyObject *kw)
 blender::PyDoc_STRVAR (bpyunits_doc, "This module contains some data/methods regarding units handling.\n")
PyObject * blender::BPY_utils_units ()

Variables

static PyTypeObject blender::BPyUnitsSystemsType
static PyTypeObject blender::BPyUnitsCategoriesType
static const char * blender::bpyunits_usystem_items []
static const char * blender::bpyunits_ucategories_items []
static PyStructSequence_Field blender::bpyunits_categories_fields [ARRAY_SIZE(bpyunits_ucategories_items)]
static PyStructSequence_Desc blender::bpyunits_systems_desc
static PyStructSequence_Desc blender::bpyunits_categories_desc
static PyMethodDef blender::bpyunits_methods []
static PyModuleDef blender::bpyunits_module

Detailed Description

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.

Macro Definition Documentation

◆ PY_SSIZE_T_CLEAN

#define PY_SSIZE_T_CLEAN

Definition at line 13 of file bpy_utils_units.cc.