DataView#
- class omni.graph.core.DataView(*args, **kwargs)#
Bases:
object
Helper class for getting and setting attribute data values. The setting operation is undoable.
- Interfaces:
force_usd_update get get_array_size gpu_ptr_kind set
All of the interface functions can either be called from an instantiation of this object or from a class method of the same name with an added attribute parameter that tells where to get and set values.
Methods
__init__
(*args, **kwargs)Initializes the data view class to prepare it for evaluting or setting an attribute value, The arguments are flexible so that you can either construct an object that will persist its settings across all method calls, or you can pass in overrides to the method calls to use instead.
force_usd_update
([force_update])get
(*args, **kwargs)Returns the current value on the owned attribute.
get_array_size
(*args, **kwargs)Returns the current number of array elements on the owned attribute.
set
(*args, **kwargs)Sets the current value on the owned attribute.
Attributes
The memory location of pointers to GPU arrays
- __init__(*args, **kwargs)#
Initializes the data view class to prepare it for evaluting or setting an attribute value, The arguments are flexible so that you can either construct an object that will persist its settings across all method calls, or you can pass in overrides to the method calls to use instead. In the case of classmethod calls the values passed in will be the only ones used.
The “attribute” value can be used by keyword or positionally. All other arguments must specify their keyword.
og.Controller(update_usd=True) # Good og.Controller("inputs:attr") # Good og.Controller(update_usd=True, attribute="inputs:attr") # Good og.Controller("inputs:attr", True) # Bad
- Parameters:
attribute – (AttributeWithValue_t) Description of an attribute object with data that can be accessed
update_usd – (bool) Should the modification to the value immediately update the USD? Defaults to True
undoable – (bool) Is the modification to the value undoable? Defaults to True
on_gpu – (bool) Is the data being modified on the GPU? Defaults to True
gpu_ptr_kind – (og.PtrToPtrKind) How should GPU array data be returned? Defaults to True
instance – (int) When working with instantiated graphs, an index representing the instance
- classmethod get(*args, **kwargs) Any #
Returns the current value on the owned attribute.
This function can be called either from the class or using an instantiated object. The first argument is mandatory, being either the class or object. All others are by keyword or by position and optional, defaulting to the value set in the constructor in the object context and the function defaults in the class context.
- Parameters:
obj – Either cls or self depending on how the function was called
attribute – Attribute whose value is to be retrieved. If used in an object context and a value was provided in the constructor then this value overrides that value. It’s mandatory, so if it was not provided in the constructor or here then an error is raised.
on_gpu – Is the value stored on the GPU?
reserved_element_count – For array attributes, if not None then the array will pre-reserve this many elements
return_type – For array attributes this specifies how the return data is to be wrapped.
gpu_ptr_kind – Type of data to return for GPU arrays (only used if on_gpu=True)
instance – When working with instantiated graphs, an index representing the instance
- Raises:
OmniGraphError – If the current attribute is not valid or its value could not be retrieved
- classmethod get_array_size(*args, **kwargs) int #
Returns the current number of array elements on the owned attribute.
This function can be called either from the class or using an instantiated object. The first argument is positional, being either the class or object. All others are by keyword and optional, defaulting to the value set in the constructor in the object context and the function defaults in the class context.
- Parameters:
obj – Either cls or self depending on how get_array_size() was called
attribute – Attribute whose size is to be retrieved. If used in an object context and a value was provided in the constructor then this value overrides that value. It’s mandatory, so if it was not provided in the constructor or here then an error is raised.
- Raises:
OmniGraphError – If the current attribute is not valid or is not an array type
- classmethod set(*args, **kwargs) bool #
Sets the current value on the owned attribute. This is an undoable action.
This function can be called either from the class or using an instantiated object. Both the attribute and value argument are mandatory and will raise an error if omitted. The attribute value may optionally be set through the constructor instead, if this function is called from an object context. These arguments may be set positionally or by keyword. The remaining arguments are optional but must be specified by keyword only. In an object context the defaults will be taken from the constructor, else they will use the function defaults.
og.Controller.set("inputs:attr", new_value) # Good og.Controller("inputs:attr").set(new_value) # Good og.Controller.set("inputs:attr") # Bad - missing value og.Controller.set("inputs:attr", new_value, undoable=False) # Good og.Controller("inputs:attr", undoable=False).set(new_value) # Good
- Parameters:
obj – Either cls or self depending on how the function was called
attribute – Attribute whose value is to be set. If used in an object context and a value was provided in the constructor then this value overrides that value. It’s mandatory, so if it was not provided in the constructor or here then an error is raised.
value – The new value for the attribute. It’s mandatory, so if it was not provided in the constructor or here then an error is raised.
on_gpu – Is the value stored on the GPU?
update_usd – Should the value immediately propagate to USD?
undoable – If True the operation is added to the undo queue, else it is done immediately and forgotten
gpu_ptr_kind – Type of data to expect for GPU arrays (only used if on_gpu=True)
- Returns:
True if the value was set successfully
- Return type:
bool
- Raises:
OmniGraphError – If the current attribute is not valid or could not be set to the given value
- property gpu_ptr_kind: PtrToPtrKind#
The memory location of pointers to GPU arrays
- Type: