blenderproc.python.modules.provider.getter.Texture module

class blenderproc.python.modules.provider.getter.Texture.Texture(config)[source]

Bases: blenderproc.python.modules.main.Provider.Provider

Returns a list of textures in accordance with defined conditions.

Example 1: Return a list of textures that match a name pattern.

{
  "provider": "getter.Texture",
  "conditions": {
    "name": "ct_.*"
  }
}

Example 2: Returns the first texture to: {match the name pattern, AND to have nodes use enabled }, OR {match anothername pattern, AND have a certain value of a cust. prop}

{
  "provider": "getter.Texture",
  "index": 0,
  "conditions": [
  {
    "name": "ct_1.*",
    "use_nodes": True
  },
  {
    "name": "ct_2.*",
    "cp_type": "custom"
  }]
}

Example 3: Returns two random textures with a certain value of a custom property.

{
  "provider": "getter.Texture",
  "random_samples": 2,
  "conditions": {
    "cp_type": "custom"
  }
}

Configuration:

Parameter Description Type
conditions List of dicts/a dict of entries of format {attribute_name: attribute_value}. Entries in a dict are conditions connected with AND, if there multiple dicts are defined (i.e. ‘conditions’ is a list of dicts, each cell is connected by OR. list/dict
conditions/attribute_name Name of any valid object’s attribute, custom property, or custom function. Any given attribute_value of the type string will be treated as a REGULAR EXPRESSION. Also, any attribute_value for a custom property can be a string/int/bool/float, while only attribute_value for valid attributes of objects can be a bool or a list (mathutils.Vector, mathurils.Color and mathutils.Euler are covered by the ‘list’ type). ” In order to specify, what exactly one wants to look for: For attribute: key of the pair must be a valid attribute name. For custom property: key of the pair must start with cp_ prefix. For calling custom function: key of the pair must start with cf_ prefix. See table below for supported custom functions. string
conditions/attribute_value Any value to set. . string, list/Vector, int, bool or float
index If set, after the conditions are applied only the entity with the specified index is returned. int
random_samples If set, this Provider returns random_samples objects from the pool of selected ones. Define index or random_samples property, only one is allowed at a time. Default: 0. int
check_empty If this is True, the returned list can not be empty, if it is empty an error will be thrown. Default: False. bool
_get_conditions_as_string()[source]

Returns the used conditions as neatly formatted string :return: str: containing the conditions

static perform_and_condition_check(and_condition, textures, used_textures_to_check=None)[source]

Checks for all textures and if all given conditions are true, collects them in the return list.

Parameters:
  • and_condition – Given conditions. Type: dict.
  • textures – Textures, that are already in the return list. Type: list.
  • used_textures_to_check – Textures to perform the check on. Type: list. Default: all materials
Returns:

Textures that comply with given conditions. Type: list.

run()[source]