blenderproc.python.types.StructUtility module

The base class of all things in BlenderProc.

class blenderproc.python.types.StructUtility.Struct(bpy_object)[source]

Bases: object

The base class of all things in BlenderProc, this can be an Entity in the scene or a Material which is only applied to a MeshObject.

clear_all_cps()[source]

Removes all existing custom properties the struct has.

del_cp(key)[source]

Removes the custom property with the given key.

Parameters:

key (str) – The key of the custom property to remove.

get_all_cps()[source]

Returns all custom properties as key, value pairs.

Return type:

Dict[str, Any]

Returns:

A dictionary of custom properties as key, value pairs

get_attr(attr_name)[source]

Returns the value of the attribute with the given name.

Parameters:

attr_name (str) – The name of the attribute.

Return type:

Any

Returns:

The value of the attribute

get_cp(key, frame=None)[source]

Returns the custom property with the given key.

Parameters:
  • key (str) – The key of the custom property.

  • frame (Optional[int]) – The frame number which the value should be set to. If None is given, the current frame number is used.

Return type:

Any

Returns:

The value of the custom property.

get_name()[source]

Returns the name of the struct.

Return type:

str

Returns:

The name.

has_cp(key)[source]

Return whether a custom property with the given key exists.

Parameters:

key (str) – The key of the custom property to check.

Return type:

bool

Returns:

True, if the custom property exists.

is_valid()[source]

Check whether the contained blender reference is valid.

The reference might become invalid after an undo operation or when the referenced struct is deleted.

Returns:

True, if it is valid.

set_cp(key, value, frame=None)[source]

Sets the custom property with the given key. The key can not be the same as any member over the stored blender object.

Keyframes can be only set for custom properties for the types int, float or bool.

Parameters:
  • key (str) – The key of the custom property.

  • value (Any) – The value to set.

  • frame (Optional[int]) – The frame number which the value should be set to. If None is given, the current frame number is used.

set_name(name)[source]

Sets the name of the struct.

Parameters:

name (str) – The new name.