blenderproc.python.modules.provider.getter.Attribute module

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

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

Returns a value that is the result of selecting entities using getter.Entity Provider, getting the list of values of selected entities’ attributes/custom properties/custom-processed data, and of the optional operations on this list.

Example 1: Get a list of locations of objects (which names match the pattern).

{
  "provider": "getter.Attribute",
  "entities": {
    "provider": "getter.Entity",
    "conditions": {
      "name": "Icosphere.*"
    }
  },
  "get": "location"
  # add "transform_by": "sum" to get one value that represents the sum of those locations.
}

Example 2: Get a list of custom property “id” values of objects (which “physics” cp value is True).

{
  "provider": "getter.Attribute",
  "entities": {
    "provider": "getter.Entity",
    "conditions": {
      "cp_physics": "True"
    }
  },
  "get": "cp_id"
}

Example 3: Get a list of mean coordinates of objects (which name matches the pattern) bounding boxes.

{
  "provider": "getter.Attribute",
  "entities": {
    "provider": "getter.Entity",
    "conditions": {
      "name": "Cube.*"
    }
  },
  "get": "cf_bounding_box_means"
  # add "transform_by": "avg" to get one value that represents the average coordinates of those bounding boxes
}

Configuration:

Parameter Description Type
entities List of objects selected by the getter.Entity Provider. list
get Attribute/Custom property/custom function name on which the return value is based. Must be a valid name of selected entities’ attribute/custom property, or a custom function name. Every entity selected must have this attribute, custom prop, or must be usable in a custom function, otherwise an exception will be thrown. ” In order to specify, what exactly one wants to get (e.g. attribute, custom property, etc.): For attribute: key of the pair must be a valid attribute name of the all selected entities. 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 function names. string
transform_by Name of the operation to perform on the list of attributes/custom property/custom data values. See table below for supported operation names. string.
index If set, after the conditions are applied only the corresponding value of entity with the specified index is returned. int

Custom functions:

Parameter Description Type
cf_bounding_box_means Custom function name for get parameter. Invokes a chain of operations which returns a list of arithmetic means of coordinates of object aligned bounding boxes’ of selected objects in world coordinates format. (return). list

Operations:

Parameter Description Type
sum Returns the sum of all values of the input list. (return). float
avg Returns the average value of all values of the input list. (return). float
_avg(raw_result)[source]

Sums up the values of the list and divides the sum by the amount of items in the list.

Returns:The average value of all values of the input list.
_check_compatibility(raw_result)[source]

Checks if the list of values contains appropriate data of int, float, or mathutils.Vector type.

Parameters:raw_result – list of selected objects’ attribute/custom prop./or custom data values. Type: List
Returns:True if list is of int (and or) float, or mathutils.Vector data type. False if not. Type: bool.
_sum(raw_result)[source]

Sums up the values of the list.

Returns:The sum of all values of the input list.
run()[source]
Selects objects, gets a list of appropriate values of objects’ attributes, custom properties, or some
processed custom data and optionally performs some operation of this list.
Returns:List of values (only if get was specified or a custom function was called) or a singular int, float, or mathutils.Vector value (if some operation was applied).