blenderproc.python.modules.provider.getter.Entity module

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

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

Returns a list of objects that comply with defined conditions.

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

{
  "provider": "getter.Entity",
  "conditions": {
    "name": "Suzanne.*"
  }
}

Example 2: Returns the first object to: {match the name pattern “Suzanne”, AND to be of a MESH type}, OR {match the name pattern, AND have a certain value of a cust. prop} OR {be inside a bounding box defined by a min and max points} OR {have a Z position in space greater than -1}

{
  "provider": "getter.Entity",
  "index": 0,
  "conditions": [
  {
    "name": "Suzanne",
    "type": "MESH"
  },
  {
    "name": "Cube.*",
    "cp_category": "is_cube"
  },
  {
    "cf_inside": {
    "min": "[-5, -5, -5]",
    "max": "[5, 5, 5]"
    }
  },
  {
    "cf_inside": {
      "z_min": -1,
    }
  }
  ]
}

Example 3: Returns two random objects of MESH type.

{
  "provider": "getter.Entity",
  "random_samples": 2,
  "conditions": {
    "type": "MESH"
  }
}

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

Custom functions

Parameter Description Type
cf_{inside,outside} Returns objects that lies inside/outside of a bounding box or with a specific coordinate component >,< than a value. dict
cf_{inside,outside}/(min,max) min and max pair defines a bounding box used for a check. cannot be mixed with /[xyz]_{min,max} configuration. list ([x, y, z])
cf_{inside,outside}/[xyz]_(min,max) Alternative syntax. Defines a hyperplane. Missing arguments extend the bounding box to infinity in that direction. float
_get_conditions_as_string()[source]

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

perform_and_condition_check(and_condition, objects)[source]

Checks all objects in the scene if all given conditions are true for an object, it is added to the list.

Parameters:
  • and_condition – Given conditions. Type: dict.
  • objects – Objects, that are already in the return list. Type: list.
Returns:

Objects that fulfilled given conditions. Type: list.

run()[source]

Processes defined conditions and compiles a list of objects.

Returns:List of objects that met the conditional requirement. Type: list.