file_path
stringlengths 22
162
| content
stringlengths 19
501k
| size
int64 19
501k
| lang
stringclasses 1
value | avg_line_length
float64 6.33
100
| max_line_length
int64 18
935
| alphanum_fraction
float64 0.34
0.93
|
---|---|---|---|---|---|---|
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/OgnBouncingCubesGpuDatabase.py | """Support for simplified access to data on nodes of type omni.graph.examples.python.BouncingCubesGpu
Deprecated node - no longer supported
"""
import sys
import traceback
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnBouncingCubesGpuDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.examples.python.BouncingCubesGpu
Class Members:
node: Node being evaluated
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
])
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = []
self._batchedReadValues = []
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedWriteValues = { }
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnBouncingCubesGpuDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnBouncingCubesGpuDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnBouncingCubesGpuDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
class abi:
"""Class defining the ABI interface for the node type"""
@staticmethod
def get_node_type():
get_node_type_function = getattr(OgnBouncingCubesGpuDatabase.NODE_TYPE_CLASS, 'get_node_type', None)
if callable(get_node_type_function):
return get_node_type_function()
return 'omni.graph.examples.python.BouncingCubesGpu'
@staticmethod
def compute(context, node):
def database_valid():
return True
try:
per_node_data = OgnBouncingCubesGpuDatabase.PER_NODE_DATA[node.node_id()]
db = per_node_data.get('_db')
if db is None:
db = OgnBouncingCubesGpuDatabase(node)
per_node_data['_db'] = db
if not database_valid():
per_node_data['_db'] = None
return False
except:
db = OgnBouncingCubesGpuDatabase(node)
try:
compute_function = getattr(OgnBouncingCubesGpuDatabase.NODE_TYPE_CLASS, 'compute', None)
if callable(compute_function) and compute_function.__code__.co_argcount > 1:
return compute_function(context, node)
db.inputs._prefetch()
db.inputs._setting_locked = True
with og.in_compute():
return OgnBouncingCubesGpuDatabase.NODE_TYPE_CLASS.compute(db)
except Exception as error:
stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next))
db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False)
finally:
db.inputs._setting_locked = False
db.outputs._commit()
return False
@staticmethod
def initialize(context, node):
OgnBouncingCubesGpuDatabase._initialize_per_node_data(node)
initialize_function = getattr(OgnBouncingCubesGpuDatabase.NODE_TYPE_CLASS, 'initialize', None)
if callable(initialize_function):
initialize_function(context, node)
per_node_data = OgnBouncingCubesGpuDatabase.PER_NODE_DATA[node.node_id()]
def on_connection_or_disconnection(*args):
per_node_data['_db'] = None
node.register_on_connected_callback(on_connection_or_disconnection)
node.register_on_disconnected_callback(on_connection_or_disconnection)
@staticmethod
def release(node):
release_function = getattr(OgnBouncingCubesGpuDatabase.NODE_TYPE_CLASS, 'release', None)
if callable(release_function):
release_function(node)
OgnBouncingCubesGpuDatabase._release_per_node_data(node)
@staticmethod
def release_instance(node, target):
OgnBouncingCubesGpuDatabase._release_per_node_instance_data(node, target)
@staticmethod
def update_node_version(context, node, old_version, new_version):
update_node_version_function = getattr(OgnBouncingCubesGpuDatabase.NODE_TYPE_CLASS, 'update_node_version', None)
if callable(update_node_version_function):
return update_node_version_function(context, node, old_version, new_version)
return False
@staticmethod
def initialize_type(node_type):
initialize_type_function = getattr(OgnBouncingCubesGpuDatabase.NODE_TYPE_CLASS, 'initialize_type', None)
needs_initializing = True
if callable(initialize_type_function):
needs_initializing = initialize_type_function(node_type)
if needs_initializing:
node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.examples.python")
node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Deprecated Node - Bouncing Cubes (GPU)")
node_type.set_metadata(ogn.MetadataKeys.MEMORY_TYPE, "cuda")
node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "examples")
node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "Deprecated node - no longer supported")
node_type.set_metadata(ogn.MetadataKeys.EXCLUSIONS, "usd,test")
node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python")
node_type.set_metadata(ogn.MetadataKeys.MEMORY_TYPE, "cuda")
node_type.set_has_state(True)
@staticmethod
def on_connection_type_resolve(node):
on_connection_type_resolve_function = getattr(OgnBouncingCubesGpuDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None)
if callable(on_connection_type_resolve_function):
on_connection_type_resolve_function(node)
NODE_TYPE_CLASS = None
@staticmethod
def register(node_type_class):
OgnBouncingCubesGpuDatabase.NODE_TYPE_CLASS = node_type_class
og.register_node_type(OgnBouncingCubesGpuDatabase.abi, 1)
@staticmethod
def deregister():
og.deregister_node_type("omni.graph.examples.python.BouncingCubesGpu")
| 9,183 | Python | 47.336842 | 138 | 0.653055 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/OgnBouncingCubesCpuDatabase.py | """Support for simplified access to data on nodes of type omni.graph.examples.python.BouncingCubes
Deprecated node - no longer supported
"""
import numpy
import sys
import traceback
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnBouncingCubesCpuDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.examples.python.BouncingCubes
Class Members:
node: Node being evaluated
Attribute Value Properties:
State:
state.translations
state.velocities
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('state:translations', 'float3[]', 0, 'Translations', 'Set of translation attributes gathered from the inputs.\nTranslations have velocities applied to them each evaluation.', {}, True, None, False, ''),
('state:velocities', 'float[]', 0, 'Velocities', 'Set of velocity attributes gathered from the inputs', {}, True, None, False, ''),
])
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = []
self._batchedReadValues = []
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedWriteValues = { }
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self.translations_size = None
self.velocities_size = None
@property
def translations(self):
data_view = og.AttributeValueHelper(self._attributes.translations)
self.translations_size = data_view.get_array_size()
return data_view.get()
@translations.setter
def translations(self, value):
data_view = og.AttributeValueHelper(self._attributes.translations)
data_view.set(value)
self.translations_size = data_view.get_array_size()
@property
def velocities(self):
data_view = og.AttributeValueHelper(self._attributes.velocities)
self.velocities_size = data_view.get_array_size()
return data_view.get()
@velocities.setter
def velocities(self, value):
data_view = og.AttributeValueHelper(self._attributes.velocities)
data_view.set(value)
self.velocities_size = data_view.get_array_size()
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnBouncingCubesCpuDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnBouncingCubesCpuDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnBouncingCubesCpuDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
class abi:
"""Class defining the ABI interface for the node type"""
@staticmethod
def get_node_type():
get_node_type_function = getattr(OgnBouncingCubesCpuDatabase.NODE_TYPE_CLASS, 'get_node_type', None)
if callable(get_node_type_function):
return get_node_type_function()
return 'omni.graph.examples.python.BouncingCubes'
@staticmethod
def compute(context, node):
def database_valid():
return True
try:
per_node_data = OgnBouncingCubesCpuDatabase.PER_NODE_DATA[node.node_id()]
db = per_node_data.get('_db')
if db is None:
db = OgnBouncingCubesCpuDatabase(node)
per_node_data['_db'] = db
if not database_valid():
per_node_data['_db'] = None
return False
except:
db = OgnBouncingCubesCpuDatabase(node)
try:
compute_function = getattr(OgnBouncingCubesCpuDatabase.NODE_TYPE_CLASS, 'compute', None)
if callable(compute_function) and compute_function.__code__.co_argcount > 1:
return compute_function(context, node)
db.inputs._prefetch()
db.inputs._setting_locked = True
with og.in_compute():
return OgnBouncingCubesCpuDatabase.NODE_TYPE_CLASS.compute(db)
except Exception as error:
stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next))
db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False)
finally:
db.inputs._setting_locked = False
db.outputs._commit()
return False
@staticmethod
def initialize(context, node):
OgnBouncingCubesCpuDatabase._initialize_per_node_data(node)
initialize_function = getattr(OgnBouncingCubesCpuDatabase.NODE_TYPE_CLASS, 'initialize', None)
if callable(initialize_function):
initialize_function(context, node)
per_node_data = OgnBouncingCubesCpuDatabase.PER_NODE_DATA[node.node_id()]
def on_connection_or_disconnection(*args):
per_node_data['_db'] = None
node.register_on_connected_callback(on_connection_or_disconnection)
node.register_on_disconnected_callback(on_connection_or_disconnection)
@staticmethod
def release(node):
release_function = getattr(OgnBouncingCubesCpuDatabase.NODE_TYPE_CLASS, 'release', None)
if callable(release_function):
release_function(node)
OgnBouncingCubesCpuDatabase._release_per_node_data(node)
@staticmethod
def release_instance(node, target):
OgnBouncingCubesCpuDatabase._release_per_node_instance_data(node, target)
@staticmethod
def update_node_version(context, node, old_version, new_version):
update_node_version_function = getattr(OgnBouncingCubesCpuDatabase.NODE_TYPE_CLASS, 'update_node_version', None)
if callable(update_node_version_function):
return update_node_version_function(context, node, old_version, new_version)
return False
@staticmethod
def initialize_type(node_type):
initialize_type_function = getattr(OgnBouncingCubesCpuDatabase.NODE_TYPE_CLASS, 'initialize_type', None)
needs_initializing = True
if callable(initialize_type_function):
needs_initializing = initialize_type_function(node_type)
if needs_initializing:
node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.examples.python")
node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Deprecated Node - Bouncing Cubes (GPU)")
node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "examples")
node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "Deprecated node - no longer supported")
node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python")
OgnBouncingCubesCpuDatabase.INTERFACE.add_to_node_type(node_type)
node_type.set_has_state(True)
@staticmethod
def on_connection_type_resolve(node):
on_connection_type_resolve_function = getattr(OgnBouncingCubesCpuDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None)
if callable(on_connection_type_resolve_function):
on_connection_type_resolve_function(node)
NODE_TYPE_CLASS = None
@staticmethod
def register(node_type_class):
OgnBouncingCubesCpuDatabase.NODE_TYPE_CLASS = node_type_class
og.register_node_type(OgnBouncingCubesCpuDatabase.abi, 1)
@staticmethod
def deregister():
og.deregister_node_type("omni.graph.examples.python.BouncingCubes")
| 10,508 | Python | 46.337838 | 211 | 0.649505 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/OgnPositionToColorDatabase.py | """Support for simplified access to data on nodes of type omni.graph.examples.python.PositionToColor
This node takes positional data (double3) and converts to a color, and outputs as color3f[] (which seems to be the default
color connection in USD)
"""
import numpy
import sys
import traceback
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnPositionToColorDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.examples.python.PositionToColor
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.color_offset
inputs.position
inputs.scale
Outputs:
outputs.color
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:color_offset', 'color3f', 0, None, 'Offset added to the scaled color to get the final result', {ogn.MetadataKeys.DEFAULT: '[0.0, 0.0, 0.0]'}, True, [0.0, 0.0, 0.0], False, ''),
('inputs:position', 'double3', 0, None, 'Position to be converted to a color', {ogn.MetadataKeys.DEFAULT: '[0.0, 0.0, 0.0]'}, True, [0.0, 0.0, 0.0], False, ''),
('inputs:scale', 'float', 0, None, 'Constant by which to multiply the position to get the color', {ogn.MetadataKeys.DEFAULT: '1.0'}, True, 1.0, False, ''),
('outputs:color', 'color3f[]', 0, None, 'Color value extracted from the position', {}, True, None, False, ''),
])
@classmethod
def _populate_role_data(cls):
"""Populate a role structure with the non-default roles on this node type"""
role_data = super()._populate_role_data()
role_data.inputs.color_offset = og.AttributeRole.COLOR
role_data.outputs.color = og.AttributeRole.COLOR
return role_data
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = {"color_offset", "position", "scale", "_setting_locked", "_batchedReadAttributes", "_batchedReadValues"}
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = [self._attributes.color_offset, self._attributes.position, self._attributes.scale]
self._batchedReadValues = [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], 1.0]
@property
def color_offset(self):
return self._batchedReadValues[0]
@color_offset.setter
def color_offset(self, value):
self._batchedReadValues[0] = value
@property
def position(self):
return self._batchedReadValues[1]
@position.setter
def position(self, value):
self._batchedReadValues[1] = value
@property
def scale(self):
return self._batchedReadValues[2]
@scale.setter
def scale(self, value):
self._batchedReadValues[2] = value
def __getattr__(self, item: str):
if item in self.LOCAL_PROPERTY_NAMES:
return object.__getattribute__(self, item)
else:
return super().__getattr__(item)
def __setattr__(self, item: str, new_value):
if item in self.LOCAL_PROPERTY_NAMES:
object.__setattr__(self, item, new_value)
else:
super().__setattr__(item, new_value)
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self.color_size = None
self._batchedWriteValues = { }
@property
def color(self):
data_view = og.AttributeValueHelper(self._attributes.color)
return data_view.get(reserved_element_count=self.color_size)
@color.setter
def color(self, value):
data_view = og.AttributeValueHelper(self._attributes.color)
data_view.set(value)
self.color_size = data_view.get_array_size()
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnPositionToColorDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnPositionToColorDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnPositionToColorDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
class abi:
"""Class defining the ABI interface for the node type"""
@staticmethod
def get_node_type():
get_node_type_function = getattr(OgnPositionToColorDatabase.NODE_TYPE_CLASS, 'get_node_type', None)
if callable(get_node_type_function):
return get_node_type_function()
return 'omni.graph.examples.python.PositionToColor'
@staticmethod
def compute(context, node):
def database_valid():
return True
try:
per_node_data = OgnPositionToColorDatabase.PER_NODE_DATA[node.node_id()]
db = per_node_data.get('_db')
if db is None:
db = OgnPositionToColorDatabase(node)
per_node_data['_db'] = db
if not database_valid():
per_node_data['_db'] = None
return False
except:
db = OgnPositionToColorDatabase(node)
try:
compute_function = getattr(OgnPositionToColorDatabase.NODE_TYPE_CLASS, 'compute', None)
if callable(compute_function) and compute_function.__code__.co_argcount > 1:
return compute_function(context, node)
db.inputs._prefetch()
db.inputs._setting_locked = True
with og.in_compute():
return OgnPositionToColorDatabase.NODE_TYPE_CLASS.compute(db)
except Exception as error:
stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next))
db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False)
finally:
db.inputs._setting_locked = False
db.outputs._commit()
return False
@staticmethod
def initialize(context, node):
OgnPositionToColorDatabase._initialize_per_node_data(node)
initialize_function = getattr(OgnPositionToColorDatabase.NODE_TYPE_CLASS, 'initialize', None)
if callable(initialize_function):
initialize_function(context, node)
per_node_data = OgnPositionToColorDatabase.PER_NODE_DATA[node.node_id()]
def on_connection_or_disconnection(*args):
per_node_data['_db'] = None
node.register_on_connected_callback(on_connection_or_disconnection)
node.register_on_disconnected_callback(on_connection_or_disconnection)
@staticmethod
def release(node):
release_function = getattr(OgnPositionToColorDatabase.NODE_TYPE_CLASS, 'release', None)
if callable(release_function):
release_function(node)
OgnPositionToColorDatabase._release_per_node_data(node)
@staticmethod
def release_instance(node, target):
OgnPositionToColorDatabase._release_per_node_instance_data(node, target)
@staticmethod
def update_node_version(context, node, old_version, new_version):
update_node_version_function = getattr(OgnPositionToColorDatabase.NODE_TYPE_CLASS, 'update_node_version', None)
if callable(update_node_version_function):
return update_node_version_function(context, node, old_version, new_version)
return False
@staticmethod
def initialize_type(node_type):
initialize_type_function = getattr(OgnPositionToColorDatabase.NODE_TYPE_CLASS, 'initialize_type', None)
needs_initializing = True
if callable(initialize_type_function):
needs_initializing = initialize_type_function(node_type)
if needs_initializing:
node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.examples.python")
node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "PositionToColor")
node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "examples")
node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "This node takes positional data (double3) and converts to a color, and outputs as color3f[] (which seems to be the default color connection in USD)")
node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python")
OgnPositionToColorDatabase.INTERFACE.add_to_node_type(node_type)
@staticmethod
def on_connection_type_resolve(node):
on_connection_type_resolve_function = getattr(OgnPositionToColorDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None)
if callable(on_connection_type_resolve_function):
on_connection_type_resolve_function(node)
NODE_TYPE_CLASS = None
@staticmethod
def register(node_type_class):
OgnPositionToColorDatabase.NODE_TYPE_CLASS = node_type_class
og.register_node_type(OgnPositionToColorDatabase.abi, 1)
@staticmethod
def deregister():
og.deregister_node_type("omni.graph.examples.python.PositionToColor")
| 12,043 | Python | 45.863813 | 220 | 0.639708 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/python/nodes/tutorial1/OgnAbsDouble.py | """
Implementation of an OmniGraph node takes the absolute value of a number
"""
class OgnAbsDouble:
@staticmethod
def compute(db):
db.outputs.out = abs(db.inputs.num)
return True
| 206 | Python | 17.81818 | 72 | 0.669903 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/python/nodes/tutorial1/OgnComposeDouble3.py | """
Implementation of an OmniGraph node that composes a double3 from its components
"""
class OgnComposeDouble3:
@staticmethod
def compute(db):
db.outputs.double3 = (db.inputs.x, db.inputs.y, db.inputs.z)
return True
| 243 | Python | 21.181816 | 79 | 0.687243 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/python/nodes/tutorial1/OgnDeformerYAxis.py | """
Implementation of an OmniGraph node that deforms a surface using a sine wave
"""
import numpy as np
class OgnDeformerYAxis:
@staticmethod
def compute(db):
"""Deform the input points by a multiple of the sine wave"""
points = db.inputs.points
multiplier = db.inputs.multiplier
wavelength = db.inputs.wavelength
offset = db.inputs.offset
db.outputs.points_size = points.shape[0]
# Nothing to evaluate if there are no input points
if db.outputs.points_size == 0:
return True
output_points = db.outputs.points
if wavelength <= 0:
wavelength = 1.0
pt = points.copy() # we still need to do a copy here because we do not want to modify points
tx = pt[:, 0]
offset_tx = tx + offset
disp = np.sin(offset_tx / wavelength)
pt[:, 1] += disp * multiplier
output_points[:] = pt[:] # we modify output_points in memory so we do not need to set the value again
return True
| 1,037 | Python | 29.529411 | 110 | 0.612343 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/python/nodes/tutorial1/OgnClampDouble.py | """
Implementation of an OmniGraph node that clamps a double value
"""
class OgnClampDouble:
@staticmethod
def compute(db):
if db.inputs.num < db.inputs.min:
db.outputs.out = db.inputs.min
elif db.inputs.num > db.inputs.max:
db.outputs.out = db.inputs.max
else:
db.outputs.out = db.inputs.num
return True
| 384 | Python | 21.647058 | 62 | 0.596354 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/python/nodes/tutorial1/OgnDecomposeDouble3.py | """
Implementation of an OmniGraph node that decomposes a double3 into its comonents
"""
class OgnDecomposeDouble3:
@staticmethod
def compute(db):
in_double3 = db.inputs.double3
db.outputs.x = in_double3[0]
db.outputs.y = in_double3[1]
db.outputs.z = in_double3[2]
return True
| 327 | Python | 22.42857 | 80 | 0.64526 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/python/nodes/tutorial1/OgnMultDouble.py | """
Implementation of an OmniGraph node that calculates a * b
"""
class OgnMultDouble:
@staticmethod
def compute(db):
db.outputs.out = db.inputs.a * db.inputs.b
return True
| 199 | Python | 17.181817 | 57 | 0.648241 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/python/nodes/tutorial1/OgnSubtractDouble.py | """
Implementation of an OmniGraph node that subtracts b from a
"""
class OgnSubtractDouble:
@staticmethod
def compute(db):
db.outputs.out = db.inputs.a - db.inputs.b
return True
| 205 | Python | 17.727271 | 59 | 0.663415 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/python/nodes/tutorial1/OgnPositionToColor.py | """
Implementation of the node algorith to convert a position to a color
"""
class OgnPositionToColor:
"""
This node takes positional data (double3) and converts to a color, and outputs
as color3f[] (which seems to be the default color connection in USD)
"""
@staticmethod
def compute(db):
"""Run the algorithm to convert a position to a color"""
position = db.inputs.position
scale_value = db.inputs.scale
color_offset = db.inputs.color_offset
color = (abs(position[:])) / scale_value
color += color_offset
ramp = (scale_value - abs(position[0])) / scale_value
ramp = max(ramp, 0)
color[0] -= ramp
if color[0] < 0:
color[0] = 0
color[1] += ramp
if color[1] > 1:
color[1] = 1
color[2] -= ramp
if color[2] < 0:
color[2] = 0
db.outputs.color_size = 1
db.outputs.color[0] = color
return True
| 993 | Python | 24.487179 | 82 | 0.558912 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/python/nodes/realtime/OgnBouncingCubesCpu.py | """
Example node showing realtime update from gathered data.
"""
class OgnBouncingCubesCpu:
@staticmethod
def compute(db):
velocities = db.state.velocities
translations = db.state.translations
# Empty input means nothing to do
if translations.size == 0 or velocities.size == 0:
return True
h = 1.0 / 60.0
g = -1000.0
for ii, velocity in enumerate(velocities):
velocity += h * g
translations[ii][2] += h * velocity
if translations[ii][2] < 1.0:
translations[ii][2] = 1.0
velocity = -5 * h * g
translations[0][0] += 0.03
translations[1][0] += 0.03
# We no longer need to set values because we do not copy memory of the numpy arrays
# Mutating the numpy array will also mutate the attribute data
# Alternative, setting values using the below lines will also work
# context.set_attr_value(translations, attr_translations)
# context.set_attr_value(velocities, attr_translations)
return True
| 1,102 | Python | 29.638888 | 91 | 0.598004 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/python/nodes/realtime/OgnBouncingCubesGpu.py | """
Example node showing realtime update from gathered data computed on the GPU.
"""
class OgnBouncingCubesGpu:
@staticmethod
def compute(db):
# This is how it should work when gather is fully supported
# velocities = db.state.velocities
# translations = db.state.translations
attr_velocities = db.node.get_attribute("state:velocities")
attr_translations = db.node.get_attribute("state:translations")
velocities = db.context_helper.get_attr_value(attr_velocities, isGPU=True, isTensor=True)
translations = db.context_helper.get_attr_value(attr_translations, isGPU=True, isTensor=True)
# When there is no data there is nothing to do
if velocities.size == 0 or translations.size == 0:
return True
h = 1.0 / 60.0
g = -1000.0
velocities += h * g
translations[:, 2] += h * velocities
translations_z = translations.split(1, dim=1)[2].squeeze(-1)
update_idx = (translations_z < 1.0).nonzero().squeeze(-1)
if update_idx.shape[0] > 0:
translations[update_idx, 2] = 1
velocities[update_idx] = -5 * h * g
translations[:, 0] += 0.03
# We no longer need to set values because we do not copy memory of the numpy arrays
# Mutating the numpy array will also mutate the attribute data
# Computegraph APIs using torch tensors currently do not have support for setting values.
# context.set_attr_value(translations, attr_translations)
# context.set_attr_value(velocities, attr_translations)
return True
| 1,624 | Python | 35.11111 | 101 | 0.644089 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/python/nodes/utility/OgnPyUniversalAdd.py | class OgnPyUniversalAdd:
@staticmethod
def compute(db):
db.outputs.bool_0 = db.inputs.bool_0 ^ db.inputs.bool_1
db.outputs.bool_arr_0 = [
db.inputs.bool_arr_0[i] ^ db.inputs.bool_arr_1[i] for i in range(len(db.inputs.bool_arr_0))
]
db.outputs.colord3_0 = db.inputs.colord3_0 + db.inputs.colord3_1
db.outputs.colord4_0 = db.inputs.colord4_0 + db.inputs.colord4_1
db.outputs.colord3_arr_0 = db.inputs.colord3_arr_0 + db.inputs.colord3_arr_1
db.outputs.colord4_arr_0 = db.inputs.colord4_arr_0 + db.inputs.colord4_arr_1
db.outputs.colorf3_0 = db.inputs.colorf3_0 + db.inputs.colorf3_1
db.outputs.colorf4_0 = db.inputs.colorf4_0 + db.inputs.colorf4_1
db.outputs.colorf3_arr_0 = db.inputs.colorf3_arr_0 + db.inputs.colorf3_arr_1
db.outputs.colorf4_arr_0 = db.inputs.colorf4_arr_0 + db.inputs.colorf4_arr_1
db.outputs.colorh3_0 = db.inputs.colorh3_0 + db.inputs.colorh3_1
db.outputs.colorh4_0 = db.inputs.colorh4_0 + db.inputs.colorh4_1
db.outputs.colorh3_arr_0 = db.inputs.colorh3_arr_0 + db.inputs.colorh3_arr_1
db.outputs.colorh4_arr_0 = db.inputs.colorh4_arr_0 + db.inputs.colorh4_arr_1
db.outputs.double_0 = db.inputs.double_0 + db.inputs.double_1
db.outputs.double2_0 = db.inputs.double2_0 + db.inputs.double2_1
db.outputs.double3_0 = db.inputs.double3_0 + db.inputs.double3_1
db.outputs.double4_0 = db.inputs.double4_0 + db.inputs.double4_1
db.outputs.double_arr_0 = db.inputs.double_arr_0 + db.inputs.double_arr_1
db.outputs.double2_arr_0 = db.inputs.double2_arr_0 + db.inputs.double2_arr_1
db.outputs.double3_arr_0 = db.inputs.double3_arr_0 + db.inputs.double3_arr_1
db.outputs.double4_arr_0 = db.inputs.double4_arr_0 + db.inputs.double4_arr_1
db.outputs.float_0 = db.inputs.float_0 + db.inputs.float_1
db.outputs.float2_0 = db.inputs.float2_0 + db.inputs.float2_1
db.outputs.float3_0 = db.inputs.float3_0 + db.inputs.float3_1
db.outputs.float4_0 = db.inputs.float4_0 + db.inputs.float4_1
db.outputs.float_arr_0 = db.inputs.float_arr_0 + db.inputs.float_arr_1
db.outputs.float2_arr_0 = db.inputs.float2_arr_0 + db.inputs.float2_arr_1
db.outputs.float3_arr_0 = db.inputs.float3_arr_0 + db.inputs.float3_arr_1
db.outputs.float4_arr_0 = db.inputs.float4_arr_0 + db.inputs.float4_arr_1
db.outputs.frame4_0 = db.inputs.frame4_0 + db.inputs.frame4_1
db.outputs.frame4_arr_0 = db.inputs.frame4_arr_0 + db.inputs.frame4_arr_1
db.outputs.half_0 = db.inputs.half_0 + db.inputs.half_1
db.outputs.half2_0 = db.inputs.half2_0 + db.inputs.half2_1
db.outputs.half3_0 = db.inputs.half3_0 + db.inputs.half3_1
db.outputs.half4_0 = db.inputs.half4_0 + db.inputs.half4_1
db.outputs.half_arr_0 = db.inputs.half_arr_0 + db.inputs.half_arr_1
db.outputs.half2_arr_0 = db.inputs.half2_arr_0 + db.inputs.half2_arr_1
db.outputs.half3_arr_0 = db.inputs.half3_arr_0 + db.inputs.half3_arr_1
db.outputs.half4_arr_0 = db.inputs.half4_arr_0 + db.inputs.half4_arr_1
db.outputs.int_0 = db.inputs.int_0 + db.inputs.int_1
db.outputs.int2_0 = db.inputs.int2_0 + db.inputs.int2_1
db.outputs.int3_0 = db.inputs.int3_0 + db.inputs.int3_1
db.outputs.int4_0 = db.inputs.int4_0 + db.inputs.int4_1
db.outputs.int_arr_0 = db.inputs.int_arr_0 + db.inputs.int_arr_1
db.outputs.int2_arr_0 = db.inputs.int2_arr_0 + db.inputs.int2_arr_1
db.outputs.int3_arr_0 = db.inputs.int3_arr_0 + db.inputs.int3_arr_1
db.outputs.int4_arr_0 = db.inputs.int4_arr_0 + db.inputs.int4_arr_1
db.outputs.int64_0 = db.inputs.int64_0 + db.inputs.int64_1
db.outputs.int64_arr_0 = db.inputs.int64_arr_0 + db.inputs.int64_arr_1
db.outputs.matrixd2_0 = db.inputs.matrixd2_0 + db.inputs.matrixd2_1
db.outputs.matrixd3_0 = db.inputs.matrixd3_0 + db.inputs.matrixd3_1
db.outputs.matrixd4_0 = db.inputs.matrixd4_0 + db.inputs.matrixd4_1
db.outputs.matrixd2_arr_0 = db.inputs.matrixd2_arr_0 + db.inputs.matrixd2_arr_1
db.outputs.matrixd3_arr_0 = db.inputs.matrixd3_arr_0 + db.inputs.matrixd3_arr_1
db.outputs.matrixd4_arr_0 = db.inputs.matrixd4_arr_0 + db.inputs.matrixd4_arr_1
db.outputs.normald3_0 = db.inputs.normald3_0 + db.inputs.normald3_1
db.outputs.normald3_arr_0 = db.inputs.normald3_arr_0 + db.inputs.normald3_arr_1
db.outputs.normalf3_0 = db.inputs.normalf3_0 + db.inputs.normalf3_1
db.outputs.normalf3_arr_0 = db.inputs.normalf3_arr_0 + db.inputs.normalf3_arr_1
db.outputs.normalh3_0 = db.inputs.normalh3_0 + db.inputs.normalh3_1
db.outputs.normalh3_arr_0 = db.inputs.normalh3_arr_0 + db.inputs.normalh3_arr_1
db.outputs.pointd3_0 = db.inputs.pointd3_0 + db.inputs.pointd3_1
db.outputs.pointd3_arr_0 = db.inputs.pointd3_arr_0 + db.inputs.pointd3_arr_1
db.outputs.pointf3_0 = db.inputs.pointf3_0 + db.inputs.pointf3_1
db.outputs.pointf3_arr_0 = db.inputs.pointf3_arr_0 + db.inputs.pointf3_arr_1
db.outputs.pointh3_0 = db.inputs.pointh3_0 + db.inputs.pointh3_1
db.outputs.pointh3_arr_0 = db.inputs.pointh3_arr_0 + db.inputs.pointh3_arr_1
db.outputs.quatd4_0 = db.inputs.quatd4_0 + db.inputs.quatd4_1
db.outputs.quatd4_arr_0 = db.inputs.quatd4_arr_0 + db.inputs.quatd4_arr_1
db.outputs.quatf4_0 = db.inputs.quatf4_0 + db.inputs.quatf4_1
db.outputs.quatf4_arr_0 = db.inputs.quatf4_arr_0 + db.inputs.quatf4_arr_1
db.outputs.quath4_0 = db.inputs.quath4_0 + db.inputs.quath4_1
db.outputs.quath4_arr_0 = db.inputs.quath4_arr_0 + db.inputs.quath4_arr_1
db.outputs.texcoordd2_0 = db.inputs.texcoordd2_0 + db.inputs.texcoordd2_1
db.outputs.texcoordd3_0 = db.inputs.texcoordd3_0 + db.inputs.texcoordd3_1
db.outputs.texcoordd2_arr_0 = db.inputs.texcoordd2_arr_0 + db.inputs.texcoordd2_arr_1
db.outputs.texcoordd3_arr_0 = db.inputs.texcoordd3_arr_0 + db.inputs.texcoordd3_arr_1
db.outputs.texcoordf2_0 = db.inputs.texcoordf2_0 + db.inputs.texcoordf2_1
db.outputs.texcoordf3_0 = db.inputs.texcoordf3_0 + db.inputs.texcoordf3_1
db.outputs.texcoordf2_arr_0 = db.inputs.texcoordf2_arr_0 + db.inputs.texcoordf2_arr_1
db.outputs.texcoordf3_arr_0 = db.inputs.texcoordf3_arr_0 + db.inputs.texcoordf3_arr_1
db.outputs.texcoordh2_0 = db.inputs.texcoordh2_0 + db.inputs.texcoordh2_1
db.outputs.texcoordh3_0 = db.inputs.texcoordh3_0 + db.inputs.texcoordh3_1
db.outputs.texcoordh2_arr_0 = db.inputs.texcoordh2_arr_0 + db.inputs.texcoordh2_arr_1
db.outputs.texcoordh3_arr_0 = db.inputs.texcoordh3_arr_0 + db.inputs.texcoordh3_arr_1
db.outputs.timecode_0 = db.inputs.timecode_0 + db.inputs.timecode_1
db.outputs.timecode_arr_0 = db.inputs.timecode_arr_0 + db.inputs.timecode_arr_1
db.outputs.token_0 = db.inputs.token_0 + db.inputs.token_1
db.outputs.token_arr_0 = [
db.inputs.token_arr_0[i] + db.inputs.token_arr_1[i] for i in range(len(db.inputs.token_arr_0))
]
db.outputs.transform4_0 = db.inputs.transform4_0 + db.inputs.transform4_1
db.outputs.transform4_arr_0 = db.inputs.transform4_arr_0 + db.inputs.transform4_arr_1
db.outputs.uchar_0 = db.inputs.uchar_0 + db.inputs.uchar_1
db.outputs.uchar_arr_0 = db.inputs.uchar_arr_0 + db.inputs.uchar_arr_1
db.outputs.uint_0 = db.inputs.uint_0 + db.inputs.uint_1
db.outputs.uint_arr_0 = db.inputs.uint_arr_0 + db.inputs.uint_arr_1
db.outputs.uint64_0 = db.inputs.uint64_0 + db.inputs.uint64_1
db.outputs.uint64_arr_0 = db.inputs.uint64_arr_0 + db.inputs.uint64_arr_1
db.outputs.vectord3_0 = db.inputs.vectord3_0 + db.inputs.vectord3_1
db.outputs.vectord3_arr_0 = db.inputs.vectord3_arr_0 + db.inputs.vectord3_arr_1
db.outputs.vectorf3_0 = db.inputs.vectorf3_0 + db.inputs.vectorf3_1
db.outputs.vectorf3_arr_0 = db.inputs.vectorf3_arr_0 + db.inputs.vectorf3_arr_1
db.outputs.vectorh3_0 = db.inputs.vectorh3_0 + db.inputs.vectorh3_1
db.outputs.vectorh3_arr_0 = db.inputs.vectorh3_arr_0 + db.inputs.vectorh3_arr_1
return True
| 8,362 | Python | 72.359648 | 106 | 0.669816 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/python/nodes/utility/OgnDynamicSwitch.py | """
Implementation of an stateful OmniGraph node that enables 1 branch or another using dynamic scheduling
"""
class OgnDynamicSwitch:
@staticmethod
def compute(db):
db.node.set_dynamic_downstream_control(True)
left_out_attr = db.node.get_attribute("outputs:left_out")
right_out_attr = db.node.get_attribute("outputs:right_out")
if db.inputs.switch > 0:
left_out_attr.set_disable_dynamic_downstream_work(True)
right_out_attr.set_disable_dynamic_downstream_work(False)
else:
left_out_attr.set_disable_dynamic_downstream_work(False)
right_out_attr.set_disable_dynamic_downstream_work(True)
db.outputs.left_out = db.inputs.left_value
db.outputs.right_out = db.inputs.right_value
return True
| 812 | Python | 34.347825 | 102 | 0.671182 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/python/nodes/stateful/OgnCountTo.py | """
Implementation of an stateful OmniGraph node that counts to a number defined by countTo
"""
class OgnCountTo:
@staticmethod
def compute(db):
if db.inputs.reset:
db.outputs.count = 0
else:
db.outputs.count = db.outputs.count + db.inputs.increment
if db.outputs.count > db.inputs.countTo:
db.outputs.count = db.inputs.countTo
else:
db.node.set_compute_incomplete()
return True
| 495 | Python | 23.799999 | 87 | 0.589899 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/python/nodes/stateful/OgnIntCounter.py | """
Implementation of an stateful OmniGraph node that counts up by an increment
"""
class OgnIntCounter:
@staticmethod
def compute(db):
if db.inputs.reset:
db.outputs.count = 0
else:
db.outputs.count = db.outputs.count + db.inputs.increment
return True
| 312 | Python | 19.866665 | 75 | 0.625 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/python/nodes/tests/OgnTestInitNode.py | import omni.graph.core as og
class OgnTestInitNode:
@staticmethod
def initialize(context, node):
_ = og.Controller()
@staticmethod
def release(node):
pass
@staticmethod
def compute(db):
db.outputs.value = 1.0
return True
| 281 | Python | 15.588234 | 34 | 0.608541 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/python/nodes/tests/OgnTestSingleton.py | class OgnTestSingleton:
@staticmethod
def compute(db):
db.outputs.out = 88.8
return True
| 113 | Python | 17.999997 | 29 | 0.619469 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/python/nodes/deformers/OgnVersionedDeformerPy.py | """
Implementation of a Python node that handles a simple version upgrade where the different versions contain
different attributes:
Version 0: multiplier
Version 1: multiplier, wavelength
Version 2: wavelength
Depending on the version that was received the upgrade will remove the obsolete "multiplier" attribute and/or
insert the new "wavelength" attribute.
"""
import numpy as np
import omni.graph.core as og
class OgnVersionedDeformerPy:
@staticmethod
def compute(db):
input_points = db.inputs.points
if len(input_points) <= 0:
return False
wavelength = db.inputs.wavelength
if wavelength <= 0.0:
wavelength = 310.0
db.outputs.points_size = input_points.shape[0]
# Nothing to evaluate if there are no input points
if db.outputs.points_size == 0:
return True
output_points = db.outputs.points
pt = input_points.copy() # we still need to do a copy here because we do not want to modify points
tx = (pt[:, 0] - wavelength) / wavelength
ty = (pt[:, 1] - wavelength) / wavelength
disp = 10.0 * (np.sin(tx * 10.0) + np.cos(ty * 15.0))
pt[:, 2] += disp * 5
output_points[:] = pt[:] # we modify output_points in memory so we do not need to set the value again
return True
@staticmethod
def update_node_version(context, node, old_version, new_version):
if old_version < new_version:
if old_version < 1:
node.create_attribute(
"inputs:wavelength",
og.Type(og.BaseDataType.FLOAT),
og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT,
50.0,
)
if old_version < 2:
node.remove_attribute("inputs:multiplier")
return True
return False
@staticmethod
def initialize_type(node_type):
node_type.add_input("test_input", "int", True)
node_type.add_output("test_output", "float", True)
node_type.add_extended_input(
"test_union_input", "float,double", True, og.ExtendedAttributeType.EXTENDED_ATTR_TYPE_UNION
)
return True
| 2,233 | Python | 33.906249 | 110 | 0.605911 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/python/nodes/deformers/OgnDeformerGpu.py | """
Implementation of an OmniGraph node that runs a simple deformer on the GPU
"""
from contextlib import suppress
with suppress(ImportError):
import torch
class OgnDeformerGpu:
@staticmethod
def compute(db) -> bool:
try:
# TODO: This method of GPU compute isn't recommended. Use CPU compute or Warp.
if torch:
input_points = db.inputs.points
multiplier = db.inputs.multiplier
db.outputs.points_size = input_points.shape[0]
# Nothing to evaluate if there are no input points
if db.outputs.points_size == 0:
return True
output_points = db.outputs.points
pt = input_points.copy()
tx = (pt[:, 0] - 310.0) / 310.0
ty = (pt[:, 1] - 310.0) / 310.0
disp = 10.0 * (torch.sin(tx * 10.0) + torch.cos(ty * 15.0))
pt[:, 2] += disp * multiplier
output_points[:] = pt[:]
return True
except NameError:
db.log_warning("Torch not found, no compute")
return False
| 1,153 | Python | 30.189188 | 90 | 0.525585 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/tests/TestOgnDynamicSwitch.py | import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.examples.python.ogn.OgnDynamicSwitchDatabase import OgnDynamicSwitchDatabase
(_, (test_node,), _, _) = og.Controller.edit("/TestGraph", {
og.Controller.Keys.CREATE_NODES: ("Template_omni_graph_examples_python_DynamicSwitch", "omni.graph.examples.python.DynamicSwitch")
})
database = OgnDynamicSwitchDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:left_value"))
attribute = test_node.get_attribute("inputs:left_value")
db_value = database.inputs.left_value
expected_value = -1
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:right_value"))
attribute = test_node.get_attribute("inputs:right_value")
db_value = database.inputs.right_value
expected_value = 1
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:switch"))
attribute = test_node.get_attribute("inputs:switch")
db_value = database.inputs.switch
expected_value = 0
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:left_out"))
attribute = test_node.get_attribute("outputs:left_out")
db_value = database.outputs.left_out
self.assertTrue(test_node.get_attribute_exists("outputs:right_out"))
attribute = test_node.get_attribute("outputs:right_out")
db_value = database.outputs.right_out
| 2,527 | Python | 47.615384 | 142 | 0.695291 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/ogn/tests/TestOgnPyUniversalAdd.py | import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.examples.python.ogn.OgnPyUniversalAddDatabase import OgnPyUniversalAddDatabase
(_, (test_node,), _, _) = og.Controller.edit("/TestGraph", {
og.Controller.Keys.CREATE_NODES: ("Template_omni_graph_examples_python_UniversalAdd", "omni.graph.examples.python.UniversalAdd")
})
database = OgnPyUniversalAddDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:bool_0"))
attribute = test_node.get_attribute("inputs:bool_0")
db_value = database.inputs.bool_0
expected_value = False
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:bool_1"))
attribute = test_node.get_attribute("inputs:bool_1")
db_value = database.inputs.bool_1
expected_value = False
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:bool_arr_0"))
attribute = test_node.get_attribute("inputs:bool_arr_0")
db_value = database.inputs.bool_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:bool_arr_1"))
attribute = test_node.get_attribute("inputs:bool_arr_1")
db_value = database.inputs.bool_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colord3_0"))
attribute = test_node.get_attribute("inputs:colord3_0")
db_value = database.inputs.colord3_0
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colord3_1"))
attribute = test_node.get_attribute("inputs:colord3_1")
db_value = database.inputs.colord3_1
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colord3_arr_0"))
attribute = test_node.get_attribute("inputs:colord3_arr_0")
db_value = database.inputs.colord3_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colord3_arr_1"))
attribute = test_node.get_attribute("inputs:colord3_arr_1")
db_value = database.inputs.colord3_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colord4_0"))
attribute = test_node.get_attribute("inputs:colord4_0")
db_value = database.inputs.colord4_0
expected_value = [0.0, 0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colord4_1"))
attribute = test_node.get_attribute("inputs:colord4_1")
db_value = database.inputs.colord4_1
expected_value = [0.0, 0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colord4_arr_0"))
attribute = test_node.get_attribute("inputs:colord4_arr_0")
db_value = database.inputs.colord4_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colord4_arr_1"))
attribute = test_node.get_attribute("inputs:colord4_arr_1")
db_value = database.inputs.colord4_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colorf3_0"))
attribute = test_node.get_attribute("inputs:colorf3_0")
db_value = database.inputs.colorf3_0
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colorf3_1"))
attribute = test_node.get_attribute("inputs:colorf3_1")
db_value = database.inputs.colorf3_1
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colorf3_arr_0"))
attribute = test_node.get_attribute("inputs:colorf3_arr_0")
db_value = database.inputs.colorf3_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colorf3_arr_1"))
attribute = test_node.get_attribute("inputs:colorf3_arr_1")
db_value = database.inputs.colorf3_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colorf4_0"))
attribute = test_node.get_attribute("inputs:colorf4_0")
db_value = database.inputs.colorf4_0
expected_value = [0.0, 0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colorf4_1"))
attribute = test_node.get_attribute("inputs:colorf4_1")
db_value = database.inputs.colorf4_1
expected_value = [0.0, 0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colorf4_arr_0"))
attribute = test_node.get_attribute("inputs:colorf4_arr_0")
db_value = database.inputs.colorf4_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colorf4_arr_1"))
attribute = test_node.get_attribute("inputs:colorf4_arr_1")
db_value = database.inputs.colorf4_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colorh3_0"))
attribute = test_node.get_attribute("inputs:colorh3_0")
db_value = database.inputs.colorh3_0
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colorh3_1"))
attribute = test_node.get_attribute("inputs:colorh3_1")
db_value = database.inputs.colorh3_1
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colorh3_arr_0"))
attribute = test_node.get_attribute("inputs:colorh3_arr_0")
db_value = database.inputs.colorh3_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colorh3_arr_1"))
attribute = test_node.get_attribute("inputs:colorh3_arr_1")
db_value = database.inputs.colorh3_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colorh4_0"))
attribute = test_node.get_attribute("inputs:colorh4_0")
db_value = database.inputs.colorh4_0
expected_value = [0.0, 0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colorh4_1"))
attribute = test_node.get_attribute("inputs:colorh4_1")
db_value = database.inputs.colorh4_1
expected_value = [0.0, 0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colorh4_arr_0"))
attribute = test_node.get_attribute("inputs:colorh4_arr_0")
db_value = database.inputs.colorh4_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:colorh4_arr_1"))
attribute = test_node.get_attribute("inputs:colorh4_arr_1")
db_value = database.inputs.colorh4_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:double2_0"))
attribute = test_node.get_attribute("inputs:double2_0")
db_value = database.inputs.double2_0
expected_value = [0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:double2_1"))
attribute = test_node.get_attribute("inputs:double2_1")
db_value = database.inputs.double2_1
expected_value = [0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:double2_arr_0"))
attribute = test_node.get_attribute("inputs:double2_arr_0")
db_value = database.inputs.double2_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:double2_arr_1"))
attribute = test_node.get_attribute("inputs:double2_arr_1")
db_value = database.inputs.double2_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:double3_0"))
attribute = test_node.get_attribute("inputs:double3_0")
db_value = database.inputs.double3_0
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:double3_1"))
attribute = test_node.get_attribute("inputs:double3_1")
db_value = database.inputs.double3_1
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:double3_arr_0"))
attribute = test_node.get_attribute("inputs:double3_arr_0")
db_value = database.inputs.double3_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:double3_arr_1"))
attribute = test_node.get_attribute("inputs:double3_arr_1")
db_value = database.inputs.double3_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:double4_0"))
attribute = test_node.get_attribute("inputs:double4_0")
db_value = database.inputs.double4_0
expected_value = [0.0, 0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:double4_1"))
attribute = test_node.get_attribute("inputs:double4_1")
db_value = database.inputs.double4_1
expected_value = [0.0, 0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:double4_arr_0"))
attribute = test_node.get_attribute("inputs:double4_arr_0")
db_value = database.inputs.double4_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:double4_arr_1"))
attribute = test_node.get_attribute("inputs:double4_arr_1")
db_value = database.inputs.double4_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:double_0"))
attribute = test_node.get_attribute("inputs:double_0")
db_value = database.inputs.double_0
expected_value = 0.0
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:double_1"))
attribute = test_node.get_attribute("inputs:double_1")
db_value = database.inputs.double_1
expected_value = 0.0
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:double_arr_0"))
attribute = test_node.get_attribute("inputs:double_arr_0")
db_value = database.inputs.double_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:double_arr_1"))
attribute = test_node.get_attribute("inputs:double_arr_1")
db_value = database.inputs.double_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:float2_0"))
attribute = test_node.get_attribute("inputs:float2_0")
db_value = database.inputs.float2_0
expected_value = [0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:float2_1"))
attribute = test_node.get_attribute("inputs:float2_1")
db_value = database.inputs.float2_1
expected_value = [0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:float2_arr_0"))
attribute = test_node.get_attribute("inputs:float2_arr_0")
db_value = database.inputs.float2_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:float2_arr_1"))
attribute = test_node.get_attribute("inputs:float2_arr_1")
db_value = database.inputs.float2_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:float3_0"))
attribute = test_node.get_attribute("inputs:float3_0")
db_value = database.inputs.float3_0
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:float3_1"))
attribute = test_node.get_attribute("inputs:float3_1")
db_value = database.inputs.float3_1
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:float3_arr_0"))
attribute = test_node.get_attribute("inputs:float3_arr_0")
db_value = database.inputs.float3_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:float3_arr_1"))
attribute = test_node.get_attribute("inputs:float3_arr_1")
db_value = database.inputs.float3_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:float4_0"))
attribute = test_node.get_attribute("inputs:float4_0")
db_value = database.inputs.float4_0
expected_value = [0.0, 0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:float4_1"))
attribute = test_node.get_attribute("inputs:float4_1")
db_value = database.inputs.float4_1
expected_value = [0.0, 0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:float4_arr_0"))
attribute = test_node.get_attribute("inputs:float4_arr_0")
db_value = database.inputs.float4_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:float4_arr_1"))
attribute = test_node.get_attribute("inputs:float4_arr_1")
db_value = database.inputs.float4_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:float_0"))
attribute = test_node.get_attribute("inputs:float_0")
db_value = database.inputs.float_0
expected_value = 0.0
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:float_1"))
attribute = test_node.get_attribute("inputs:float_1")
db_value = database.inputs.float_1
expected_value = 0.0
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:float_arr_0"))
attribute = test_node.get_attribute("inputs:float_arr_0")
db_value = database.inputs.float_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:float_arr_1"))
attribute = test_node.get_attribute("inputs:float_arr_1")
db_value = database.inputs.float_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:frame4_0"))
attribute = test_node.get_attribute("inputs:frame4_0")
db_value = database.inputs.frame4_0
expected_value = [[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0]]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:frame4_1"))
attribute = test_node.get_attribute("inputs:frame4_1")
db_value = database.inputs.frame4_1
expected_value = [[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0]]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:frame4_arr_0"))
attribute = test_node.get_attribute("inputs:frame4_arr_0")
db_value = database.inputs.frame4_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:frame4_arr_1"))
attribute = test_node.get_attribute("inputs:frame4_arr_1")
db_value = database.inputs.frame4_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:half2_0"))
attribute = test_node.get_attribute("inputs:half2_0")
db_value = database.inputs.half2_0
expected_value = [0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:half2_1"))
attribute = test_node.get_attribute("inputs:half2_1")
db_value = database.inputs.half2_1
expected_value = [0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:half2_arr_0"))
attribute = test_node.get_attribute("inputs:half2_arr_0")
db_value = database.inputs.half2_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:half2_arr_1"))
attribute = test_node.get_attribute("inputs:half2_arr_1")
db_value = database.inputs.half2_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:half3_0"))
attribute = test_node.get_attribute("inputs:half3_0")
db_value = database.inputs.half3_0
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:half3_1"))
attribute = test_node.get_attribute("inputs:half3_1")
db_value = database.inputs.half3_1
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:half3_arr_0"))
attribute = test_node.get_attribute("inputs:half3_arr_0")
db_value = database.inputs.half3_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:half3_arr_1"))
attribute = test_node.get_attribute("inputs:half3_arr_1")
db_value = database.inputs.half3_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:half4_0"))
attribute = test_node.get_attribute("inputs:half4_0")
db_value = database.inputs.half4_0
expected_value = [0.0, 0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:half4_1"))
attribute = test_node.get_attribute("inputs:half4_1")
db_value = database.inputs.half4_1
expected_value = [0.0, 0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:half4_arr_0"))
attribute = test_node.get_attribute("inputs:half4_arr_0")
db_value = database.inputs.half4_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:half4_arr_1"))
attribute = test_node.get_attribute("inputs:half4_arr_1")
db_value = database.inputs.half4_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:half_0"))
attribute = test_node.get_attribute("inputs:half_0")
db_value = database.inputs.half_0
expected_value = 0.0
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:half_1"))
attribute = test_node.get_attribute("inputs:half_1")
db_value = database.inputs.half_1
expected_value = 0.0
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:half_arr_0"))
attribute = test_node.get_attribute("inputs:half_arr_0")
db_value = database.inputs.half_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:half_arr_1"))
attribute = test_node.get_attribute("inputs:half_arr_1")
db_value = database.inputs.half_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:int2_0"))
attribute = test_node.get_attribute("inputs:int2_0")
db_value = database.inputs.int2_0
expected_value = [0, 0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:int2_1"))
attribute = test_node.get_attribute("inputs:int2_1")
db_value = database.inputs.int2_1
expected_value = [0, 0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:int2_arr_0"))
attribute = test_node.get_attribute("inputs:int2_arr_0")
db_value = database.inputs.int2_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:int2_arr_1"))
attribute = test_node.get_attribute("inputs:int2_arr_1")
db_value = database.inputs.int2_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:int3_0"))
attribute = test_node.get_attribute("inputs:int3_0")
db_value = database.inputs.int3_0
expected_value = [0, 0, 0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:int3_1"))
attribute = test_node.get_attribute("inputs:int3_1")
db_value = database.inputs.int3_1
expected_value = [0, 0, 0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:int3_arr_0"))
attribute = test_node.get_attribute("inputs:int3_arr_0")
db_value = database.inputs.int3_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:int3_arr_1"))
attribute = test_node.get_attribute("inputs:int3_arr_1")
db_value = database.inputs.int3_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:int4_0"))
attribute = test_node.get_attribute("inputs:int4_0")
db_value = database.inputs.int4_0
expected_value = [0, 0, 0, 0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:int4_1"))
attribute = test_node.get_attribute("inputs:int4_1")
db_value = database.inputs.int4_1
expected_value = [0, 0, 0, 0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:int4_arr_0"))
attribute = test_node.get_attribute("inputs:int4_arr_0")
db_value = database.inputs.int4_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:int4_arr_1"))
attribute = test_node.get_attribute("inputs:int4_arr_1")
db_value = database.inputs.int4_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:int64_0"))
attribute = test_node.get_attribute("inputs:int64_0")
db_value = database.inputs.int64_0
expected_value = 0
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:int64_1"))
attribute = test_node.get_attribute("inputs:int64_1")
db_value = database.inputs.int64_1
expected_value = 0
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:int64_arr_0"))
attribute = test_node.get_attribute("inputs:int64_arr_0")
db_value = database.inputs.int64_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:int64_arr_1"))
attribute = test_node.get_attribute("inputs:int64_arr_1")
db_value = database.inputs.int64_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:int_0"))
attribute = test_node.get_attribute("inputs:int_0")
db_value = database.inputs.int_0
expected_value = 0
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:int_1"))
attribute = test_node.get_attribute("inputs:int_1")
db_value = database.inputs.int_1
expected_value = 0
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:int_arr_0"))
attribute = test_node.get_attribute("inputs:int_arr_0")
db_value = database.inputs.int_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:int_arr_1"))
attribute = test_node.get_attribute("inputs:int_arr_1")
db_value = database.inputs.int_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:matrixd2_0"))
attribute = test_node.get_attribute("inputs:matrixd2_0")
db_value = database.inputs.matrixd2_0
expected_value = [[0.0, 0.0], [0.0, 0.0]]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:matrixd2_1"))
attribute = test_node.get_attribute("inputs:matrixd2_1")
db_value = database.inputs.matrixd2_1
expected_value = [[0.0, 0.0], [0.0, 0.0]]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:matrixd2_arr_0"))
attribute = test_node.get_attribute("inputs:matrixd2_arr_0")
db_value = database.inputs.matrixd2_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:matrixd2_arr_1"))
attribute = test_node.get_attribute("inputs:matrixd2_arr_1")
db_value = database.inputs.matrixd2_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:matrixd3_0"))
attribute = test_node.get_attribute("inputs:matrixd3_0")
db_value = database.inputs.matrixd3_0
expected_value = [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:matrixd3_1"))
attribute = test_node.get_attribute("inputs:matrixd3_1")
db_value = database.inputs.matrixd3_1
expected_value = [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:matrixd3_arr_0"))
attribute = test_node.get_attribute("inputs:matrixd3_arr_0")
db_value = database.inputs.matrixd3_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:matrixd3_arr_1"))
attribute = test_node.get_attribute("inputs:matrixd3_arr_1")
db_value = database.inputs.matrixd3_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:matrixd4_0"))
attribute = test_node.get_attribute("inputs:matrixd4_0")
db_value = database.inputs.matrixd4_0
expected_value = [[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0]]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:matrixd4_1"))
attribute = test_node.get_attribute("inputs:matrixd4_1")
db_value = database.inputs.matrixd4_1
expected_value = [[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0]]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:matrixd4_arr_0"))
attribute = test_node.get_attribute("inputs:matrixd4_arr_0")
db_value = database.inputs.matrixd4_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:matrixd4_arr_1"))
attribute = test_node.get_attribute("inputs:matrixd4_arr_1")
db_value = database.inputs.matrixd4_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:normald3_0"))
attribute = test_node.get_attribute("inputs:normald3_0")
db_value = database.inputs.normald3_0
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:normald3_1"))
attribute = test_node.get_attribute("inputs:normald3_1")
db_value = database.inputs.normald3_1
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:normald3_arr_0"))
attribute = test_node.get_attribute("inputs:normald3_arr_0")
db_value = database.inputs.normald3_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:normald3_arr_1"))
attribute = test_node.get_attribute("inputs:normald3_arr_1")
db_value = database.inputs.normald3_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:normalf3_0"))
attribute = test_node.get_attribute("inputs:normalf3_0")
db_value = database.inputs.normalf3_0
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:normalf3_1"))
attribute = test_node.get_attribute("inputs:normalf3_1")
db_value = database.inputs.normalf3_1
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:normalf3_arr_0"))
attribute = test_node.get_attribute("inputs:normalf3_arr_0")
db_value = database.inputs.normalf3_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:normalf3_arr_1"))
attribute = test_node.get_attribute("inputs:normalf3_arr_1")
db_value = database.inputs.normalf3_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:normalh3_0"))
attribute = test_node.get_attribute("inputs:normalh3_0")
db_value = database.inputs.normalh3_0
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:normalh3_1"))
attribute = test_node.get_attribute("inputs:normalh3_1")
db_value = database.inputs.normalh3_1
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:normalh3_arr_0"))
attribute = test_node.get_attribute("inputs:normalh3_arr_0")
db_value = database.inputs.normalh3_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:normalh3_arr_1"))
attribute = test_node.get_attribute("inputs:normalh3_arr_1")
db_value = database.inputs.normalh3_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:pointd3_0"))
attribute = test_node.get_attribute("inputs:pointd3_0")
db_value = database.inputs.pointd3_0
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:pointd3_1"))
attribute = test_node.get_attribute("inputs:pointd3_1")
db_value = database.inputs.pointd3_1
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:pointd3_arr_0"))
attribute = test_node.get_attribute("inputs:pointd3_arr_0")
db_value = database.inputs.pointd3_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:pointd3_arr_1"))
attribute = test_node.get_attribute("inputs:pointd3_arr_1")
db_value = database.inputs.pointd3_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:pointf3_0"))
attribute = test_node.get_attribute("inputs:pointf3_0")
db_value = database.inputs.pointf3_0
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:pointf3_1"))
attribute = test_node.get_attribute("inputs:pointf3_1")
db_value = database.inputs.pointf3_1
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:pointf3_arr_0"))
attribute = test_node.get_attribute("inputs:pointf3_arr_0")
db_value = database.inputs.pointf3_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:pointf3_arr_1"))
attribute = test_node.get_attribute("inputs:pointf3_arr_1")
db_value = database.inputs.pointf3_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:pointh3_0"))
attribute = test_node.get_attribute("inputs:pointh3_0")
db_value = database.inputs.pointh3_0
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:pointh3_1"))
attribute = test_node.get_attribute("inputs:pointh3_1")
db_value = database.inputs.pointh3_1
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:pointh3_arr_0"))
attribute = test_node.get_attribute("inputs:pointh3_arr_0")
db_value = database.inputs.pointh3_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:pointh3_arr_1"))
attribute = test_node.get_attribute("inputs:pointh3_arr_1")
db_value = database.inputs.pointh3_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:quatd4_0"))
attribute = test_node.get_attribute("inputs:quatd4_0")
db_value = database.inputs.quatd4_0
expected_value = [0.0, 0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:quatd4_1"))
attribute = test_node.get_attribute("inputs:quatd4_1")
db_value = database.inputs.quatd4_1
expected_value = [0.0, 0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:quatd4_arr_0"))
attribute = test_node.get_attribute("inputs:quatd4_arr_0")
db_value = database.inputs.quatd4_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:quatd4_arr_1"))
attribute = test_node.get_attribute("inputs:quatd4_arr_1")
db_value = database.inputs.quatd4_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:quatf4_0"))
attribute = test_node.get_attribute("inputs:quatf4_0")
db_value = database.inputs.quatf4_0
expected_value = [0.0, 0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:quatf4_1"))
attribute = test_node.get_attribute("inputs:quatf4_1")
db_value = database.inputs.quatf4_1
expected_value = [0.0, 0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:quatf4_arr_0"))
attribute = test_node.get_attribute("inputs:quatf4_arr_0")
db_value = database.inputs.quatf4_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:quatf4_arr_1"))
attribute = test_node.get_attribute("inputs:quatf4_arr_1")
db_value = database.inputs.quatf4_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:quath4_0"))
attribute = test_node.get_attribute("inputs:quath4_0")
db_value = database.inputs.quath4_0
expected_value = [0.0, 0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:quath4_1"))
attribute = test_node.get_attribute("inputs:quath4_1")
db_value = database.inputs.quath4_1
expected_value = [0.0, 0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:quath4_arr_0"))
attribute = test_node.get_attribute("inputs:quath4_arr_0")
db_value = database.inputs.quath4_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:quath4_arr_1"))
attribute = test_node.get_attribute("inputs:quath4_arr_1")
db_value = database.inputs.quath4_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordd2_0"))
attribute = test_node.get_attribute("inputs:texcoordd2_0")
db_value = database.inputs.texcoordd2_0
expected_value = [0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordd2_1"))
attribute = test_node.get_attribute("inputs:texcoordd2_1")
db_value = database.inputs.texcoordd2_1
expected_value = [0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordd2_arr_0"))
attribute = test_node.get_attribute("inputs:texcoordd2_arr_0")
db_value = database.inputs.texcoordd2_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordd2_arr_1"))
attribute = test_node.get_attribute("inputs:texcoordd2_arr_1")
db_value = database.inputs.texcoordd2_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordd3_0"))
attribute = test_node.get_attribute("inputs:texcoordd3_0")
db_value = database.inputs.texcoordd3_0
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordd3_1"))
attribute = test_node.get_attribute("inputs:texcoordd3_1")
db_value = database.inputs.texcoordd3_1
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordd3_arr_0"))
attribute = test_node.get_attribute("inputs:texcoordd3_arr_0")
db_value = database.inputs.texcoordd3_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordd3_arr_1"))
attribute = test_node.get_attribute("inputs:texcoordd3_arr_1")
db_value = database.inputs.texcoordd3_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordf2_0"))
attribute = test_node.get_attribute("inputs:texcoordf2_0")
db_value = database.inputs.texcoordf2_0
expected_value = [0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordf2_1"))
attribute = test_node.get_attribute("inputs:texcoordf2_1")
db_value = database.inputs.texcoordf2_1
expected_value = [0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordf2_arr_0"))
attribute = test_node.get_attribute("inputs:texcoordf2_arr_0")
db_value = database.inputs.texcoordf2_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordf2_arr_1"))
attribute = test_node.get_attribute("inputs:texcoordf2_arr_1")
db_value = database.inputs.texcoordf2_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordf3_0"))
attribute = test_node.get_attribute("inputs:texcoordf3_0")
db_value = database.inputs.texcoordf3_0
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordf3_1"))
attribute = test_node.get_attribute("inputs:texcoordf3_1")
db_value = database.inputs.texcoordf3_1
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordf3_arr_0"))
attribute = test_node.get_attribute("inputs:texcoordf3_arr_0")
db_value = database.inputs.texcoordf3_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordf3_arr_1"))
attribute = test_node.get_attribute("inputs:texcoordf3_arr_1")
db_value = database.inputs.texcoordf3_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordh2_0"))
attribute = test_node.get_attribute("inputs:texcoordh2_0")
db_value = database.inputs.texcoordh2_0
expected_value = [0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordh2_1"))
attribute = test_node.get_attribute("inputs:texcoordh2_1")
db_value = database.inputs.texcoordh2_1
expected_value = [0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordh2_arr_0"))
attribute = test_node.get_attribute("inputs:texcoordh2_arr_0")
db_value = database.inputs.texcoordh2_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordh2_arr_1"))
attribute = test_node.get_attribute("inputs:texcoordh2_arr_1")
db_value = database.inputs.texcoordh2_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordh3_0"))
attribute = test_node.get_attribute("inputs:texcoordh3_0")
db_value = database.inputs.texcoordh3_0
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordh3_1"))
attribute = test_node.get_attribute("inputs:texcoordh3_1")
db_value = database.inputs.texcoordh3_1
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordh3_arr_0"))
attribute = test_node.get_attribute("inputs:texcoordh3_arr_0")
db_value = database.inputs.texcoordh3_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:texcoordh3_arr_1"))
attribute = test_node.get_attribute("inputs:texcoordh3_arr_1")
db_value = database.inputs.texcoordh3_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:timecode_0"))
attribute = test_node.get_attribute("inputs:timecode_0")
db_value = database.inputs.timecode_0
expected_value = 0.0
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:timecode_1"))
attribute = test_node.get_attribute("inputs:timecode_1")
db_value = database.inputs.timecode_1
expected_value = 0.0
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:timecode_arr_0"))
attribute = test_node.get_attribute("inputs:timecode_arr_0")
db_value = database.inputs.timecode_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:timecode_arr_1"))
attribute = test_node.get_attribute("inputs:timecode_arr_1")
db_value = database.inputs.timecode_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:token_0"))
attribute = test_node.get_attribute("inputs:token_0")
db_value = database.inputs.token_0
expected_value = "default_token"
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:token_1"))
attribute = test_node.get_attribute("inputs:token_1")
db_value = database.inputs.token_1
expected_value = "default_token"
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:token_arr_0"))
attribute = test_node.get_attribute("inputs:token_arr_0")
db_value = database.inputs.token_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:token_arr_1"))
attribute = test_node.get_attribute("inputs:token_arr_1")
db_value = database.inputs.token_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:transform4_0"))
attribute = test_node.get_attribute("inputs:transform4_0")
db_value = database.inputs.transform4_0
expected_value = [[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0]]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:transform4_1"))
attribute = test_node.get_attribute("inputs:transform4_1")
db_value = database.inputs.transform4_1
expected_value = [[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0]]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:transform4_arr_0"))
attribute = test_node.get_attribute("inputs:transform4_arr_0")
db_value = database.inputs.transform4_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:transform4_arr_1"))
attribute = test_node.get_attribute("inputs:transform4_arr_1")
db_value = database.inputs.transform4_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:uchar_0"))
attribute = test_node.get_attribute("inputs:uchar_0")
db_value = database.inputs.uchar_0
expected_value = 0
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:uchar_1"))
attribute = test_node.get_attribute("inputs:uchar_1")
db_value = database.inputs.uchar_1
expected_value = 0
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:uchar_arr_0"))
attribute = test_node.get_attribute("inputs:uchar_arr_0")
db_value = database.inputs.uchar_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:uchar_arr_1"))
attribute = test_node.get_attribute("inputs:uchar_arr_1")
db_value = database.inputs.uchar_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:uint64_0"))
attribute = test_node.get_attribute("inputs:uint64_0")
db_value = database.inputs.uint64_0
expected_value = 0
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:uint64_1"))
attribute = test_node.get_attribute("inputs:uint64_1")
db_value = database.inputs.uint64_1
expected_value = 0
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:uint64_arr_0"))
attribute = test_node.get_attribute("inputs:uint64_arr_0")
db_value = database.inputs.uint64_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:uint64_arr_1"))
attribute = test_node.get_attribute("inputs:uint64_arr_1")
db_value = database.inputs.uint64_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:uint_0"))
attribute = test_node.get_attribute("inputs:uint_0")
db_value = database.inputs.uint_0
expected_value = 0
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:uint_1"))
attribute = test_node.get_attribute("inputs:uint_1")
db_value = database.inputs.uint_1
expected_value = 0
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:uint_arr_0"))
attribute = test_node.get_attribute("inputs:uint_arr_0")
db_value = database.inputs.uint_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:uint_arr_1"))
attribute = test_node.get_attribute("inputs:uint_arr_1")
db_value = database.inputs.uint_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:vectord3_0"))
attribute = test_node.get_attribute("inputs:vectord3_0")
db_value = database.inputs.vectord3_0
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:vectord3_1"))
attribute = test_node.get_attribute("inputs:vectord3_1")
db_value = database.inputs.vectord3_1
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:vectord3_arr_0"))
attribute = test_node.get_attribute("inputs:vectord3_arr_0")
db_value = database.inputs.vectord3_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:vectord3_arr_1"))
attribute = test_node.get_attribute("inputs:vectord3_arr_1")
db_value = database.inputs.vectord3_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:vectorf3_0"))
attribute = test_node.get_attribute("inputs:vectorf3_0")
db_value = database.inputs.vectorf3_0
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:vectorf3_1"))
attribute = test_node.get_attribute("inputs:vectorf3_1")
db_value = database.inputs.vectorf3_1
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:vectorf3_arr_0"))
attribute = test_node.get_attribute("inputs:vectorf3_arr_0")
db_value = database.inputs.vectorf3_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:vectorf3_arr_1"))
attribute = test_node.get_attribute("inputs:vectorf3_arr_1")
db_value = database.inputs.vectorf3_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:vectorh3_0"))
attribute = test_node.get_attribute("inputs:vectorh3_0")
db_value = database.inputs.vectorh3_0
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:vectorh3_1"))
attribute = test_node.get_attribute("inputs:vectorh3_1")
db_value = database.inputs.vectorh3_1
expected_value = [0.0, 0.0, 0.0]
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:vectorh3_arr_0"))
attribute = test_node.get_attribute("inputs:vectorh3_arr_0")
db_value = database.inputs.vectorh3_arr_0
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:vectorh3_arr_1"))
attribute = test_node.get_attribute("inputs:vectorh3_arr_1")
db_value = database.inputs.vectorh3_arr_1
expected_value = []
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:bool_0"))
attribute = test_node.get_attribute("outputs:bool_0")
db_value = database.outputs.bool_0
self.assertTrue(test_node.get_attribute_exists("outputs:bool_arr_0"))
attribute = test_node.get_attribute("outputs:bool_arr_0")
db_value = database.outputs.bool_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:colord3_0"))
attribute = test_node.get_attribute("outputs:colord3_0")
db_value = database.outputs.colord3_0
self.assertTrue(test_node.get_attribute_exists("outputs:colord3_arr_0"))
attribute = test_node.get_attribute("outputs:colord3_arr_0")
db_value = database.outputs.colord3_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:colord4_0"))
attribute = test_node.get_attribute("outputs:colord4_0")
db_value = database.outputs.colord4_0
self.assertTrue(test_node.get_attribute_exists("outputs:colord4_arr_0"))
attribute = test_node.get_attribute("outputs:colord4_arr_0")
db_value = database.outputs.colord4_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:colorf3_0"))
attribute = test_node.get_attribute("outputs:colorf3_0")
db_value = database.outputs.colorf3_0
self.assertTrue(test_node.get_attribute_exists("outputs:colorf3_arr_0"))
attribute = test_node.get_attribute("outputs:colorf3_arr_0")
db_value = database.outputs.colorf3_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:colorf4_0"))
attribute = test_node.get_attribute("outputs:colorf4_0")
db_value = database.outputs.colorf4_0
self.assertTrue(test_node.get_attribute_exists("outputs:colorf4_arr_0"))
attribute = test_node.get_attribute("outputs:colorf4_arr_0")
db_value = database.outputs.colorf4_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:colorh3_0"))
attribute = test_node.get_attribute("outputs:colorh3_0")
db_value = database.outputs.colorh3_0
self.assertTrue(test_node.get_attribute_exists("outputs:colorh3_arr_0"))
attribute = test_node.get_attribute("outputs:colorh3_arr_0")
db_value = database.outputs.colorh3_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:colorh4_0"))
attribute = test_node.get_attribute("outputs:colorh4_0")
db_value = database.outputs.colorh4_0
self.assertTrue(test_node.get_attribute_exists("outputs:colorh4_arr_0"))
attribute = test_node.get_attribute("outputs:colorh4_arr_0")
db_value = database.outputs.colorh4_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:double2_0"))
attribute = test_node.get_attribute("outputs:double2_0")
db_value = database.outputs.double2_0
self.assertTrue(test_node.get_attribute_exists("outputs:double2_arr_0"))
attribute = test_node.get_attribute("outputs:double2_arr_0")
db_value = database.outputs.double2_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:double3_0"))
attribute = test_node.get_attribute("outputs:double3_0")
db_value = database.outputs.double3_0
self.assertTrue(test_node.get_attribute_exists("outputs:double3_arr_0"))
attribute = test_node.get_attribute("outputs:double3_arr_0")
db_value = database.outputs.double3_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:double4_0"))
attribute = test_node.get_attribute("outputs:double4_0")
db_value = database.outputs.double4_0
self.assertTrue(test_node.get_attribute_exists("outputs:double4_arr_0"))
attribute = test_node.get_attribute("outputs:double4_arr_0")
db_value = database.outputs.double4_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:double_0"))
attribute = test_node.get_attribute("outputs:double_0")
db_value = database.outputs.double_0
self.assertTrue(test_node.get_attribute_exists("outputs:double_arr_0"))
attribute = test_node.get_attribute("outputs:double_arr_0")
db_value = database.outputs.double_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:float2_0"))
attribute = test_node.get_attribute("outputs:float2_0")
db_value = database.outputs.float2_0
self.assertTrue(test_node.get_attribute_exists("outputs:float2_arr_0"))
attribute = test_node.get_attribute("outputs:float2_arr_0")
db_value = database.outputs.float2_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:float3_0"))
attribute = test_node.get_attribute("outputs:float3_0")
db_value = database.outputs.float3_0
self.assertTrue(test_node.get_attribute_exists("outputs:float3_arr_0"))
attribute = test_node.get_attribute("outputs:float3_arr_0")
db_value = database.outputs.float3_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:float4_0"))
attribute = test_node.get_attribute("outputs:float4_0")
db_value = database.outputs.float4_0
self.assertTrue(test_node.get_attribute_exists("outputs:float4_arr_0"))
attribute = test_node.get_attribute("outputs:float4_arr_0")
db_value = database.outputs.float4_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:float_0"))
attribute = test_node.get_attribute("outputs:float_0")
db_value = database.outputs.float_0
self.assertTrue(test_node.get_attribute_exists("outputs:float_arr_0"))
attribute = test_node.get_attribute("outputs:float_arr_0")
db_value = database.outputs.float_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:frame4_0"))
attribute = test_node.get_attribute("outputs:frame4_0")
db_value = database.outputs.frame4_0
self.assertTrue(test_node.get_attribute_exists("outputs:frame4_arr_0"))
attribute = test_node.get_attribute("outputs:frame4_arr_0")
db_value = database.outputs.frame4_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:half2_0"))
attribute = test_node.get_attribute("outputs:half2_0")
db_value = database.outputs.half2_0
self.assertTrue(test_node.get_attribute_exists("outputs:half2_arr_0"))
attribute = test_node.get_attribute("outputs:half2_arr_0")
db_value = database.outputs.half2_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:half3_0"))
attribute = test_node.get_attribute("outputs:half3_0")
db_value = database.outputs.half3_0
self.assertTrue(test_node.get_attribute_exists("outputs:half3_arr_0"))
attribute = test_node.get_attribute("outputs:half3_arr_0")
db_value = database.outputs.half3_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:half4_0"))
attribute = test_node.get_attribute("outputs:half4_0")
db_value = database.outputs.half4_0
self.assertTrue(test_node.get_attribute_exists("outputs:half4_arr_0"))
attribute = test_node.get_attribute("outputs:half4_arr_0")
db_value = database.outputs.half4_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:half_0"))
attribute = test_node.get_attribute("outputs:half_0")
db_value = database.outputs.half_0
self.assertTrue(test_node.get_attribute_exists("outputs:half_arr_0"))
attribute = test_node.get_attribute("outputs:half_arr_0")
db_value = database.outputs.half_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:int2_0"))
attribute = test_node.get_attribute("outputs:int2_0")
db_value = database.outputs.int2_0
self.assertTrue(test_node.get_attribute_exists("outputs:int2_arr_0"))
attribute = test_node.get_attribute("outputs:int2_arr_0")
db_value = database.outputs.int2_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:int3_0"))
attribute = test_node.get_attribute("outputs:int3_0")
db_value = database.outputs.int3_0
self.assertTrue(test_node.get_attribute_exists("outputs:int3_arr_0"))
attribute = test_node.get_attribute("outputs:int3_arr_0")
db_value = database.outputs.int3_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:int4_0"))
attribute = test_node.get_attribute("outputs:int4_0")
db_value = database.outputs.int4_0
self.assertTrue(test_node.get_attribute_exists("outputs:int4_arr_0"))
attribute = test_node.get_attribute("outputs:int4_arr_0")
db_value = database.outputs.int4_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:int64_0"))
attribute = test_node.get_attribute("outputs:int64_0")
db_value = database.outputs.int64_0
self.assertTrue(test_node.get_attribute_exists("outputs:int64_arr_0"))
attribute = test_node.get_attribute("outputs:int64_arr_0")
db_value = database.outputs.int64_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:int_0"))
attribute = test_node.get_attribute("outputs:int_0")
db_value = database.outputs.int_0
self.assertTrue(test_node.get_attribute_exists("outputs:int_arr_0"))
attribute = test_node.get_attribute("outputs:int_arr_0")
db_value = database.outputs.int_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:matrixd2_0"))
attribute = test_node.get_attribute("outputs:matrixd2_0")
db_value = database.outputs.matrixd2_0
self.assertTrue(test_node.get_attribute_exists("outputs:matrixd2_arr_0"))
attribute = test_node.get_attribute("outputs:matrixd2_arr_0")
db_value = database.outputs.matrixd2_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:matrixd3_0"))
attribute = test_node.get_attribute("outputs:matrixd3_0")
db_value = database.outputs.matrixd3_0
self.assertTrue(test_node.get_attribute_exists("outputs:matrixd3_arr_0"))
attribute = test_node.get_attribute("outputs:matrixd3_arr_0")
db_value = database.outputs.matrixd3_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:matrixd4_0"))
attribute = test_node.get_attribute("outputs:matrixd4_0")
db_value = database.outputs.matrixd4_0
self.assertTrue(test_node.get_attribute_exists("outputs:matrixd4_arr_0"))
attribute = test_node.get_attribute("outputs:matrixd4_arr_0")
db_value = database.outputs.matrixd4_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:normald3_0"))
attribute = test_node.get_attribute("outputs:normald3_0")
db_value = database.outputs.normald3_0
self.assertTrue(test_node.get_attribute_exists("outputs:normald3_arr_0"))
attribute = test_node.get_attribute("outputs:normald3_arr_0")
db_value = database.outputs.normald3_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:normalf3_0"))
attribute = test_node.get_attribute("outputs:normalf3_0")
db_value = database.outputs.normalf3_0
self.assertTrue(test_node.get_attribute_exists("outputs:normalf3_arr_0"))
attribute = test_node.get_attribute("outputs:normalf3_arr_0")
db_value = database.outputs.normalf3_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:normalh3_0"))
attribute = test_node.get_attribute("outputs:normalh3_0")
db_value = database.outputs.normalh3_0
self.assertTrue(test_node.get_attribute_exists("outputs:normalh3_arr_0"))
attribute = test_node.get_attribute("outputs:normalh3_arr_0")
db_value = database.outputs.normalh3_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:pointd3_0"))
attribute = test_node.get_attribute("outputs:pointd3_0")
db_value = database.outputs.pointd3_0
self.assertTrue(test_node.get_attribute_exists("outputs:pointd3_arr_0"))
attribute = test_node.get_attribute("outputs:pointd3_arr_0")
db_value = database.outputs.pointd3_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:pointf3_0"))
attribute = test_node.get_attribute("outputs:pointf3_0")
db_value = database.outputs.pointf3_0
self.assertTrue(test_node.get_attribute_exists("outputs:pointf3_arr_0"))
attribute = test_node.get_attribute("outputs:pointf3_arr_0")
db_value = database.outputs.pointf3_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:pointh3_0"))
attribute = test_node.get_attribute("outputs:pointh3_0")
db_value = database.outputs.pointh3_0
self.assertTrue(test_node.get_attribute_exists("outputs:pointh3_arr_0"))
attribute = test_node.get_attribute("outputs:pointh3_arr_0")
db_value = database.outputs.pointh3_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:quatd4_0"))
attribute = test_node.get_attribute("outputs:quatd4_0")
db_value = database.outputs.quatd4_0
self.assertTrue(test_node.get_attribute_exists("outputs:quatd4_arr_0"))
attribute = test_node.get_attribute("outputs:quatd4_arr_0")
db_value = database.outputs.quatd4_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:quatf4_0"))
attribute = test_node.get_attribute("outputs:quatf4_0")
db_value = database.outputs.quatf4_0
self.assertTrue(test_node.get_attribute_exists("outputs:quatf4_arr_0"))
attribute = test_node.get_attribute("outputs:quatf4_arr_0")
db_value = database.outputs.quatf4_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:quath4_0"))
attribute = test_node.get_attribute("outputs:quath4_0")
db_value = database.outputs.quath4_0
self.assertTrue(test_node.get_attribute_exists("outputs:quath4_arr_0"))
attribute = test_node.get_attribute("outputs:quath4_arr_0")
db_value = database.outputs.quath4_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:texcoordd2_0"))
attribute = test_node.get_attribute("outputs:texcoordd2_0")
db_value = database.outputs.texcoordd2_0
self.assertTrue(test_node.get_attribute_exists("outputs:texcoordd2_arr_0"))
attribute = test_node.get_attribute("outputs:texcoordd2_arr_0")
db_value = database.outputs.texcoordd2_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:texcoordd3_0"))
attribute = test_node.get_attribute("outputs:texcoordd3_0")
db_value = database.outputs.texcoordd3_0
self.assertTrue(test_node.get_attribute_exists("outputs:texcoordd3_arr_0"))
attribute = test_node.get_attribute("outputs:texcoordd3_arr_0")
db_value = database.outputs.texcoordd3_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:texcoordf2_0"))
attribute = test_node.get_attribute("outputs:texcoordf2_0")
db_value = database.outputs.texcoordf2_0
self.assertTrue(test_node.get_attribute_exists("outputs:texcoordf2_arr_0"))
attribute = test_node.get_attribute("outputs:texcoordf2_arr_0")
db_value = database.outputs.texcoordf2_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:texcoordf3_0"))
attribute = test_node.get_attribute("outputs:texcoordf3_0")
db_value = database.outputs.texcoordf3_0
self.assertTrue(test_node.get_attribute_exists("outputs:texcoordf3_arr_0"))
attribute = test_node.get_attribute("outputs:texcoordf3_arr_0")
db_value = database.outputs.texcoordf3_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:texcoordh2_0"))
attribute = test_node.get_attribute("outputs:texcoordh2_0")
db_value = database.outputs.texcoordh2_0
self.assertTrue(test_node.get_attribute_exists("outputs:texcoordh2_arr_0"))
attribute = test_node.get_attribute("outputs:texcoordh2_arr_0")
db_value = database.outputs.texcoordh2_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:texcoordh3_0"))
attribute = test_node.get_attribute("outputs:texcoordh3_0")
db_value = database.outputs.texcoordh3_0
self.assertTrue(test_node.get_attribute_exists("outputs:texcoordh3_arr_0"))
attribute = test_node.get_attribute("outputs:texcoordh3_arr_0")
db_value = database.outputs.texcoordh3_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:timecode_0"))
attribute = test_node.get_attribute("outputs:timecode_0")
db_value = database.outputs.timecode_0
self.assertTrue(test_node.get_attribute_exists("outputs:timecode_arr_0"))
attribute = test_node.get_attribute("outputs:timecode_arr_0")
db_value = database.outputs.timecode_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:token_0"))
attribute = test_node.get_attribute("outputs:token_0")
db_value = database.outputs.token_0
self.assertTrue(test_node.get_attribute_exists("outputs:token_arr_0"))
attribute = test_node.get_attribute("outputs:token_arr_0")
db_value = database.outputs.token_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:transform4_0"))
attribute = test_node.get_attribute("outputs:transform4_0")
db_value = database.outputs.transform4_0
self.assertTrue(test_node.get_attribute_exists("outputs:transform4_arr_0"))
attribute = test_node.get_attribute("outputs:transform4_arr_0")
db_value = database.outputs.transform4_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:uchar_0"))
attribute = test_node.get_attribute("outputs:uchar_0")
db_value = database.outputs.uchar_0
self.assertTrue(test_node.get_attribute_exists("outputs:uchar_arr_0"))
attribute = test_node.get_attribute("outputs:uchar_arr_0")
db_value = database.outputs.uchar_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:uint64_0"))
attribute = test_node.get_attribute("outputs:uint64_0")
db_value = database.outputs.uint64_0
self.assertTrue(test_node.get_attribute_exists("outputs:uint64_arr_0"))
attribute = test_node.get_attribute("outputs:uint64_arr_0")
db_value = database.outputs.uint64_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:uint_0"))
attribute = test_node.get_attribute("outputs:uint_0")
db_value = database.outputs.uint_0
self.assertTrue(test_node.get_attribute_exists("outputs:uint_arr_0"))
attribute = test_node.get_attribute("outputs:uint_arr_0")
db_value = database.outputs.uint_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:vectord3_0"))
attribute = test_node.get_attribute("outputs:vectord3_0")
db_value = database.outputs.vectord3_0
self.assertTrue(test_node.get_attribute_exists("outputs:vectord3_arr_0"))
attribute = test_node.get_attribute("outputs:vectord3_arr_0")
db_value = database.outputs.vectord3_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:vectorf3_0"))
attribute = test_node.get_attribute("outputs:vectorf3_0")
db_value = database.outputs.vectorf3_0
self.assertTrue(test_node.get_attribute_exists("outputs:vectorf3_arr_0"))
attribute = test_node.get_attribute("outputs:vectorf3_arr_0")
db_value = database.outputs.vectorf3_arr_0
self.assertTrue(test_node.get_attribute_exists("outputs:vectorh3_0"))
attribute = test_node.get_attribute("outputs:vectorh3_0")
db_value = database.outputs.vectorh3_0
self.assertTrue(test_node.get_attribute_exists("outputs:vectorh3_arr_0"))
attribute = test_node.get_attribute("outputs:vectorh3_arr_0")
db_value = database.outputs.vectorh3_arr_0
| 86,139 | Python | 49.970414 | 140 | 0.666191 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/_impl/extension.py | """
Support required by the Carbonite extension loader
"""
import omni.ext
class _PublicExtension(omni.ext.IExt):
"""Object that tracks the lifetime of the Python part of the extension loading"""
def on_startup(self):
"""Set up initial conditions for the Python part of the extension"""
def on_shutdown(self):
"""Shutting down this part of the extension prepares it for hot reload"""
| 416 | Python | 26.799998 | 85 | 0.701923 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/tests/test_api.py | """Testing the stability of the API in this module"""
import omni.graph.core.tests as ogts
import omni.graph.examples.python as ogep
from omni.graph.tools.tests.internal_utils import _check_module_api_consistency, _check_public_api_contents
# ======================================================================
class _TestOmniGraphExamplesPythonApi(ogts.OmniGraphTestCase):
_UNPUBLISHED = ["bindings", "ogn", "tests"]
async def test_api(self):
_check_module_api_consistency(ogep, self._UNPUBLISHED) # noqa: PLW0212
_check_module_api_consistency(ogep.tests, is_test_module=True) # noqa: PLW0212
async def test_api_features(self):
"""Test that the known public API features continue to exist"""
_check_public_api_contents(ogep, [], self._UNPUBLISHED, only_expected_allowed=True) # noqa: PLW0212
_check_public_api_contents(ogep.tests, [], [], only_expected_allowed=True) # noqa: PLW0212
| 947 | Python | 48.894734 | 108 | 0.661035 |
omniverse-code/kit/exts/omni.graph.examples.python/omni/graph/examples/python/tests/test_omnigraph_python_examples.py | import math
import os
import omni.graph.core as og
import omni.graph.core.tests as ogts
import omni.kit.test
import omni.timeline
import omni.usd
from pxr import Gf, Sdf, UsdGeom
def example_deformer1(input_point, width, height, freq):
"""Implement simple deformation on the input point with the given wavelength, wave height, and frequency"""
tx = freq * (input_point[0] - width) / width
ty = 1.5 * freq * (input_point[1] - width) / width
tz = height * (math.sin(tx) + math.cos(ty))
return Gf.Vec3f(input_point[0], input_point[1], input_point[2] + tz)
class TestOmniGraphPythonExamples(ogts.OmniGraphTestCase):
# ----------------------------------------------------------------------
async def verify_example_deformer(self):
"""Compare the actual deformation against the expected values using example_deformer1"""
stage = omni.usd.get_context().get_stage()
input_grid = stage.GetPrimAtPath("/defaultPrim/inputGrid")
self.assertEqual(input_grid.GetTypeName(), "Mesh")
input_points_attr = input_grid.GetAttribute("points")
self.assertIsNotNone(input_points_attr)
output_grid = stage.GetPrimAtPath("/defaultPrim/outputGrid")
self.assertEqual(output_grid.GetTypeName(), "Mesh")
output_points_attr = output_grid.GetAttribute("points")
self.assertIsNotNone(output_points_attr)
await omni.kit.app.get_app().next_update_async()
await og.Controller.evaluate()
multiplier_attr = og.Controller.attribute("inputs:multiplier", "/defaultPrim/DeformerGraph/testDeformer")
multiplier = og.Controller.get(multiplier_attr)
# TODO: Should really be using hardcoded values from the file to ensure correct operation
# multiplier = 3.0
width = 310.0
height = multiplier * 10.0
freq = 10.0
# check that the deformer applies the correct deformation
input_points = input_points_attr.Get()
output_points = output_points_attr.Get()
actual_points = []
for input_point, output_point in zip(input_points, output_points):
point = example_deformer1(input_point, width, height, freq)
self.assertEqual(point[0], output_point[0])
self.assertEqual(point[1], output_point[1])
# verify that the z-coordinates computed by the test and the deformer match to three decimal places
actual_points.append(point)
self.assertAlmostEqual(point[2], output_point[2], 3)
# need to wait for next update to propagate the attribute change from USD
og.Controller.set(multiplier_attr, 0.0)
await omni.kit.app.get_app().next_update_async()
# check that the deformer with a zero multiplier leaves the grid undeformed
input_points = input_points_attr.Get()
output_points = output_points_attr.Get()
for input_point, output_point in zip(input_points, output_points):
self.assertEqual(input_point, output_point)
# ----------------------------------------------------------------------
async def test_example_deformer_python(self):
"""Tests the omnigraph.examples.deformerPy node"""
(result, error) = await og.load_example_file("ExampleGridDeformerPython.usda")
self.assertTrue(result, error)
await omni.kit.app.get_app().next_update_async()
await self.verify_example_deformer()
# ----------------------------------------------------------------------
async def run_python_node_creation_by_command(self, node_backed_by_usd=True):
"""
This tests the creation of python nodes through the node definition mechanism
We have a python node type that defines the inputs and outputs of a python node
type. Here, without pre-declaring these attributes in USD, we will create the
node using its node type definition only. The required attributes should
automatically be created for the node. We then wire it up to make sure it works.
"""
graph = og.Controller.create_graph("/defaultPrim/TestGraph")
new_node_path = "/defaultPrim/TestGraph/new_node"
omni.kit.commands.execute(
"CreateNode",
graph=graph,
node_path=new_node_path,
node_type="omni.graph.examples.python.VersionedDeformerPy",
create_usd=node_backed_by_usd,
)
node = graph.get_node(new_node_path)
self.assertEqual(node.get_prim_path(), new_node_path)
# ----------------------------------------------------------------------
async def test_python_node_creation_by_command_usd(self):
"""Test that USD commands creating Python nodes also create OmniGraph nodes"""
await self.run_python_node_creation_by_command(node_backed_by_usd=True)
# ----------------------------------------------------------------------
async def test_python_node_creation_by_command_no_usd(self):
"""Test that USD commands creating Python nodes also create OmniGraph nodes"""
await self.run_python_node_creation_by_command(node_backed_by_usd=False)
# ----------------------------------------------------------------------
async def test_update_node_version(self):
usd_context = omni.usd.get_context()
stage = usd_context.get_stage()
controller = og.Controller()
(input_grid, output_grid) = ogts.create_input_and_output_grid_meshes(stage)
input_points_attr = input_grid.GetPointsAttr()
output_points_attr = output_grid.GetPointsAttr()
keys = og.Controller.Keys
controller = og.Controller()
(push_graph, _, _, _) = controller.edit(
"/defaultPrim/pushGraph",
{
keys.CREATE_NODES: [
("ReadPoints", "omni.graph.nodes.ReadPrimAttribute"),
("WritePoints", "omni.graph.nodes.WritePrimAttribute"),
],
keys.SET_VALUES: [
("ReadPoints.inputs:name", input_points_attr.GetName()),
("ReadPoints.inputs:primPath", "/defaultPrim/inputGrid"),
("ReadPoints.inputs:usePath", True),
("WritePoints.inputs:name", output_points_attr.GetName()),
("WritePoints.inputs:primPath", "/defaultPrim/outputGrid"),
("WritePoints.inputs:usePath", True),
],
},
)
test_deformer = stage.DefinePrim("/defaultPrim/pushGraph/testVersionedDeformer", "OmniGraphNode")
test_deformer.GetAttribute("node:type").Set("omni.graph.examples.python.VersionedDeformerPy")
test_deformer.GetAttribute("node:typeVersion").Set(0)
deformer_input_points = test_deformer.CreateAttribute("inputs:points", Sdf.ValueTypeNames.Point3fArray)
deformer_input_points.Set([(0, 0, 0)] * 1024)
deformer_output_points = test_deformer.CreateAttribute("outputs:points", Sdf.ValueTypeNames.Point3fArray)
deformer_output_points.Set([(0, 0, 0)] * 1024)
multiplier_attr = test_deformer.CreateAttribute("inputs:multiplier", Sdf.ValueTypeNames.Float)
multiplier_attr.Set(3)
await controller.evaluate()
controller.edit(
push_graph,
{
keys.CONNECT: [
("ReadPoints.outputs:value", deformer_input_points.GetPath().pathString),
(deformer_output_points.GetPath().pathString, "WritePoints.inputs:value"),
]
},
)
# Wait for USD notice handler to construct the underlying compute graph
await controller.evaluate()
# This node has 2 attributes declared as part of its node definition. We didn't create these attributes
# above, but the code should have automatically filled them in
version_deformer_node = push_graph.get_node("/defaultPrim/pushGraph/testVersionedDeformer")
input_attr = version_deformer_node.get_attribute("test_input")
output_attr = version_deformer_node.get_attribute("test_output")
self.assertTrue(input_attr is not None and input_attr.is_valid())
self.assertTrue(output_attr is not None and output_attr.is_valid())
self.assertEqual(input_attr.get_name(), "test_input")
self.assertEqual(input_attr.get_type_name(), "int")
self.assertEqual(output_attr.get_name(), "test_output")
self.assertEqual(output_attr.get_type_name(), "float")
# We added an union type input to this node as well, so test that is here:
union_attr = version_deformer_node.get_attribute("test_union_input")
self.assertTrue(union_attr is not None and union_attr.is_valid())
self.assertEqual(union_attr.get_name(), "test_union_input")
self.assertEqual(union_attr.get_type_name(), "token")
self.assertEqual(union_attr.get_extended_type(), og.ExtendedAttributeType.EXTENDED_ATTR_TYPE_UNION)
self.assertEqual(union_attr.get_resolved_type().base_type, og.BaseDataType.UNKNOWN)
union_attr.set_resolved_type(og.Type(og.BaseDataType.FLOAT))
self.assertEqual(union_attr.get_resolved_type(), og.Type(og.BaseDataType.FLOAT))
union_attr.set(32)
self.assertEqual(union_attr.get(), 32)
# Node version update happens as the nodes are constructed and checked against the node type
multiplier_attr = test_deformer.GetAttribute("inputs:multiplier")
self.assertFalse(multiplier_attr.IsValid())
wavelength_attr = test_deformer.GetAttribute("inputs:wavelength")
self.assertIsNotNone(wavelength_attr)
self.assertEqual(wavelength_attr.GetTypeName(), Sdf.ValueTypeNames.Float)
# attrib value should be initialized to 50
og_attr = controller.node("/defaultPrim/pushGraph/testVersionedDeformer").get_attribute("inputs:wavelength")
self.assertEqual(og_attr.get(), 50.0)
# ----------------------------------------------------------------------
async def test_example_tutorial1_finished(self):
"""Tests the deforming_text_tutorial_finished.usda file"""
ext_dir = os.path.dirname(__file__) + ("/.." * 5)
file_path = os.path.join(ext_dir, "data", "deforming_text_tutorial_finished.usda")
(result, error) = await ogts.load_test_file(file_path)
self.assertTrue(result, error)
await omni.kit.app.get_app().next_update_async()
await og.Controller.evaluate()
# Verify the test graph is functional. We take a look at the location of the sphere and the 'G' mesh. When we
# move the sphere it should also move the 'G'. If the 'G' is not moved from it's orginal location we know
# something is wrong.
stage = omni.usd.get_context().get_stage()
sphere = UsdGeom.Xformable(stage.GetPrimAtPath("/World/Sphere"))
text_g_mesh = UsdGeom.Xformable(stage.GetPrimAtPath("/World/Text_G"))
text_g_x0 = text_g_mesh.GetLocalTransformation()[3]
# Move the sphere
sphere.ClearXformOpOrder()
sphere_translate_op = sphere.AddTranslateOp()
sphere_translate_op.Set(Gf.Vec3d(0, 0, 0))
# Check the 'G' position has changed
await omni.kit.app.get_app().next_update_async()
text_g_x1 = text_g_mesh.GetLocalTransformation()[3]
self.assertNotEqual(text_g_x0, text_g_x1)
# ----------------------------------------------------------------------
async def test_singleton(self):
"""
Basic idea of test: we define a node that's been tagged as singleton. We then try to add another
node of the same type. It should fail and not let us.
"""
(graph, (singleton_node,), _, _) = og.Controller.edit(
"/TestGraph",
{og.Controller.Keys.CREATE_NODES: ("testSingleton", "omni.graph.examples.python.TestSingleton")},
)
singleton_node = graph.get_node("/TestGraph/testSingleton")
self.assertTrue(singleton_node.is_valid())
with ogts.ExpectedError():
(_, (other_node,), _, _) = og.Controller.edit(
graph, {og.Controller.Keys.CREATE_NODES: ("testSingleton2", "omni.graph.examples.python.TestSingleton")}
)
self.assertFalse(other_node.is_valid())
node = graph.get_node("/TestGraph/testSingleton")
self.assertTrue(node.is_valid())
node = graph.get_node("/TestGraph/testSingleton2")
self.assertFalse(node.is_valid())
# ----------------------------------------------------------------------
async def test_set_compute_incomplete(self):
"""
Test usage of OgnCountTo which leverages set_compute_incomplete API.
"""
controller = og.Controller()
keys = og.Controller.Keys
(_, nodes, _, _,) = controller.edit(
{"graph_path": "/World/TestGraph", "evaluator_name": "dirty_push"},
{
keys.CREATE_NODES: [
("CountTo", "omni.graph.examples.python.CountTo"),
],
keys.SET_VALUES: [
("CountTo.inputs:increment", 1),
],
},
)
count_out = controller.attribute("outputs:count", nodes[0])
self.assertEqual(og.Controller.get(count_out), 0.0)
await controller.evaluate()
self.assertEqual(og.Controller.get(count_out), 1.0)
await controller.evaluate()
self.assertEqual(og.Controller.get(count_out), 2.0)
await controller.evaluate()
self.assertEqual(og.Controller.get(count_out), 3.0)
await controller.evaluate()
self.assertEqual(og.Controller.get(count_out), 3.0)
| 13,779 | Python | 48.568345 | 120 | 0.609768 |
omniverse-code/kit/exts/omni.kit.widget.options_menu/omni/kit/widget/options_menu/options_model.py | from typing import List
import omni.ui as ui
from .option_item import OptionItem
class OptionsModel(ui.AbstractItemModel):
"""
Model for options items.
Args:
name (str): Model name to display in menu header.
items (List[OptionItem]): Items to show in menu.
"""
def __init__(self, name: str, items: List[OptionItem]):
self.name = name
self._items = items
self.__subs = {}
for item in self._items:
if item.name:
self.__subs[item] = item.model.subscribe_value_changed_fn(lambda m, i=item: self.__on_value_changed(i, m))
super().__init__()
def destroy(self):
self.__subs.clear()
@property
def dirty(self) -> bool:
"""
Flag if any item not in default value.
"""
for item in self._items:
if item.dirty:
return True
return False
def rebuild_items(self, items: List[OptionItem]) -> None:
"""
Rebuild option items.
Args:
items (List[OptionItem]): Items to show in menu.
"""
self.__subs.clear()
self._items = items
for item in self._items:
if item.name:
self.__subs[item] = item.model.subscribe_value_changed_fn(lambda m, i=item: self.__on_value_changed(i, m))
self._item_changed(None)
def reset(self) -> None:
"""
Reset all items to default value.
"""
for item in self._items:
item.reset()
def get_item_children(self) -> List[OptionItem]:
"""
Get items in this model.
"""
return self._items
def __on_value_changed(self, item: OptionItem, model: ui.SimpleBoolModel):
self._item_changed(item)
| 1,802 | Python | 25.910447 | 122 | 0.54384 |
omniverse-code/kit/exts/omni.kit.widget.options_menu/omni/kit/widget/options_menu/option_menu_item.py | import omni.ui as ui
from .option_item import OptionItem
class OptionMenuItemDelegate(ui.MenuDelegate):
"""
Delegate for general option menu item.
A general option item includes a selected icon and item text.
Args:
option_item (OptionItem): Option item to show as menu item.
Keyword Args:
width (ui.Length): Menu item width. Default ui.Fraction(1).
"""
def __init__(self, option_item: OptionItem, width: ui.Length = ui.Fraction(1)):
self._option_item = option_item
self._width = width
super().__init__(propagate=True)
def destroy(self):
self.__sub = None
def build_item(self, item: ui.MenuItem):
model = self._option_item.model
self.__sub = model.subscribe_value_changed_fn(self._on_value_changed)
self._container = ui.HStack(height=24, width=self._width, content_clipping=False, checked=model.as_bool)
with self._container:
ui.ImageWithProvider(width = 24, style_type_name_override="MenuItem.Icon")
ui.Label(
item.text,
style_type_name_override="MenuItem.Label",
)
ui.Spacer(width=16)
self._container.set_mouse_pressed_fn(lambda x, y, b, a, m=model: m.set_value(not m.as_bool))
self._container.set_mouse_hovered_fn(self._on_mouse_hovered)
def _on_value_changed(self, model: ui.SimpleBoolModel) -> None:
self._container.checked = model.as_bool
def _on_mouse_hovered(self, hovered: bool) -> None:
# Here to set selected instead of hovered status for icon.
# Because there is margin in icon, there will be some blank at top/bottom as a result icon does not become hovered if mouse on these area.
self._container.selected = hovered
class OptionMenuItem(ui.MenuItem):
"""
Represent a menu item for a single option.
Args:
option_item (OptionItem): Option item to show as menu item.
Keyword Args:
hide_on_click (bool): Hide menu if item clicked. Default False.
width (ui.Length): Menu item width. Default ui.Fraction(1).
"""
def __init__(self, option_item: OptionItem, hide_on_click: bool = False, width: ui.Length = ui.Fraction(1)):
self._delegate = OptionMenuItemDelegate(option_item, width=width)
super().__init__(option_item.text, delegate=self._delegate, hide_on_click=hide_on_click, checkable=True)
def destroy(self):
self._delegate.destroy()
| 2,502 | Python | 36.924242 | 146 | 0.642286 |
omniverse-code/kit/exts/omni.kit.widget.options_menu/omni/kit/widget/options_menu/style.py | from pathlib import Path
import omni.ui as ui
from omni.ui import color as cl
CURRENT_PATH = Path(__file__).parent.absolute()
ICON_PATH = CURRENT_PATH.parent.parent.parent.parent.joinpath(f"data/icons")
OPTIONS_MENU_STYLE = {
"Title.Background": {"background_color": 0xFF23211F, "corner_flag": ui.CornerFlag.TOP, "margin": 0},
"Title.Header": {"margin_width": 3, "margin_height": 0},
"Title.Label": {"background_color": 0x0, "color": cl.shade(cl('#A1A1A1')), "margin_width": 5},
"ResetButton": {"background_color": 0},
"ResetButton:hovered": {"background_color": cl.shade(cl('323434'))},
"ResetButton.Label": {"color": cl.shade(cl('#34C7FF'))},
"ResetButton.Label:disabled": {"color": cl.shade(cl('#6E6E6E'))},
"ResetButton.Label:hovered": {"color": cl.shade(cl('#1A91C5'))},
"MenuItem.Icon": {"image_url": f"{ICON_PATH}/check_solid.svg", "color": 0, "margin": 7},
"MenuItem.Icon:checked": {"color": cl.shade(cl('#34C7FF'))},
"MenuItem.Icon:selected": {"color": cl.shade(cl('#1F2123'))},
"MenuItem.Label::title": {"color": cl.shade(cl('#A1A1A1')), "margin_width": 5},
"MenuItem.Separator": {"color": cl.shade(cl('#626363')), "border_width": 1.5},
}
| 1,205 | Python | 47.239998 | 104 | 0.640664 |
omniverse-code/kit/exts/omni.kit.widget.options_menu/omni/kit/widget/options_menu/option_separator.py | import omni.ui as ui
class SeparatorDelegate(ui.MenuDelegate):
"""Menu delegate for separator"""
def build_item(self, _):
with ui.HStack():
ui.Spacer(width=24)
ui.Line(height=10, style_type_name_override="MenuItem.Separator")
ui.Spacer(width=8)
class OptionSeparator(ui.MenuItem):
"""A simple separator"""
def __init__(self):
super().__init__("##OPTION_SEPARATOR", delegate=SeparatorDelegate(), enabled=False)
| 482 | Python | 27.411763 | 91 | 0.628631 |
omniverse-code/kit/exts/omni.kit.widget.options_menu/omni/kit/widget/options_menu/__init__.py | from .options_menu import OptionsMenu
from .options_model import OptionsModel
from .option_item import OptionItem, OptionSeparator
| 132 | Python | 25.599995 | 52 | 0.840909 |
omniverse-code/kit/exts/omni.kit.widget.options_menu/omni/kit/widget/options_menu/option_item.py | from typing import Optional, Callable
import omni.ui as ui
class OptionItem(ui.AbstractItem):
"""
Represent an item for OptionsMenu.
Args:
name (str): Item name.
Keyword args:
text (str): Item text to show in menu item. Default None means using name.
default (bool): Default item value. Default False.
on_value_changed_fn (Callable[[bool], None]): Callback when item value changed.
"""
def __init__(self, name: Optional[str], text: Optional[str] = None, default: bool = False, on_value_changed_fn: Callable[[bool], None] = None):
self.name = name
self.text = text or name
self.default = default
self.model = ui.SimpleBoolModel(default)
if on_value_changed_fn:
self.__on_value_changed_fn = on_value_changed_fn
def __on_value_changed(model: ui.SimpleBoolModel):
self.__on_value_changed_fn(model.as_bool)
self.__sub = self.model.subscribe_value_changed_fn(__on_value_changed)
super().__init__()
def destroy(self):
self.__sub = None
@property
def value(self) -> bool:
"""
Item current value.
"""
return self.model.as_bool
@value.setter
def value(self, new_value: bool) -> None:
self.model.set_value(new_value)
@property
def dirty(self) -> bool:
"""
Flag of item value changed.
"""
return self.model.as_bool != self.default
def reset(self) -> None:
"""
Reset item value to default.
"""
self.model.set_value(self.default)
class OptionSeparator(OptionItem):
"""
A simple option item represents a separator in menu item.
"""
def __init__(self):
super().__init__(None) | 1,814 | Python | 26.5 | 147 | 0.579383 |
omniverse-code/kit/exts/omni.kit.widget.options_menu/omni/kit/widget/options_menu/options_menu.py | from typing import Optional
import omni.ui as ui
from .option_item import OptionItem
from .option_menu_item import OptionMenuItem
from .options_model import OptionsModel
from .option_separator import OptionSeparator
from .style import OPTIONS_MENU_STYLE
class OptionsMenuDelegate(ui.MenuDelegate):
"""
Delegate for options menu.
It has a header to show label and reset button
Args:
model (OptionsModel): Model for options to show in this menu.
"""
def __init__(self, model: OptionsModel, **kwargs):
self._model = model
self._reset_all: Optional[ui.Button] = None
self.__sub = self._model.subscribe_item_changed_fn(self.__on_item_changed)
super().__init__(**kwargs)
def destroy(self) -> None:
self.__sub = None
def build_title(self, item: ui.Menu) -> None:
with ui.ZStack(content_clipping=True, height=24):
ui.Rectangle(style_type_name_override="Title.Background")
with ui.HStack(style_type_name_override="Title.Header"):
if item.text:
ui.Label(self._model.name, width=0, style_type_name_override="Title.Label")
# Extra spacer here to make sure menu window has min width
ui.Spacer(width=45)
ui.Spacer()
self._reset_all = ui.Button(
"Reset All",
width=0,
height=24,
enabled=self._model.dirty,
style_type_name_override="ResetButton",
clicked_fn=self._model.reset,
identifier="reset_all",
)
def __on_item_changed(self, model: OptionsModel, item: OptionItem) -> None:
if self._reset_all:
self._reset_all.enabled = self._model.dirty
class OptionsMenu(ui.Menu):
"""
Represent a menu to show options.
A options menu includes a header and a list of menu items for options.
Args:
model (OptionsModel): Model of option items to show in this menu.
hide_on_click (bool): Hide menu when item clicked. Default False.
width (ui.Length): Width of menu item. Default ui.Fraction(1).
style (dict): Additional style. Default empty.
"""
def __init__(self, model: OptionsModel, hide_on_click: bool = False, width: ui.Length = ui.Fraction(1), style: dict = {}):
self._model = model
self._hide_on_click = hide_on_click
self._width = width
menu_style = OPTIONS_MENU_STYLE.copy()
menu_style.update(style)
self._delegate = OptionsMenuDelegate(self._model)
super().__init__(self._model.name, delegate=self._delegate, menu_compatibility=False, on_build_fn=self._build_menu_items, style=menu_style)
self.__sub = self._model.subscribe_item_changed_fn(self.__on_model_changed)
def destroy(self):
self.__sub = None
self._delegate.destroy()
def show_by_widget(self, widget: ui.Widget) -> None:
"""
Show menu around widget (bottom left).
Args:
widget (ui.Widget): Widget to align for this menu.
"""
if widget:
x = widget.screen_position_x
y = widget.screen_position_y + widget.computed_height
self.show_at(x, y)
else:
self.show()
def _build_menu_items(self):
for item in self._model.get_item_children():
if item.text is None:
# Separator
OptionSeparator()
else:
OptionMenuItem(item, hide_on_click=self._hide_on_click, width=self._width)
def __on_model_changed(self, model: OptionsModel, item: Optional[OptionItem]) -> None:
if item is None:
self.invalidate()
| 3,803 | Python | 34.886792 | 147 | 0.591112 |
omniverse-code/kit/exts/omni.kit.widget.options_menu/omni/kit/widget/options_menu/tests/__init__.py | from .test_ui import *
| 23 | Python | 10.999995 | 22 | 0.695652 |
omniverse-code/kit/exts/omni.kit.widget.options_menu/omni/kit/widget/options_menu/tests/test_ui.py | from pathlib import Path
import omni.kit.ui_test as ui_test
from omni.ui.tests.test_base import OmniUiTest
from ..options_menu import OptionsMenu
from ..options_model import OptionsModel
from ..option_item import OptionItem, OptionSeparator
CURRENT_PATH = Path(__file__).parent.absolute()
TEST_DATA_PATH = CURRENT_PATH.parent.parent.parent.parent.parent.joinpath("data/tests")
class TestOptions(OmniUiTest):
# Before running each test
async def setUp(self):
self._model = OptionsModel(
"Filter",
[
OptionItem("audio", text="Audio"),
OptionItem("materials", text="Materials"),
OptionItem("scripts", text="Scripts"),
OptionItem("textures", text="Textures"),
OptionItem("usd", text="USD"),
]
)
self._golden_img_dir = TEST_DATA_PATH.absolute().joinpath("golden")
await super().setUp()
# After running each test
async def tearDown(self):
await super().tearDown()
async def finalize_test(self, golden_img_name: str):
await self.wait_n_updates()
await super().finalize_test(golden_img_dir=self._golden_img_dir, golden_img_name=golden_img_name)
await self.wait_n_updates()
async def test_ui_layout(self):
"""Test ui, reset and API to get/set value"""
items = self._model.get_item_children()
self._changed_names = []
def _on_item_changed(_, item: OptionItem):
self._changed_names.append(item.name)
self._sub = self._model.subscribe_item_changed_fn(_on_item_changed)
menu = OptionsMenu(self._model)
menu.show_at(0, 0)
try:
# Initial UI
await ui_test.emulate_mouse_move(ui_test.Vec2(0, 0))
await ui_test.human_delay()
await self.finalize_test("options_menu.png")
# Change first and last item via mouse click
await ui_test.human_delay()
await ui_test.emulate_mouse_move_and_click(ui_test.Vec2(50, 45))
await ui_test.human_delay()
await ui_test.emulate_mouse_move_and_click(ui_test.Vec2(50, 145))
await ui_test.human_delay()
self.assertEqual(len(self._changed_names), 2)
self.assertEqual(self._changed_names[0], items[0].name)
self.assertEqual(self._changed_names[1], items[-1].name)
await self.finalize_test("options_menu_click.png")
# Change value via item property
items[2].value = not items[2].value
items[3].value = not items[3].value
await self.finalize_test("options_menu_value_changed.png")
# Reset all
await ui_test.emulate_mouse_move_and_click(ui_test.Vec2(120, 20))
await self.finalize_test("options_menu.png")
finally:
menu.destroy()
async def test_ui_rebuild_items(self):
"""Test ui, reset and API to get/set value"""
items = self._model.get_item_children()
menu = OptionsMenu(self._model)
menu.show_at(0, 0)
try:
# Initial UI
await ui_test.emulate_mouse_move(ui_test.Vec2(0, 0))
await ui_test.human_delay()
await self.finalize_test("options_menu.png")
self._model.rebuild_items(
[
OptionItem("Test"),
OptionSeparator(),
OptionItem("More"),
]
)
await ui_test.human_delay()
await self.finalize_test("options_menu_rebuild.png")
self._model.rebuild_items(items)
await ui_test.human_delay()
await self.finalize_test("options_menu.png")
finally:
menu.destroy()
| 3,827 | Python | 33.486486 | 105 | 0.577215 |
omniverse-code/kit/exts/omni.kit.welcome.about/omni/kit/welcome/about/style.py | from pathlib import Path
import omni.ui as ui
from omni.ui import color as cl
from omni.ui import constant as fl
CURRENT_PATH = Path(__file__).parent
ICON_PATH = CURRENT_PATH.parent.parent.parent.parent.joinpath("icons")
ABOUT_PAGE_STYLE = {
"Info": { "background_color": cl("#1F2123") },
"Title.Label": { "font_size": fl.welcome_title_font_size },
"Version.Label": { "font_size": 18, "margin_width": 5 },
"Plugin.Title": { "font_size": 16, "margin_width": 5 },
"Plugin.Label": { "font_size": 16, "margin_width": 5 },
"Plugin.Frame": { "background_color": 0xFF454545, "margin_width": 2, "margin_height": 3, "margin": 5 }
}
| 650 | Python | 35.166665 | 106 | 0.646154 |
omniverse-code/kit/exts/omni.kit.welcome.about/omni/kit/welcome/about/extension.py | from typing import List
import carb.settings
import carb.tokens
import omni.client
import omni.ext
import omni.ui as ui
from omni.kit.welcome.window import register_page
from omni.ui import constant as fl
from .style import ABOUT_PAGE_STYLE
_extension_instance = None
class AboutPageExtension(omni.ext.IExt):
def on_startup(self, ext_id):
self.__ext_name = omni.ext.get_extension_name(ext_id)
register_page(self.__ext_name, self.build_ui)
def on_shutdown(self):
global _extension_instance
_extension_instance = None
self._about_widget = None
def build_ui(self) -> None:
with ui.ZStack(style=ABOUT_PAGE_STYLE):
# Background
ui.Rectangle(style_type_name_override="Content")
with ui.VStack():
with ui.VStack(height=fl._find("welcome_page_title_height")):
ui.Spacer()
ui.Label("ABOUT", height=0, alignment=ui.Alignment.CENTER, style_type_name_override="Title.Label")
ui.Spacer()
with ui.HStack():
ui.Spacer(width=fl._find("welcome_content_padding_x"))
with ui.VStack():
with ui.ZStack():
ui.Rectangle(style_type_name_override="Info")
self.__build_content()
ui.Spacer(width=fl._find("welcome_content_padding_x"))
ui.Spacer(height=fl._find("welcome_content_padding_y"))
def __build_content(self):
import omni.kit.app
manager = omni.kit.app.get_app().get_extension_manager()
manager.set_extension_enabled_immediate("omni.kit.window.about", True)
from omni.kit.window.about import AboutWidget
with ui.Frame():
self._about_widget = AboutWidget()
| 1,849 | Python | 32.636363 | 118 | 0.593294 |
omniverse-code/kit/exts/omni.kit.welcome.about/omni/kit/welcome/about/tests/test_page.py | import asyncio
from pathlib import Path
import omni.kit.app
from omni.ui.tests.test_base import OmniUiTest
from ..extension import AboutPageExtension
CURRENT_PATH = Path(__file__).parent
TEST_DATA_PATH = CURRENT_PATH.parent.parent.parent.parent.parent.joinpath("data").joinpath("tests")
class TestPage(OmniUiTest):
# Before running each test
async def setUp(self):
await super().setUp()
self._golden_img_dir = TEST_DATA_PATH.absolute().joinpath("golden_img").absolute()
# After running each test
async def tearDown(self):
await super().tearDown()
async def test_page(self):
window = await self.create_test_window(width=800, height=500)
with window.frame:
ext = AboutPageExtension()
ext.on_startup("omni.kit.welcome.extensions-1.1.0")
ext.build_ui()
ext._about_widget.app_info = "#App Name# #App Version#"
ext._about_widget.versions = ["About test version #1", "About test version #2", "About test version #3"]
class FakePluginImpl():
def __init__(self, name):
self.name = name
class FakePlugin():
def __init__(self, name):
self.libPath = "Lib Path " + name
self.impl = FakePluginImpl("Impl " + name)
self.interfaces = "Interface " + name
ext._about_widget.plugins = [FakePlugin("Test 1"), FakePlugin("Test 2"), FakePlugin("Test 3"), FakePlugin("Test 4")]
await omni.kit.app.get_app().next_update_async()
# Wait for image loaded
await asyncio.sleep(5)
await self.finalize_test(golden_img_dir=self._golden_img_dir, golden_img_name="page.png")
| 1,765 | Python | 35.040816 | 128 | 0.603399 |
omniverse-code/kit/exts/omni.kit.viewport.manipulator.transform/omni/kit/viewport/manipulator/transform/fakeGf.py | import math
from usdrt import Gf
def GfRotation(axis0, angle):
axis = Gf.Vec3d(axis0[0], axis0[1], axis0[2]).GetNormalized()
quat = Gf.Quatd()
s = math.sin(math.radians (angle*0.5 ) )
qx = axis[0] * s
qy = axis[1] * s
qz = axis[2] * s
qw = math.cos( math.radians (angle/2) )
i = Gf.Vec3d(qx, qy, qz)
quat.SetReal(qw)
quat.SetImaginary(i)
return quat
| 397 | Python | 21.11111 | 65 | 0.586902 |
omniverse-code/kit/exts/omni.kit.viewport.manipulator.transform/omni/kit/viewport/manipulator/transform/__init__.py | from .extension import *
from .model import *
| 46 | Python | 14.666662 | 24 | 0.73913 |
omniverse-code/kit/exts/omni.kit.viewport.manipulator.transform/omni/kit/viewport/manipulator/transform/utils.py | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#
import carb
import carb.profiler
import carb.settings
@carb.profiler.profile
def flatten(transform):
"""Convert array[4][4] to array[16]"""
# flatten the matrix by hand
# USING LIST COMPREHENSION IS VERY SLOW (e.g. return [item for sublist in transform for item in sublist]), which takes around 10ms.
m0, m1, m2, m3 = transform[0], transform[1], transform[2], transform[3]
return [
m0[0],
m0[1],
m0[2],
m0[3],
m1[0],
m1[1],
m1[2],
m1[3],
m2[0],
m2[1],
m2[2],
m2[3],
m3[0],
m3[1],
m3[2],
m3[3],
] | 1,078 | Python | 27.394736 | 135 | 0.628942 |
omniverse-code/kit/exts/omni.kit.viewport.manipulator.transform/omni/kit/viewport/manipulator/transform/model.py | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#
from __future__ import annotations
# import asyncio
# import math
# import traceback
from enum import Enum, Flag, IntEnum, auto
# from typing import Dict, List, Sequence, Set, Tuple, Union
# import concurrent.futures
import carb
import carb.dictionary
import carb.events
import carb.profiler
import carb.settings
# import omni.kit.app
from omni.kit.async_engine import run_coroutine
import omni.kit.undo
import omni.timeline
# from omni.kit.manipulator.tool.snap import settings_constants as snap_c
from omni.kit.manipulator.transform import AbstractTransformManipulatorModel, Operation
# from omni.kit.manipulator.transform.settings_constants import c
# from omni.kit.manipulator.transform.settings_listener import OpSettingsListener, SnapSettingsListener
# from omni.ui import scene as sc
# from pxr import Gf, Sdf, Tf, Usd, UsdGeom, UsdUtils
# from .utils import *
# from .settings_constants import Constants as prim_c
class ManipulationMode(IntEnum):
PIVOT = 0 # transform around manipulator pivot
UNIFORM = 1 # set same world transform from manipulator to all prims equally
INDIVIDUAL = 2 # 2: (TODO) transform around each prim's own pivot respectively
class Viewport1WindowState:
def __init__(self):
self._focused_windows = None
focused_windows = []
try:
# For some reason is_focused may return False, when a Window is definitely in fact is the focused window!
# And there's no good solution to this when multiple Viewport-1 instances are open; so we just have to
# operate on all Viewports for a given usd_context.
import omni.kit.viewport_legacy as vp
vpi = vp.acquire_viewport_interface()
for instance in vpi.get_instance_list():
window = vpi.get_viewport_window(instance)
if not window:
continue
focused_windows.append(window)
if focused_windows:
self._focused_windows = focused_windows
for window in self._focused_windows:
# Disable the selection_rect, but enable_picking for snapping
window.disable_selection_rect(True)
# Schedule a picking request so if snap needs it later, it may arrive by the on_change event
window.request_picking()
except Exception:
pass
def get_picked_world_pos(self):
if self._focused_windows:
# Try to reduce to the focused window now after, we've had some mouse-move input
focused_windows = [window for window in self._focused_windows if window.is_focused()]
if focused_windows:
self._focused_windows = focused_windows
for window in self._focused_windows:
window.disable_selection_rect(True)
# request picking FOR NEXT FRAME
window.request_picking()
# get PREVIOUSLY picked pos, it may be None the first frame but that's fine
return window.get_picked_world_pos()
return None
def __del__(self):
self.destroy()
def destroy(self):
self._focused_windows = None
def get_usd_context_name(self):
if self._focused_windows:
return self._focused_windows[0].get_usd_context_name()
else:
return ""
class DataAccessorRegistry():
def __init__(self):
...
def getDataAccessor(self):
self.dataAccessor = DataAccessor()
return self.dataAccessor
class DataAccessor():
def __init__(self):
...
def get_local_to_world_transform(self, obj):
...
def get_parent_to_world_transform(self, obj):
...
def clear_xform_cache(self):
...
class ViewportTransformModel(AbstractTransformManipulatorModel):
def __init__(self, usd_context_name: str = "", viewport_api=None):
super().__init__() | 4,385 | Python | 38.160714 | 117 | 0.662942 |
omniverse-code/kit/exts/omni.kit.viewport.manipulator.transform/omni/kit/viewport/manipulator/transform/gestures.py | # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#
from __future__ import annotations
import asyncio
import math
import traceback
from enum import Enum, Flag, IntEnum, auto
from typing import Dict, List, Sequence, Set, Tuple, Union
import concurrent.futures
import carb
import carb.dictionary
import carb.events
import carb.profiler
import carb.settings
import omni.kit.app
from omni.kit.async_engine import run_coroutine
import omni.kit.commands
import omni.kit.undo
import omni.timeline
from omni.kit.manipulator.tool.snap import SnapProviderManager
# from omni.kit.manipulator.tool.snap import settings_constants as snap_c
from omni.kit.manipulator.transform.gestures import (
RotateChangedGesture,
RotateDragGesturePayload,
ScaleChangedGesture,
ScaleDragGesturePayload,
TransformDragGesturePayload,
TranslateChangedGesture,
TranslateDragGesturePayload,
)
from omni.kit.manipulator.transform import Operation
from omni.kit.manipulator.transform.settings_constants import c
from omni.ui import scene as sc
from .model import ViewportTransformModel, ManipulationMode, Viewport1WindowState
from .utils import flatten
from .fakeGf import GfRotation
# from usdrt import Sdf, Usd, UsdGeom
from usdrt import Gf
class ViewportTransformChangedGestureBase:
def __init__(self, usd_context_name: str = "", viewport_api=None):
self._settings = carb.settings.get_settings()
self._usd_context_name = usd_context_name
self._usd_context = omni.usd.get_context(self._usd_context_name)
self._viewport_api = viewport_api # VP2
self._vp1_window_state = None
self._stage_id = None
def on_began(self, payload_type=TransformDragGesturePayload):
self._viewport_on_began()
if not self.gesture_payload or not self.sender or not isinstance(self.gesture_payload, payload_type):
return
model = self.sender.model
if not model:
return
item = self.gesture_payload.changing_item
self._current_editing_op = item.operation
# NOTE! self._begin_xform has no scale. To get the full matrix, do self._begin_scale_mtx * self._begin_xform
self._begin_xform = Gf.Matrix4d(*model.get_as_floats(model.get_item("no_scale_transform_manipulator")))
manip_scale = Gf.Vec3d(*model.get_as_floats(model.get_item("scale_manipulator")))
self._begin_scale_mtx = Gf.Matrix4d(1.0)
self._begin_scale_mtx.SetScale(manip_scale)
model.set_floats(model.get_item("viewport_fps"), [0.0])
model.on_began(self.gesture_payload)
def on_changed(self, payload_type=TransformDragGesturePayload):
if not self.gesture_payload or not self.sender or not isinstance(self.gesture_payload, payload_type):
return
model = self.sender.model
if not model:
return
if self._viewport_api:
fps = self._viewport_api.frame_info.get("fps")
model.set_floats(model.get_item("viewport_fps"), [fps])
model.on_changed(self.gesture_payload)
def on_ended(self, payload_type=TransformDragGesturePayload):
self._viewport_on_ended()
if not self.gesture_payload or not self.sender or not isinstance(self.gesture_payload, payload_type):
return
model = self.sender.model
if not model:
return
item = self.gesture_payload.changing_item
if item.operation != self._current_editing_op:
return
model.set_floats(model.get_item("viewport_fps"), [0.0])
model.on_ended(self.gesture_payload)
self._current_editing_op = None
def on_canceled(self, payload_type=TransformDragGesturePayload):
self._viewport_on_ended()
if not self.gesture_payload or not self.sender or not isinstance(self.gesture_payload, payload_type):
return
model = self.sender.model
if not model:
return
item = self.gesture_payload.changing_item
if item.operation != self._current_editing_op:
return
model.on_canceled(self.gesture_payload)
self._current_editing_op = None
def _publish_delta(self, operation: Operation, delta: List[float]):
if operation == Operation.TRANSLATE:
self._settings.set_float_array(TRANSFORM_GIZMO_TRANSLATE_DELTA_XYZ, delta)
elif operation == Operation.ROTATE:
self._settings.set_float_array(TRANSFORM_GIZMO_ROTATE_DELTA_XYZW, delta)
elif operation == Operation.SCALE:
self._settings.set_float_array(TRANSFORM_GIZMO_SCALE_DELTA_XYZ, delta)
def __set_viewport_manipulating(self, value: int):
# Signal that user-manipulation has started for this stage
if self._stage_id is None:
# self._stage_id = UsdUtils.StageCache.Get().GetId(self._usd_context.get_stage()).ToLongInt()
self._stage_id = self._usd_context.get_stage_id()
key = f"/app/viewport/{self._stage_id}/manipulating"
cur_value = self._settings.get(key) or 0
self._settings.set(key, cur_value + value)
def _viewport_on_began(self):
self._viewport_on_ended()
if self._viewport_api is None:
self._vp1_window_state = Viewport1WindowState()
self.__set_viewport_manipulating(1)
def _viewport_on_ended(self):
if self._vp1_window_state:
self._vp1_window_state.destroy()
self._vp1_window_state = None
if self._stage_id:
self.__set_viewport_manipulating(-1)
self._stage_id = None
class ViewportTranslateChangedGesture(TranslateChangedGesture, ViewportTransformChangedGestureBase):
def __init__(self, snap_manager: SnapProviderManager, **kwargs):
ViewportTransformChangedGestureBase.__init__(self, **kwargs)
TranslateChangedGesture.__init__(self)
self._accumulated_translate = Gf.Vec3d(0)
self._snap_manager = snap_manager
def on_began(self):
ViewportTransformChangedGestureBase.on_began(self, TranslateDragGesturePayload)
self._accumulated_translate = Gf.Vec3d(0)
model = self._get_model(TranslateDragGesturePayload)
if model and self._can_snap(model):
# TODO No need for gesture=self when VP1 has viewport_api
self._snap_manager.on_began(model.consolidated_xformable_prim_data_curr.keys(), gesture=self)
if model:
model.set_floats(model.get_item("translate_delta"), [0, 0, 0])
def on_ended(self):
ViewportTransformChangedGestureBase.on_ended(self, TranslateDragGesturePayload)
model = self._get_model(TranslateDragGesturePayload)
if model and self._can_snap(model):
self._snap_manager.on_ended()
def on_canceled(self):
ViewportTransformChangedGestureBase.on_canceled(self, TranslateDragGesturePayload)
model = self._get_model(TranslateDragGesturePayload)
if model and self._can_snap(model):
self._snap_manager.on_ended()
@carb.profiler.profile
def on_changed(self):
ViewportTransformChangedGestureBase.on_changed(self, TranslateDragGesturePayload)
model = self._get_model(TranslateDragGesturePayload)
if not model:
return
manip_xform = Gf.Matrix4d(*model.get_as_floats(model.get_item("no_scale_transform_manipulator")))
new_manip_xform = Gf.Matrix4d(manip_xform)
rotation_mtx = manip_xform.ExtractRotationMatrix()
rotation_mtx.Orthonormalize()
translate_delta = self.gesture_payload.moved_delta
translate = self.gesture_payload.moved
axis = self.gesture_payload.axis
# slow Gf.Vec3d(*translate_delta)
translate_delta = Gf.Vec3d(translate_delta[0], translate_delta[1], translate_delta[2])
if model.op_settings_listener.translation_mode == c.TRANSFORM_MODE_LOCAL:
translate_delta = translate_delta * rotation_mtx
self._accumulated_translate += translate_delta
def apply_position(snap_world_pos=None, snap_world_orient=None, keep_spacing: bool = True):
nonlocal new_manip_xform
if self.state != sc.GestureState.CHANGED:
return
# only set translate if no snap or only snap to position
item_name = "translate"
if snap_world_pos and (
math.isfinite(snap_world_pos[0])
and math.isfinite(snap_world_pos[1])
and math.isfinite(snap_world_pos[2])
):
if snap_world_orient is None:
new_manip_xform.SetTranslateOnly(Gf.Vec3d(snap_world_pos[0], snap_world_pos[1], snap_world_pos[2]))
new_manip_xform = self._begin_scale_mtx * new_manip_xform
else:
new_manip_xform.SetTranslateOnly(Gf.Vec3d(snap_world_pos[0], snap_world_pos[1], snap_world_pos[2]))
new_manip_xform.SetRotateOnly(snap_world_orient)
# set transform if snap both position and orientation
item_name = "no_scale_transform_manipulator"
else:
new_manip_xform.SetTranslateOnly(self._begin_xform.ExtractTranslation() + self._accumulated_translate)
new_manip_xform = self._begin_scale_mtx * new_manip_xform
model.set_floats(model.get_item("translate_delta"), translate_delta)
if model.custom_manipulator_enabled:
self._publish_delta(Operation.TRANSLATE, translate_delta)
if keep_spacing is False:
mode_item = model.get_item("manipulator_mode")
prev_mode = model.get_as_ints(mode_item)
model.set_ints(mode_item, [int(ManipulationMode.UNIFORM)])
model.set_floats(model.get_item(item_name), flatten(new_manip_xform))
if keep_spacing is False:
model.set_ints(mode_item, prev_mode)
# only do snap to surface if drag the center point
if (
model.snap_settings_listener.snap_enabled
and model.snap_settings_listener.snap_provider
and axis == [1, 1, 1]
):
ndc_location = None
if self._viewport_api:
# No mouse location is available, have to convert back to NDC space
ndc_location = self.sender.transform_space(
sc.Space.WORLD, sc.Space.NDC, self.gesture_payload.ray_closest_point
)
if self._snap_manager.get_snap_pos(
new_manip_xform,
ndc_location,
self.sender.scene_view,
lambda **kwargs: apply_position(
kwargs.get("position", None), kwargs.get("orient", None), kwargs.get("keep_spacing", True)
),
):
return
apply_position()
def _get_model(self, payload_type) -> ViewportTransformModel:
if not self.gesture_payload or not self.sender or not isinstance(self.gesture_payload, payload_type):
return None
return self.sender.model
def _can_snap(self, model: ViewportTransformModel):
axis = self.gesture_payload.axis
if (
model.snap_settings_listener.snap_enabled
and model.snap_settings_listener.snap_provider
and axis == [1, 1, 1]
):
return True
return False
class ViewportRotateChangedGesture(RotateChangedGesture, ViewportTransformChangedGestureBase):
def __init__(self, **kwargs):
ViewportTransformChangedGestureBase.__init__(self, **kwargs)
RotateChangedGesture.__init__(self)
def on_began(self):
ViewportTransformChangedGestureBase.on_began(self, RotateDragGesturePayload)
model = self.sender.model
if model:
model.set_floats(model.get_item("rotate_delta"), [0, 0, 0, 0])
def on_ended(self):
ViewportTransformChangedGestureBase.on_ended(self, RotateDragGesturePayload)
def on_canceled(self):
ViewportTransformChangedGestureBase.on_canceled(self, RotateDragGesturePayload)
@carb.profiler.profile
def on_changed(self):
ViewportTransformChangedGestureBase.on_changed(self, RotateDragGesturePayload)
if (
not self.gesture_payload
or not self.sender
or not isinstance(self.gesture_payload, RotateDragGesturePayload)
):
return
model = self.sender.model
if not model:
return
axis = self.gesture_payload.axis
angle = self.gesture_payload.angle
angle_delta = self.gesture_payload.angle_delta
screen_space = self.gesture_payload.screen_space
free_rotation = self.gesture_payload.free_rotation
axis = Gf.Vec3d(*axis[:3])
rotate = GfRotation(axis, angle)
delta_axis = Gf.Vec4d(*axis, 0.0)
rot_matrix = Gf.Matrix4d(1)
rot_matrix.SetRotate(rotate)
if free_rotation:
rotate = GfRotation(axis, angle_delta)
rot_matrix = Gf.Matrix4d(1)
rot_matrix.SetRotate(rotate)
xform = Gf.Matrix4d(*model.get_as_floats(model.get_item("no_scale_transform_manipulator")))
full_xform = self._begin_scale_mtx * xform
translate = full_xform.ExtractTranslation()
no_translate_mtx = Gf.Matrix4d(full_xform)
no_translate_mtx.SetTranslateOnly(Gf.Vec3d(0))
no_translate_mtx = no_translate_mtx * rot_matrix
new_transform_matrix = no_translate_mtx.SetTranslateOnly(translate)
delta_axis = no_translate_mtx * delta_axis
elif model.op_settings_listener.rotation_mode == c.TRANSFORM_MODE_GLOBAL or screen_space:
begin_full_xform = self._begin_scale_mtx * self._begin_xform
translate = begin_full_xform.ExtractTranslation()
no_translate_mtx = Gf.Matrix4d(begin_full_xform)
no_translate_mtx.SetTranslateOnly(Gf.Vec3d(0))
no_translate_mtx = no_translate_mtx * rot_matrix
new_transform_matrix = no_translate_mtx.SetTranslateOnly(translate)
delta_axis = no_translate_mtx * delta_axis
else:
self._begin_xform = Gf.Matrix4d(*model.get_as_floats(model.get_item("no_scale_transform_manipulator")))
new_transform_matrix = self._begin_scale_mtx * rot_matrix * self._begin_xform
delta_axis.Normalize()
delta_rotate = GfRotation(delta_axis[:3], angle_delta)
quat = delta_rotate #.GetQuaternion()
real = quat.GetReal()
imaginary = quat.GetImaginary()
rd = [imaginary[0], imaginary[1], imaginary[2], real]
model.set_floats(model.get_item("rotate_delta"), rd)
if model.custom_manipulator_enabled:
self._publish_delta(Operation.ROTATE, rd)
model.set_floats(model.get_item("rotate"), flatten(new_transform_matrix))
class ViewportScaleChangedGesture(ScaleChangedGesture, ViewportTransformChangedGestureBase):
def __init__(self, **kwargs):
ViewportTransformChangedGestureBase.__init__(self, **kwargs)
ScaleChangedGesture.__init__(self)
def on_began(self):
ViewportTransformChangedGestureBase.on_began(self, ScaleDragGesturePayload)
model = self.sender.model
if model:
model.set_floats(model.get_item("scale_delta"), [0, 0, 0])
def on_ended(self):
ViewportTransformChangedGestureBase.on_ended(self, ScaleDragGesturePayload)
def on_canceled(self):
ViewportTransformChangedGestureBase.on_canceled(self, ScaleDragGesturePayload)
@carb.profiler.profile
def on_changed(self):
ViewportTransformChangedGestureBase.on_changed(self, ScaleDragGesturePayload)
if not self.gesture_payload or not self.sender or not isinstance(self.gesture_payload, ScaleDragGesturePayload):
return
model = self.sender.model
if not model:
return
axis = self.gesture_payload.axis
scale = self.gesture_payload.scale
axis = Gf.Vec3d(*axis[:3])
scale_delta = scale * axis
scale_vec = Gf.Vec3d()
for i in range(3):
scale_vec[i] = scale_delta[i] if scale_delta[i] else 1
scale_matrix = Gf.Matrix4d(1.0)
scale_matrix.SetScale(scale_vec)
scale_matrix *= self._begin_scale_mtx
new_transform_matrix = scale_matrix * self._begin_xform
s = Gf.Vec3d(*model.get_as_floats(model.get_item("scale_manipulator")))
sd = [s_n / s_o for s_n, s_o in zip([scale_matrix[0][0], scale_matrix[1][1], scale_matrix[2][2]], s)]
model.set_floats(model.get_item("scale_delta"), sd)
if model.custom_manipulator_enabled:
self._publish_delta(Operation.SCALE, sd)
model.set_floats(model.get_item("scale"), flatten(new_transform_matrix))
| 17,358 | Python | 37.747768 | 120 | 0.649038 |
omniverse-code/kit/exts/omni.kit.viewport.manipulator.transform/omni/kit/viewport/manipulator/transform/tests/test_manipulator_transform.py | ## Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
##
## NVIDIA CORPORATION and its licensors retain all intellectual property
## and proprietary rights in and to this software, related documentation
## and any modifications thereto. Any use, reproduction, disclosure or
## distribution of this software and related documentation without an express
## license agreement from NVIDIA CORPORATION is strictly prohibited.
##
from omni.ui.tests.test_base import OmniUiTest
class TestViewportTransform(OmniUiTest):
# Before running each test
async def setUp(self):
pass
# After running each test
async def tearDown(self):
pass
| 670 | Python | 34.315788 | 77 | 0.756716 |
omniverse-code/kit/exts/omni.kit.window.content_browser_registry/omni/kit/window/content_browser_registry/extension.py | # Copyright (c) 2018-2020, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#
import omni.ext
import omni.kit.app
from typing import Callable
from collections import OrderedDict
from omni.kit.window.filepicker import SearchDelegate
g_singleton = None
# Any class derived from `omni.ext.IExt` in top level module (defined in `python.modules` of `extension.toml`) will be
# instantiated when extension gets enabled and `on_startup(ext_id)` will be called. Later when extension gets disabled
# on_shutdown() is called.
class ContentBrowserRegistryExtension(omni.ext.IExt):
"""
This registry extension keeps track of the functioanl customizations that are applied to the Content Browser -
so that they can be re-applied should the browser be re-started.
"""
def __init__(self):
super().__init__()
self._custom_menus = OrderedDict()
self._selection_handlers = set()
self._search_delegate = None
def on_startup(self, ext_id):
# Save away this instance as singleton
global g_singleton
g_singleton = self
def on_shutdown(self):
self._custom_menus.clear()
self._selection_handlers.clear()
self._search_delegate = None
global g_singleton
g_singleton = None
def register_custom_menu(self, context: str, name: str, glyph: str, click_fn: Callable, show_fn: Callable, index: int = -1):
id = f"{context}::{name}"
self._custom_menus[id] = {
'name': name,
'glyph': glyph,
'click_fn': click_fn,
'show_fn': show_fn,
'index': index,
}
def deregister_custom_menu(self, context: str, name: str):
id = f"{context}::{name}"
if id in self._custom_menus:
del self._custom_menus[id]
def register_selection_handler(self, handler: Callable):
self._selection_handlers.add(handler)
def deregister_selection_handler(self, handler: Callable):
if handler in self._selection_handlers:
self._selection_handlers.remove(handler)
def register_search_delegate(self, search_delegate: SearchDelegate):
self._search_delegate = search_delegate
def deregister_search_delegate(self, search_delegate: SearchDelegate):
if self._search_delegate == search_delegate:
self._search_delegate = None
def get_instance():
return g_singleton
| 2,775 | Python | 34.13924 | 128 | 0.675676 |
omniverse-code/kit/exts/omni.kit.window.content_browser_registry/omni/kit/window/content_browser_registry/__init__.py | # Copyright (c) 2021-2022, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#
from typing import Callable, Union, Set
from collections import OrderedDict
from omni.kit.window.filepicker import SearchDelegate
from .extension import ContentBrowserRegistryExtension, get_instance
def custom_menus() -> OrderedDict:
registry = get_instance()
if registry:
return registry._custom_menus
return OrderedDict()
def selection_handlers() -> Set:
registry = get_instance()
if registry:
return registry._selection_handlers
return set()
def search_delegate() -> SearchDelegate:
registry = get_instance()
if registry:
return registry._search_delegate
return None
def register_context_menu(name: str, glyph: str, click_fn: Callable, show_fn: Callable, index: int = -1):
registry = get_instance()
if registry:
registry.register_custom_menu("context", name, glyph, click_fn, show_fn, index=index)
def deregister_context_menu(name: str):
registry = get_instance()
if registry:
registry.deregister_custom_menu("context", name)
def register_listview_menu(name: str, glyph: str, click_fn: Callable, show_fn: Callable, index: int = -1):
registry = get_instance()
if registry:
registry.register_custom_menu("listview", name, glyph, click_fn, show_fn, index=index)
def deregister_listview_menu(name: str):
registry = get_instance()
if registry:
registry.deregister_custom_menu("listview", name)
def register_import_menu(name: str, glyph: str, click_fn: Callable, show_fn: Callable):
registry = get_instance()
if registry:
registry.register_custom_menu("import", name, glyph, click_fn, show_fn)
def deregister_import_menu(name: str):
registry = get_instance()
if registry:
registry.deregister_custom_menu("import", name)
def register_file_open_handler(name: str, open_fn: Callable, file_type: Union[int, Callable]):
registry = get_instance()
if registry:
registry.register_custom_menu("file_open", name, None, open_fn, file_type)
def deregister_file_open_handler(name: str):
registry = get_instance()
if registry:
registry.deregister_custom_menu("file_open", name)
def register_selection_handler(handler: Callable):
registry = get_instance()
if registry:
registry.register_selection_handler(handler)
def deregister_selection_handler(handler: Callable):
registry = get_instance()
if registry:
registry.deregister_selection_handler(handler)
def register_search_delegate(search_delegate: SearchDelegate):
registry = get_instance()
if registry:
registry.register_search_delegate(search_delegate)
def deregister_search_delegate(search_delegate: SearchDelegate):
registry = get_instance()
if registry:
registry.deregister_search_delegate(search_delegate)
| 3,246 | Python | 34.293478 | 106 | 0.718731 |
omniverse-code/kit/exts/omni.kit.window.content_browser_registry/omni/kit/window/content_browser_registry/tests/test_registry.py | ## Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved.
##
## NVIDIA CORPORATION and its licensors retain all intellectual property
## and proprietary rights in and to this software, related documentation
## and any modifications thereto. Any use, reproduction, disclosure or
## distribution of this software and related documentation without an express
## license agreement from NVIDIA CORPORATION is strictly prohibited.
##
import omni.kit.test
import inspect
import omni.kit.window.content_browser_registry as registry
from unittest.mock import Mock
from omni.kit.test.async_unittest import AsyncTestCase
class TestRegistry(AsyncTestCase):
"""Testing Content Browser Registry"""
async def setUp(self):
pass
async def tearDown(self):
pass
async def test_custom_menus(self):
"""Test registering and de-registering custom menus"""
test_menus = [
{
"register_fn": registry.register_context_menu,
"deregister_fn": registry.deregister_context_menu,
"context": "context",
"name": "my context menu",
"glyph": "my glyph",
"click_fn": Mock(),
"show_fn": Mock(),
},
{
"register_fn": registry.register_listview_menu,
"deregister_fn": registry.deregister_listview_menu,
"context": "listview",
"name": "my listview menu",
"glyph": "my glyph",
"click_fn": Mock(),
"show_fn": Mock(),
},
{
"register_fn": registry.register_import_menu,
"deregister_fn": registry.deregister_import_menu,
"context": "import",
"name": "my import menu",
"glyph": None,
"click_fn": Mock(),
"show_fn": Mock(),
},
{
"register_fn": registry.register_file_open_handler,
"deregister_fn": registry.deregister_file_open_handler,
"context": "file_open",
"name": "my file_open handler",
"glyph": None,
"click_fn": Mock(),
"show_fn": Mock(),
}
]
# Register menus
for test_menu in test_menus:
register_fn = test_menu["register_fn"]
if 'glyph' in inspect.getfullargspec(register_fn).args:
register_fn(test_menu["name"], test_menu["glyph"], test_menu["click_fn"], test_menu["show_fn"])
else:
register_fn(test_menu["name"], test_menu["click_fn"], test_menu["show_fn"])
# Confirm menus stored to registry
for test_menu in test_menus:
self.assertTrue(f'{test_menu["context"]}::{test_menu["name"]}' in registry.custom_menus())
# De-register all menus
for test_menu in test_menus:
test_menu["deregister_fn"](test_menu["name"])
# Confirm all menus removed from registry
self.assertEqual(len(registry.custom_menus()), 0)
async def test_selection_handlers(self):
"""Test registering selection handlers"""
test_handler_1 = Mock()
test_handler_2 = Mock()
test_handlers = [test_handler_1, test_handler_2, test_handler_1]
self.assertEqual(len(registry.selection_handlers()), 0)
for test_handler in test_handlers:
registry.register_selection_handler(test_handler)
# Confirm each unique handler is stored only once in registry
self.assertEqual(len(registry.selection_handlers()), 2)
async def test_search_delegate(self):
"""Test registering search delegate"""
test_search_delegate = Mock()
self.assertEqual(registry.search_delegate(), None)
registry.register_search_delegate(test_search_delegate)
# Confirm search delegate stored in registry
self.assertEqual(registry.search_delegate(), test_search_delegate)
| 4,061 | Python | 38.057692 | 111 | 0.581138 |
omniverse-code/kit/exts/omni.kit.window.about/omni/kit/window/about/about.py | import carb
import carb.settings
import omni.client
import omni.kit.app
import omni.kit.ui
import omni.ext
import omni.kit.menu.utils
from omni.kit.menu.utils import MenuItemDescription
from pathlib import Path
from omni import ui
from .about_actions import register_actions, deregister_actions
from .about_window import AboutWindow
WINDOW_NAME = "About"
MENU_NAME = "Help"
_extension_instance = None
class AboutExtension(omni.ext.IExt):
def on_startup(self, ext_id):
self._ext_name = omni.ext.get_extension_name(ext_id)
self._window = AboutWindow()
self._window.set_visibility_changed_fn(self._on_visibility_changed)
self._menu_entry = MenuItemDescription(
name=WINDOW_NAME,
ticked_fn=self._is_visible,
onclick_action=(self._ext_name, "toggle_window"),
)
omni.kit.menu.utils.add_menu_items([self._menu_entry], name=MENU_NAME)
ui.Workspace.set_show_window_fn(
"About",
lambda value: self._toggle_window(),
)
manager = omni.kit.app.get_app().get_extension_manager()
extension_path = manager.get_extension_path(ext_id)
global _extension_instance
_extension_instance = self
register_actions(self._ext_name, lambda: _extension_instance)
def on_shutdown(self):
global _extension_instance
_extension_instance = None
self._window.destroy()
self._window = None
omni.kit.menu.utils.remove_menu_items([self._menu_entry], name=MENU_NAME)
self._menu_entry = None
deregister_actions(self._ext_name)
def _is_visible(self) -> bool:
return False if self._window is None else self._window.visible
def _on_visibility_changed(self, visible):
self._menu_entry.ticked = visible
omni.kit.menu.utils.refresh_menu_items(MENU_NAME)
def toggle_window(self):
self._window.visible = not self._window.visible
def show(self, visible: bool):
self._window.visible = visible
def menu_show_about(self, plugins):
version_infos = [
f"Omniverse Kit {self.kit_version}",
f"App Name: {self.app_name}",
f"App Version: {self.app_version}",
f"Client Library Version: {self.client_library_version}",
f"USD Resolver Version: {self.usd_resolver_version}",
f"USD Version: {self.usd_version}",
f"MDL SDK Version: {self.mdlsdk_version}",
]
@staticmethod
def _resize_window(window: ui.Window, scrolling_frame: ui.ScrollingFrame):
scrolling_frame.width = ui.Pixel(window.width - 10)
scrolling_frame.height = ui.Pixel(window.height - 305)
def get_instance():
return _extension_instance
| 2,772 | Python | 29.811111 | 81 | 0.644661 |
omniverse-code/kit/exts/omni.kit.window.about/omni/kit/window/about/style.py | from pathlib import Path
from omni import ui
from omni.ui import color as cl
CURRENT_PATH = Path(__file__).parent
ICON_PATH = CURRENT_PATH.parent.parent.parent.parent.joinpath("data")
ABOUT_STYLE = {
"Window": {"background_color": cl("#1F2123")},
"Line": {"color": 0xFF353332, "border_width": 1.5},
"ScrollingFrame": {"background_color": cl.transparent, "margin_width": 1, "margin_height": 2},
"About.Background": {"image_url": f"{ICON_PATH}/about_backgroud.png"},
"About.Background.Fill": {"background_color": cl("#131415")},
"About.Logo": {"image_url": f"{ICON_PATH}/about_logo.png", "padding": 0, "margin": 0},
"Logo.Frame": {"background_color": cl("#202424"), "padding": 0, "margin": 0},
"Logo.Separator": {"color": cl("#7BB01E"), "border_width": 1.5},
"Text.App": {"font_size": 18, "margin_width": 10, "margin_height": 2},
"Text.Plugin": {"font_size": 14, "margin_width": 10, "margin_height": 2},
"Text.Version": {"font_size": 18, "margin_width": 10, "margin_height": 2},
"Text.Title": {"font_size": 16, "margin_width": 10},
} | 1,083 | Python | 46.130433 | 98 | 0.626039 |
omniverse-code/kit/exts/omni.kit.window.about/omni/kit/window/about/about_window.py | import omni.ui as ui
import omni.kit.clipboard
from .about_widget import AboutWidget
from .style import ABOUT_STYLE
class AboutWindow(ui.Window):
def __init__(self):
super().__init__(
"About",
width=800,
height=540,
flags=ui.WINDOW_FLAGS_NO_SCROLLBAR | ui.WINDOW_FLAGS_NO_DOCKING,
visible=False
)
self.frame.set_build_fn(self._build_ui)
self.frame.set_style(ABOUT_STYLE)
def destroy(self):
self.visible = False
super().destroy()
def _build_ui(self):
with self.frame:
with ui.ZStack():
with ui.VStack():
self._widget = AboutWidget()
ui.Line(height=0)
ui.Spacer(height=4)
with ui.HStack(height=26):
ui.Spacer()
ui.Button("Close", width=80, clicked_fn=self._hide, style={"padding": 0, "margin": 0})
ui.Button(
"###copy_to_clipboard",
style={"background_color": 0x00000000},
mouse_pressed_fn=lambda x, y, b, a: self.__copy_to_clipboard(b),
identifier="copy_to_clipboard",
)
def _hide(self):
self.visible = False
def __copy_to_clipboard(self, button):
if button != 1:
return
omni.kit.clipboard.copy("\n".join(self._widget.versions)) | 1,474 | Python | 30.382978 | 110 | 0.504071 |
omniverse-code/kit/exts/omni.kit.window.about/omni/kit/window/about/__init__.py | from .about import *
from .about_widget import AboutWidget
| 59 | Python | 18.999994 | 37 | 0.79661 |
omniverse-code/kit/exts/omni.kit.window.about/omni/kit/window/about/about_widget.py | from typing import List
import carb
import carb.settings
import omni.kit.app
import omni.ui as ui
from .style import ABOUT_STYLE
class AboutWidget:
def __init__(self):
app = omni.kit.app.get_app()
self._app_info = f"{app.get_app_name()} {app.get_app_version()}"
self._versions = self.__get_versions()
plugins = [p for p in carb.get_framework().get_plugins() if p.impl.name]
self._plugins = sorted(plugins, key=lambda x: x.impl.name)
custom_image = carb.settings.get_settings().get("/app/window/imagePath")
if custom_image:
ABOUT_STYLE['About.Logo']['image_url'] = carb.tokens.get_tokens_interface().resolve(custom_image)
self._frame = ui.Frame(build_fn=self._build_ui, style=ABOUT_STYLE)
@property
def app_info(self) -> List[str]:
return self._app_info
@app_info.setter
def app_info(self, value: str) -> None:
self._app_info = value
with self._frame:
self._frame.call_build_fn()
@property
def versions(self) -> List[str]:
return [self._app_info] + self._versions
@versions.setter
def versions(self, values: List[str]) -> None:
self._versions = values
with self._frame:
self._frame.call_build_fn()
@property
def plugins(self) -> list:
return self._plugins
@plugins.setter
def plugins(self, values: list) -> None:
self._plugins = values
with self._frame:
self._frame.call_build_fn()
def _build_ui(self):
with ui.VStack(spacing=5):
with ui.ZStack(height=0):
with ui.ZStack():
ui.Rectangle(style_type_name_override="About.Background.Fill")
ui.Image(
style_type_name_override="About.Background",
alignment=ui.Alignment.RIGHT_TOP,
)
with ui.VStack():
ui.Spacer(height=10)
self.__build_app_info()
ui.Spacer(height=10)
for version_info in self._versions:
ui.Label(version_info, height=0, style_type_name_override="Text.Version")
ui.Spacer(height=10)
ui.Spacer(height=0)
ui.Label("Loaded plugins", height=0, style_type_name_override="Text.Title")
ui.Line(height=0)
with ui.ScrollingFrame(
horizontal_scrollbar_policy=ui.ScrollBarPolicy.SCROLLBAR_ALWAYS_OFF,
vertical_scrollbar_policy=ui.ScrollBarPolicy.SCROLLBAR_ALWAYS_ON,
):
with ui.VStack(height=0, spacing=1):
for p in self._plugins:
ui.Label(f"{p.impl.name} {p.interfaces}", tooltip=p.libPath, style_type_name_override="Text.Plugin")
def __build_app_info(self):
with ui.HStack(height=0):
ui.Spacer(width=10)
with ui.ZStack(width=0, height=0):
ui.Rectangle(style_type_name_override="Logo.Frame")
with ui.HStack(height=0):
with ui.VStack():
ui.Spacer(height=5)
ui.Image(width=80, height=80, alignment=ui.Alignment.CENTER, style_type_name_override="About.Logo")
ui.Spacer(height=5)
with ui.VStack(width=0):
ui.Spacer(height=10)
ui.Line(alignment=ui.Alignment.LEFT, style_type_name_override="Logo.Separator")
ui.Spacer(height=18)
with ui.VStack(width=0, height=80):
ui.Spacer()
ui.Label("OMNIVERSE", style_type_name_override="Text.App")
ui.Label(self._app_info, style_type_name_override="Text.App")
ui.Spacer()
ui.Spacer()
def __get_versions(self) -> List[str]:
settings = carb.settings.get_settings()
is_running_test = settings.get("/testconfig/isTest")
# omni_usd_resolver isn't loaded until Ar.GetResolver is called.
# In the ext test, nothing does that, so we need to do it
# since the library isn't located in a PATH search entry.
# Unforunately the ext is loaded before the test module runs,
# so we can't do it there.
try:
if is_running_test:
from pxr import Ar
Ar.GetResolver()
import omni.usd_resolver
usd_resolver_version = omni.usd_resolver.get_version()
except ImportError:
usd_resolver_version = None
try:
import omni.usd_libs
usd_version = omni.usd_libs.get_version()
except ImportError:
usd_version = None
try:
# OM-61509: Add MDL SDK and USD version in about window
import omni.mdl.neuraylib
from omni.mdl import pymdlsdk
# get mdl sdk version
neuraylib = omni.mdl.neuraylib.get_neuraylib()
ineuray = neuraylib.getNeurayAPI()
neuray = pymdlsdk.attach_ineuray(ineuray)
# strip off the date and platform info and only keep the version and build info
version = neuray.get_version().split(",")[:2]
mdlsdk_version = ",".join(version)
except ImportError:
mdlsdk_version = None
app = omni.kit.app.get_app()
version_infos = [
f"Omniverse Kit {app.get_kit_version()}",
f"Client Library Version: {omni.client.get_version()}",
f"USD Resolver Version: {usd_resolver_version}",
f"USD Version: {usd_version}",
f"MDL SDK Version: {mdlsdk_version}",
]
return version_infos
| 5,850 | Python | 36.993506 | 124 | 0.549915 |
omniverse-code/kit/exts/omni.kit.window.about/omni/kit/window/about/about_actions.py | import carb
import omni.kit.actions.core
def register_actions(extension_id, get_self_fn):
action_registry = omni.kit.actions.core.get_action_registry()
actions_tag = "About Actions"
omni.kit.actions.core.get_action_registry().register_action(
extension_id,
"toggle_window",
get_self_fn().toggle_window,
display_name="Help->Toggle About Window",
description="Toggle About",
tag=actions_tag,
)
omni.kit.actions.core.get_action_registry().register_action(
extension_id,
"show_window",
lambda v=True: get_self_fn().show(v),
display_name="Help->Show About Window",
description="Show About",
tag=actions_tag,
)
omni.kit.actions.core.get_action_registry().register_action(
extension_id,
"hide_window",
lambda v=False: get_self_fn().show(v),
display_name="Help->Hide About Window",
description="Hide About",
tag=actions_tag,
)
def deregister_actions(extension_id):
action_registry = omni.kit.actions.core.get_action_registry()
action_registry.deregister_all_actions_for_extension(extension_id)
| 1,176 | Python | 29.179486 | 70 | 0.643707 |
omniverse-code/kit/exts/omni.kit.window.about/omni/kit/window/about/tests/test_window_about.py | ## Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
##
## NVIDIA CORPORATION and its licensors retain all intellectual property
## and proprietary rights in and to this software, related documentation
## and any modifications thereto. Any use, reproduction, disclosure or
## distribution of this software and related documentation without an express
## license agreement from NVIDIA CORPORATION is strictly prohibited.
##
from pathlib import Path
import omni.kit.app
import omni.kit.test
import omni.ui as ui
from omni.ui.tests.test_base import OmniUiTest
CURRENT_PATH = Path(__file__).parent
TEST_DATA_PATH = CURRENT_PATH.parent.parent.parent.parent.parent.joinpath("data").joinpath("tests")
class TestAboutWindow(OmniUiTest):
# Before running each test
async def setUp(self):
await super().setUp()
self._golden_img_dir = TEST_DATA_PATH.absolute().joinpath("golden_img").absolute()
# After running each test
async def tearDown(self):
await super().tearDown()
async def test_about_ui(self):
class FakePluginImpl():
def __init__(self, name):
self.name = name
class FakePlugin():
def __init__(self, name):
self.libPath = "Lib Path " + name
self.impl = FakePluginImpl("Impl " + name)
self.interfaces = "Interface " + name
about = omni.kit.window.about.get_instance()
about.show(True)
await omni.kit.app.get_app().next_update_async()
await omni.kit.app.get_app().next_update_async()
about._window._widget.app_info = "#App Name# #App Version#"
about._window._widget.versions = [
"Omniverse Kit #Version#",
"Client Library Version: #Client Library Version#",
"USD Resolver Version: #USD Resolver Version#",
"USD Version: #USD Version#",
"MDL SDK Version: #MDL SDK Version#",
]
about._window._widget.plugins = [FakePlugin("Test 1"), FakePlugin("Test 2"), FakePlugin("Test 3"), FakePlugin("Test 4")]
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
await self.docked_test_window(
window=about._window,
width=800,
height=510)
await self.finalize_test(golden_img_dir=self._golden_img_dir, golden_img_name="test_about_ui.png")
| 2,403 | Python | 37.774193 | 128 | 0.63712 |
omniverse-code/kit/exts/omni.kit.window.about/omni/kit/window/about/tests/__init__.py | from .test_window_about import *
from .test_clipboard import *
| 63 | Python | 20.333327 | 32 | 0.761905 |
omniverse-code/kit/exts/omni.kit.window.about/omni/kit/window/about/tests/test_clipboard.py | ## Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
##
## NVIDIA CORPORATION and its licensors retain all intellectual property
## and proprietary rights in and to this software, related documentation
## and any modifications thereto. Any use, reproduction, disclosure or
## distribution of this software and related documentation without an express
## license agreement from NVIDIA CORPORATION is strictly prohibited.
##
import pathlib
import sys
import unittest
import omni.kit.app
import omni.kit.test
import omni.ui as ui
from omni.kit import ui_test
from omni.ui.tests.test_base import OmniUiTest
class TestAboutWindowClipboard(OmniUiTest):
# Before running each test
async def setUp(self):
await super().setUp()
# After running each test
async def tearDown(self):
await super().tearDown()
# @unittest.skipIf(sys.platform.startswith("linux"), "Pyperclip fails on some TeamCity agents")
async def test_about_clipboard(self):
class FakePluginImpl():
def __init__(self, name):
self.name = name
class FakePlugin():
def __init__(self, name):
self.libPath = "Lib Path " + name
self.impl = FakePluginImpl("Impl " + name)
self.interfaces = "Interface " + name
omni.kit.clipboard.copy("")
about = omni.kit.window.about.get_instance()
about.kit_version = "#Version#"
about.nucleus_version = "#Nucleus Version#"
about.client_library_version = "#Client Library Version#"
about.app_name = "#App Name#"
about.app_version = "#App Version#"
about.usd_resolver_version = "#USD Resolver Version#"
about.usd_version = "#USD Version#"
about.mdlsdk_version = "#MDL SDK Version#"
about_window = about.menu_show_about([FakePlugin("Test 1"), FakePlugin("Test 2"), FakePlugin("Test 3"), FakePlugin("Test 4")])
await ui_test.find("About//Frame/**/Button[*].identifier=='copy_to_clipboard'").click(right_click=True)
await ui_test.human_delay()
clipboard = omni.kit.clipboard.paste()
self.assertEqual(clipboard, "#App Name# #App Version#\nOmniverse Kit #Version#\nClient Library Version: #Client Library Version#\nUSD Resolver Version: #USD Resolver Version#\nUSD Version: #USD Version#\nMDL SDK Version: #MDL SDK Version#")
| 2,390 | Python | 39.525423 | 248 | 0.669038 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnArraySetIndexDatabase.py | """Support for simplified access to data on nodes of type omni.graph.nodes.ArraySetIndex
Sets an element of an array. If the given index is negative it will be an offset from the end of the array.
"""
from typing import Any
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnArraySetIndexDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.nodes.ArraySetIndex
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.array
inputs.index
inputs.resizeToFit
inputs.value
Outputs:
outputs.array
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:array', 'bool[],colord[3][],colord[4][],colorf[3][],colorf[4][],colorh[3][],colorh[4][],double[2][],double[3][],double[4][],double[],float[2][],float[3][],float[4][],float[],frame[4][],half[2][],half[3][],half[4][],half[],int64[],int[2][],int[3][],int[4][],int[],matrixd[3][],matrixd[4][],normald[3][],normalf[3][],normalh[3][],pointd[3][],pointf[3][],pointh[3][],quatd[4][],quatf[4][],quath[4][],texcoordd[2][],texcoordd[3][],texcoordf[2][],texcoordf[3][],texcoordh[2][],texcoordh[3][],timecode[],token[],transform[4][],uchar[],uint64[],uint[],vectord[3][],vectorf[3][],vectorh[3][]', 1, 'Array', 'The array to be modified', {}, True, None, False, ''),
('inputs:index', 'int', 0, 'Index', 'The index into the array, a negative value indexes from the end of the array', {}, True, 0, False, ''),
('inputs:resizeToFit', 'bool', 0, None, 'When true, and the given positive index is larger than the highest index in the array\nresize the output array to length 1 + index, and fill the new spaces with zeros', {}, True, False, False, ''),
('inputs:value', 'bool,colord[3],colord[4],colorf[3],colorf[4],colorh[3],colorh[4],double,double[2],double[3],double[4],float,float[2],float[3],float[4],frame[4],half,half[2],half[3],half[4],int,int64,int[2],int[3],int[4],matrixd[3],matrixd[4],normald[3],normalf[3],normalh[3],pointd[3],pointf[3],pointh[3],quatd[4],quatf[4],quath[4],texcoordd[2],texcoordd[3],texcoordf[2],texcoordf[3],texcoordh[2],texcoordh[3],timecode,token,transform[4],uchar,uint,uint64,vectord[3],vectorf[3],vectorh[3]', 1, None, 'The value to set at the given index', {}, True, None, False, ''),
('outputs:array', 'bool[],colord[3][],colord[4][],colorf[3][],colorf[4][],colorh[3][],colorh[4][],double[2][],double[3][],double[4][],double[],float[2][],float[3][],float[4][],float[],frame[4][],half[2][],half[3][],half[4][],half[],int64[],int[2][],int[3][],int[4][],int[],matrixd[3][],matrixd[4][],normald[3][],normalf[3][],normalh[3][],pointd[3][],pointf[3][],pointh[3][],quatd[4][],quatf[4][],quath[4][],texcoordd[2][],texcoordd[3][],texcoordf[2][],texcoordf[3][],texcoordh[2][],texcoordh[3][],timecode[],token[],transform[4][],uchar[],uint64[],uint[],vectord[3][],vectorf[3][],vectorh[3][]', 1, 'Array', 'The modified array', {}, True, None, False, ''),
])
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = []
self._batchedReadValues = []
@property
def array(self) -> og.RuntimeAttribute:
"""Get the runtime wrapper class for the attribute inputs.array"""
return og.RuntimeAttribute(self._attributes.array.get_attribute_data(), self._context, True)
@array.setter
def array(self, value_to_set: Any):
"""Assign another attribute's value to outputs.array"""
if isinstance(value_to_set, og.RuntimeAttribute):
self.array.value = value_to_set.value
else:
self.array.value = value_to_set
@property
def index(self):
data_view = og.AttributeValueHelper(self._attributes.index)
return data_view.get()
@index.setter
def index(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.index)
data_view = og.AttributeValueHelper(self._attributes.index)
data_view.set(value)
@property
def resizeToFit(self):
data_view = og.AttributeValueHelper(self._attributes.resizeToFit)
return data_view.get()
@resizeToFit.setter
def resizeToFit(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.resizeToFit)
data_view = og.AttributeValueHelper(self._attributes.resizeToFit)
data_view.set(value)
@property
def value(self) -> og.RuntimeAttribute:
"""Get the runtime wrapper class for the attribute inputs.value"""
return og.RuntimeAttribute(self._attributes.value.get_attribute_data(), self._context, True)
@value.setter
def value(self, value_to_set: Any):
"""Assign another attribute's value to outputs.value"""
if isinstance(value_to_set, og.RuntimeAttribute):
self.value.value = value_to_set.value
else:
self.value.value = value_to_set
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedWriteValues = { }
@property
def array(self) -> og.RuntimeAttribute:
"""Get the runtime wrapper class for the attribute outputs.array"""
return og.RuntimeAttribute(self._attributes.array.get_attribute_data(), self._context, False)
@array.setter
def array(self, value_to_set: Any):
"""Assign another attribute's value to outputs.array"""
if isinstance(value_to_set, og.RuntimeAttribute):
self.array.value = value_to_set.value
else:
self.array.value = value_to_set
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnArraySetIndexDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnArraySetIndexDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnArraySetIndexDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
| 9,089 | Python | 56.898089 | 670 | 0.645506 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnRotateToOrientationDatabase.py | """Support for simplified access to data on nodes of type omni.graph.nodes.RotateToOrientation
Perform a smooth rotation maneuver, rotating a prim to a desired orientation given a speed and easing factor
"""
import numpy
import usdrt
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnRotateToOrientationDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.nodes.RotateToOrientation
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.execIn
inputs.exponent
inputs.prim
inputs.primPath
inputs.speed
inputs.stop
inputs.target
inputs.usePath
Outputs:
outputs.finished
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:execIn', 'execution', 0, 'Execute In', 'The input execution', {}, True, None, False, ''),
('inputs:exponent', 'float', 0, None, 'The blend exponent, which is the degree of the ease curve\n (1 = linear, 2 = quadratic, 3 = cubic, etc). ', {ogn.MetadataKeys.DEFAULT: '2.0'}, True, 2.0, False, ''),
('inputs:prim', 'target', 0, None, 'The prim to be rotated', {}, False, [], False, ''),
('inputs:primPath', 'path', 0, None, "The source prim to be transformed, used when 'usePath' is true", {}, False, None, True, 'Use prim input with a GetPrimsAtPath node instead'),
('inputs:speed', 'double', 0, None, 'The peak speed of approach (Units / Second)', {ogn.MetadataKeys.DEFAULT: '1.0'}, True, 1.0, False, ''),
('inputs:stop', 'execution', 0, 'Stop', 'Stops the maneuver', {}, True, None, False, ''),
('inputs:target', 'vector3d', 0, 'Target Orientation', 'The desired orientation as euler angles (XYZ) in local space', {}, True, [0.0, 0.0, 0.0], False, ''),
('inputs:usePath', 'bool', 0, None, "When true, the 'primPath' attribute is used, otherwise it will read the connection at the 'prim' attribute", {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, True, 'Use prim input with a GetPrimsAtPath node instead'),
('outputs:finished', 'execution', 0, 'Finished', 'The output execution, sent one the maneuver is completed', {}, True, None, False, ''),
])
@classmethod
def _populate_role_data(cls):
"""Populate a role structure with the non-default roles on this node type"""
role_data = super()._populate_role_data()
role_data.inputs.execIn = og.AttributeRole.EXECUTION
role_data.inputs.prim = og.AttributeRole.TARGET
role_data.inputs.primPath = og.AttributeRole.PATH
role_data.inputs.stop = og.AttributeRole.EXECUTION
role_data.inputs.target = og.AttributeRole.VECTOR
role_data.outputs.finished = og.AttributeRole.EXECUTION
return role_data
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = []
self._batchedReadValues = []
@property
def execIn(self):
data_view = og.AttributeValueHelper(self._attributes.execIn)
return data_view.get()
@execIn.setter
def execIn(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.execIn)
data_view = og.AttributeValueHelper(self._attributes.execIn)
data_view.set(value)
@property
def exponent(self):
data_view = og.AttributeValueHelper(self._attributes.exponent)
return data_view.get()
@exponent.setter
def exponent(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.exponent)
data_view = og.AttributeValueHelper(self._attributes.exponent)
data_view.set(value)
@property
def prim(self):
data_view = og.AttributeValueHelper(self._attributes.prim)
return data_view.get()
@prim.setter
def prim(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.prim)
data_view = og.AttributeValueHelper(self._attributes.prim)
data_view.set(value)
self.prim_size = data_view.get_array_size()
@property
def primPath(self):
data_view = og.AttributeValueHelper(self._attributes.primPath)
return data_view.get()
@primPath.setter
def primPath(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.primPath)
data_view = og.AttributeValueHelper(self._attributes.primPath)
data_view.set(value)
self.primPath_size = data_view.get_array_size()
@property
def speed(self):
data_view = og.AttributeValueHelper(self._attributes.speed)
return data_view.get()
@speed.setter
def speed(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.speed)
data_view = og.AttributeValueHelper(self._attributes.speed)
data_view.set(value)
@property
def stop(self):
data_view = og.AttributeValueHelper(self._attributes.stop)
return data_view.get()
@stop.setter
def stop(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.stop)
data_view = og.AttributeValueHelper(self._attributes.stop)
data_view.set(value)
@property
def target(self):
data_view = og.AttributeValueHelper(self._attributes.target)
return data_view.get()
@target.setter
def target(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.target)
data_view = og.AttributeValueHelper(self._attributes.target)
data_view.set(value)
@property
def usePath(self):
data_view = og.AttributeValueHelper(self._attributes.usePath)
return data_view.get()
@usePath.setter
def usePath(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.usePath)
data_view = og.AttributeValueHelper(self._attributes.usePath)
data_view.set(value)
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedWriteValues = { }
@property
def finished(self):
data_view = og.AttributeValueHelper(self._attributes.finished)
return data_view.get()
@finished.setter
def finished(self, value):
data_view = og.AttributeValueHelper(self._attributes.finished)
data_view.set(value)
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnRotateToOrientationDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnRotateToOrientationDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnRotateToOrientationDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
| 10,132 | Python | 44.439462 | 263 | 0.639755 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnReadPrimsBundleDatabase.py | """Support for simplified access to data on nodes of type omni.graph.nodes.ReadPrimsBundle
Reads primitives and outputs multiple primitive in a bundle.
"""
from typing import Any
import numpy
import usdrt
import carb
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnReadPrimsBundleDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.nodes.ReadPrimsBundle
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.attrNamesToImport
inputs.primPaths
inputs.prims
inputs.usdTimecode
inputs.usePaths
Outputs:
outputs.primsBundle
State:
state.attrNamesToImport
state.primPaths
state.usdTimecode
state.usePaths
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:attrNamesToImport', 'string', 0, 'Attributes To Import', "A list of wildcard patterns used to match the attribute names that are to be imported\n\nSupported syntax of wildcard pattern:\n '*' - match an arbitrary number of any characters\n '?' - match any single character\n '^' - (caret) is used to define a pattern that is to be excluded\n\nExample of wildcard patterns, input: ['points', 'faceVertexCount', 'faceVertexIndices', 'size']\n '*' - match any\n '* ^points' - match any, but exclude 'points'\n '* ^face*' - match any, but exclude 'faceVertexCount' and 'faceVertexIndices'", {ogn.MetadataKeys.DEFAULT: '"*"'}, True, "*", False, ''),
('inputs:primPaths', 'path,token,token[]', 1, 'Prim Paths', "The paths of the prims to be read from when 'usePaths' is true", {}, False, None, False, ''),
('inputs:prims', 'target', 0, None, "The prims to be read from when 'usePaths' is false", {ogn.MetadataKeys.ALLOW_MULTI_INPUTS: '1'}, False, [], False, ''),
('inputs:usdTimecode', 'timecode', 0, 'Time', 'The time at which to evaluate the transform of the USD prim. A value of "NaN" indicates that the default USD time stamp should be used', {ogn.MetadataKeys.DEFAULT: '"NaN"'}, True, float("NaN"), False, ''),
('inputs:usePaths', 'bool', 0, 'Use Paths', "When true, the 'primPaths' attribute is used as the path to the prim being read, otherwise it will read the connection at the 'prim' attribute", {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''),
('outputs:primsBundle', 'bundle', 0, None, 'An output bundle containing multiple prims as children.\nEach child contains data attributes and two additional token attributes named sourcePrimPath and sourcePrimType\nwhich contain the path and the type of the Prim being read', {}, True, None, False, ''),
('state:attrNamesToImport', 'string', 0, None, 'State from previous evaluation', {}, True, None, False, ''),
('state:primPaths', 'uint64[]', 0, None, 'State from previous evaluation', {}, True, None, False, ''),
('state:usdTimecode', 'timecode', 0, None, 'State from previous evaluation', {ogn.MetadataKeys.DEFAULT: '"NaN"'}, True, float("NaN"), False, ''),
('state:usePaths', 'bool', 0, None, 'State from previous evaluation', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''),
])
@classmethod
def _populate_role_data(cls):
"""Populate a role structure with the non-default roles on this node type"""
role_data = super()._populate_role_data()
role_data.inputs.attrNamesToImport = og.AttributeRole.TEXT
role_data.inputs.prims = og.AttributeRole.TARGET
role_data.inputs.usdTimecode = og.AttributeRole.TIMECODE
role_data.outputs.primsBundle = og.AttributeRole.BUNDLE
role_data.state.attrNamesToImport = og.AttributeRole.TEXT
role_data.state.usdTimecode = og.AttributeRole.TIMECODE
return role_data
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = []
self._batchedReadValues = []
@property
def attrNamesToImport(self):
data_view = og.AttributeValueHelper(self._attributes.attrNamesToImport)
return data_view.get()
@attrNamesToImport.setter
def attrNamesToImport(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.attrNamesToImport)
data_view = og.AttributeValueHelper(self._attributes.attrNamesToImport)
data_view.set(value)
self.attrNamesToImport_size = data_view.get_array_size()
@property
def primPaths(self) -> og.RuntimeAttribute:
"""Get the runtime wrapper class for the attribute inputs.primPaths"""
return og.RuntimeAttribute(self._attributes.primPaths.get_attribute_data(), self._context, True)
@primPaths.setter
def primPaths(self, value_to_set: Any):
"""Assign another attribute's value to outputs.primPaths"""
if isinstance(value_to_set, og.RuntimeAttribute):
self.primPaths.value = value_to_set.value
else:
self.primPaths.value = value_to_set
@property
def prims(self):
data_view = og.AttributeValueHelper(self._attributes.prims)
return data_view.get()
@prims.setter
def prims(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.prims)
data_view = og.AttributeValueHelper(self._attributes.prims)
data_view.set(value)
self.prims_size = data_view.get_array_size()
@property
def usdTimecode(self):
data_view = og.AttributeValueHelper(self._attributes.usdTimecode)
return data_view.get()
@usdTimecode.setter
def usdTimecode(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.usdTimecode)
data_view = og.AttributeValueHelper(self._attributes.usdTimecode)
data_view.set(value)
@property
def usePaths(self):
data_view = og.AttributeValueHelper(self._attributes.usePaths)
return data_view.get()
@usePaths.setter
def usePaths(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.usePaths)
data_view = og.AttributeValueHelper(self._attributes.usePaths)
data_view.set(value)
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self.__bundles = og.BundleContainer(context, node, attributes, [], read_only=False, gpu_ptr_kinds={})
self._batchedWriteValues = { }
@property
def primsBundle(self) -> og.BundleContents:
"""Get the bundle wrapper class for the attribute outputs.primsBundle"""
return self.__bundles.primsBundle
@primsBundle.setter
def primsBundle(self, bundle: og.BundleContents):
"""Overwrite the bundle attribute outputs.primsBundle with a new bundle"""
if not isinstance(bundle, og.BundleContents):
carb.log_error("Only bundle attributes can be assigned to another bundle attribute")
self.__bundles.primsBundle.bundle = bundle
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self.attrNamesToImport_size = None
self.primPaths_size = None
@property
def attrNamesToImport(self):
data_view = og.AttributeValueHelper(self._attributes.attrNamesToImport)
self.attrNamesToImport_size = data_view.get_array_size()
return data_view.get()
@attrNamesToImport.setter
def attrNamesToImport(self, value):
data_view = og.AttributeValueHelper(self._attributes.attrNamesToImport)
data_view.set(value)
self.attrNamesToImport_size = data_view.get_array_size()
@property
def primPaths(self):
data_view = og.AttributeValueHelper(self._attributes.primPaths)
self.primPaths_size = data_view.get_array_size()
return data_view.get()
@primPaths.setter
def primPaths(self, value):
data_view = og.AttributeValueHelper(self._attributes.primPaths)
data_view.set(value)
self.primPaths_size = data_view.get_array_size()
@property
def usdTimecode(self):
data_view = og.AttributeValueHelper(self._attributes.usdTimecode)
return data_view.get()
@usdTimecode.setter
def usdTimecode(self, value):
data_view = og.AttributeValueHelper(self._attributes.usdTimecode)
data_view.set(value)
@property
def usePaths(self):
data_view = og.AttributeValueHelper(self._attributes.usePaths)
return data_view.get()
@usePaths.setter
def usePaths(self, value):
data_view = og.AttributeValueHelper(self._attributes.usePaths)
data_view.set(value)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnReadPrimsBundleDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnReadPrimsBundleDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnReadPrimsBundleDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
| 12,275 | Python | 49.727273 | 678 | 0.655886 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnSetMatrix4RotationDatabase.py | """Support for simplified access to data on nodes of type omni.graph.nodes.SetMatrix4Rotation
Sets the rotation of the given matrix4d value which represents a linear transformation. Does not modify the translation (row
3) of the matrix.
"""
from typing import Any
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnSetMatrix4RotationDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.nodes.SetMatrix4Rotation
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.fixedRotationAxis
inputs.matrix
inputs.rotationAngle
Outputs:
outputs.matrix
Predefined Tokens:
tokens.X
tokens.Y
tokens.Z
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:fixedRotationAxis', 'token', 0, None, 'The axis of the given rotation', {ogn.MetadataKeys.ALLOWED_TOKENS: 'X,Y,Z', ogn.MetadataKeys.ALLOWED_TOKENS_RAW: '["X", "Y", "Z"]', ogn.MetadataKeys.DEFAULT: '"Y"'}, True, "Y", False, ''),
('inputs:matrix', 'matrixd[4],matrixd[4][]', 1, None, 'The matrix to be modified', {}, True, None, False, ''),
('inputs:rotationAngle', 'double,double[]', 1, 'Rotation', 'The rotation in degrees that the matrix will apply about the given rotationAxis.', {}, True, None, False, ''),
('outputs:matrix', 'matrixd[4],matrixd[4][]', 1, None, 'The updated matrix', {}, True, None, False, ''),
])
class tokens:
X = "X"
Y = "Y"
Z = "Z"
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = []
self._batchedReadValues = []
@property
def fixedRotationAxis(self):
data_view = og.AttributeValueHelper(self._attributes.fixedRotationAxis)
return data_view.get()
@fixedRotationAxis.setter
def fixedRotationAxis(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.fixedRotationAxis)
data_view = og.AttributeValueHelper(self._attributes.fixedRotationAxis)
data_view.set(value)
@property
def matrix(self) -> og.RuntimeAttribute:
"""Get the runtime wrapper class for the attribute inputs.matrix"""
return og.RuntimeAttribute(self._attributes.matrix.get_attribute_data(), self._context, True)
@matrix.setter
def matrix(self, value_to_set: Any):
"""Assign another attribute's value to outputs.matrix"""
if isinstance(value_to_set, og.RuntimeAttribute):
self.matrix.value = value_to_set.value
else:
self.matrix.value = value_to_set
@property
def rotationAngle(self) -> og.RuntimeAttribute:
"""Get the runtime wrapper class for the attribute inputs.rotationAngle"""
return og.RuntimeAttribute(self._attributes.rotationAngle.get_attribute_data(), self._context, True)
@rotationAngle.setter
def rotationAngle(self, value_to_set: Any):
"""Assign another attribute's value to outputs.rotationAngle"""
if isinstance(value_to_set, og.RuntimeAttribute):
self.rotationAngle.value = value_to_set.value
else:
self.rotationAngle.value = value_to_set
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedWriteValues = { }
@property
def matrix(self) -> og.RuntimeAttribute:
"""Get the runtime wrapper class for the attribute outputs.matrix"""
return og.RuntimeAttribute(self._attributes.matrix.get_attribute_data(), self._context, False)
@matrix.setter
def matrix(self, value_to_set: Any):
"""Assign another attribute's value to outputs.matrix"""
if isinstance(value_to_set, og.RuntimeAttribute):
self.matrix.value = value_to_set.value
else:
self.matrix.value = value_to_set
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnSetMatrix4RotationDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnSetMatrix4RotationDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnSetMatrix4RotationDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
| 7,338 | Python | 46.655844 | 244 | 0.658354 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnPartialSumDatabase.py | """Support for simplified access to data on nodes of type omni.graph.nodes.PartialSum
Compute the partial sums of the input integer array named 'array' and put the result in an output integer array named 'partialSum'.
A partial sum is the sum of all of the elements up to but not including a certain point in an array, so output element 0
is always 0, element 1 is array[0], element 2 is array[0] + array[1], etc.
"""
import numpy
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnPartialSumDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.nodes.PartialSum
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.array
Outputs:
outputs.partialSum
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:array', 'int[]', 0, None, 'List of integers whose partial sum is to be computed', {ogn.MetadataKeys.DEFAULT: '[]'}, True, [], False, ''),
('outputs:partialSum', 'int[]', 0, None, "Array whose nth value equals the nth partial sum of the input 'array'", {ogn.MetadataKeys.DEFAULT: '[]'}, True, [], False, ''),
])
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = []
self._batchedReadValues = []
@property
def array(self):
data_view = og.AttributeValueHelper(self._attributes.array)
return data_view.get()
@array.setter
def array(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.array)
data_view = og.AttributeValueHelper(self._attributes.array)
data_view.set(value)
self.array_size = data_view.get_array_size()
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self.partialSum_size = 0
self._batchedWriteValues = { }
@property
def partialSum(self):
data_view = og.AttributeValueHelper(self._attributes.partialSum)
return data_view.get(reserved_element_count=self.partialSum_size)
@partialSum.setter
def partialSum(self, value):
data_view = og.AttributeValueHelper(self._attributes.partialSum)
data_view.set(value)
self.partialSum_size = data_view.get_array_size()
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnPartialSumDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnPartialSumDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnPartialSumDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
| 5,613 | Python | 47.817391 | 177 | 0.672902 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnReadOmniGraphValueDatabase.py | """Support for simplified access to data on nodes of type omni.graph.nodes.ReadOmniGraphValue
Imports a data value from the Fabric cache that is located at the given path and attribute name. This is for data that is
not already present in OmniGraph as that data can be accessed through a direct connection to the underlying OmniGraph node.
"""
from typing import Any
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnReadOmniGraphValueDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.nodes.ReadOmniGraphValue
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.name
inputs.path
Outputs:
outputs.value
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:name', 'token', 0, None, 'The name of the attribute to be queried', {}, True, "", False, ''),
('inputs:path', 'path', 0, None, 'The path to the Fabric data bucket in which the attribute being queried lives.', {}, True, "", False, ''),
('outputs:value', 'any', 2, None, 'The attribute value', {}, True, None, False, ''),
])
@classmethod
def _populate_role_data(cls):
"""Populate a role structure with the non-default roles on this node type"""
role_data = super()._populate_role_data()
role_data.inputs.path = og.AttributeRole.PATH
return role_data
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = []
self._batchedReadValues = []
@property
def name(self):
data_view = og.AttributeValueHelper(self._attributes.name)
return data_view.get()
@name.setter
def name(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.name)
data_view = og.AttributeValueHelper(self._attributes.name)
data_view.set(value)
@property
def path(self):
data_view = og.AttributeValueHelper(self._attributes.path)
return data_view.get()
@path.setter
def path(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.path)
data_view = og.AttributeValueHelper(self._attributes.path)
data_view.set(value)
self.path_size = data_view.get_array_size()
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedWriteValues = { }
@property
def value(self) -> og.RuntimeAttribute:
"""Get the runtime wrapper class for the attribute outputs.value"""
return og.RuntimeAttribute(self._attributes.value.get_attribute_data(), self._context, False)
@value.setter
def value(self, value_to_set: Any):
"""Assign another attribute's value to outputs.value"""
if isinstance(value_to_set, og.RuntimeAttribute):
self.value.value = value_to_set.value
else:
self.value.value = value_to_set
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnReadOmniGraphValueDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnReadOmniGraphValueDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnReadOmniGraphValueDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
| 6,380 | Python | 45.919117 | 148 | 0.661912 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnToStringDatabase.py | """Support for simplified access to data on nodes of type omni.graph.nodes.ToString
Converts the given input to a string equivalent.
"""
from typing import Any
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnToStringDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.nodes.ToString
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.value
Outputs:
outputs.converted
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:value', 'any', 2, 'value', 'The value to be converted to a string.\n\nNumeric values are converted using C++\'s std::ostringstream << operator. This can result in the values\nbeing converted to exponential form. E.g: 1.234e+06\nArrays of numeric values are converted to Python list syntax. E.g: [1.5, -0.03]\nA uchar value is converted to a single, unquoted character.\nAn array of uchar values is converted to an unquoted string. Avoid zero values (i.e. null chars) in the\narray as the behavior is undefined and may vary over time.\nA single token is converted to its unquoted string equivalent.\nAn array of tokens is converted to Python list syntax with each token enclosed in double quotes. E.g. ["first", "second"]', {}, True, None, False, ''),
('outputs:converted', 'string', 0, 'String', 'Output string', {}, True, None, False, ''),
])
@classmethod
def _populate_role_data(cls):
"""Populate a role structure with the non-default roles on this node type"""
role_data = super()._populate_role_data()
role_data.outputs.converted = og.AttributeRole.TEXT
return role_data
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = []
self._batchedReadValues = []
@property
def value(self) -> og.RuntimeAttribute:
"""Get the runtime wrapper class for the attribute inputs.value"""
return og.RuntimeAttribute(self._attributes.value.get_attribute_data(), self._context, True)
@value.setter
def value(self, value_to_set: Any):
"""Assign another attribute's value to outputs.value"""
if isinstance(value_to_set, og.RuntimeAttribute):
self.value.value = value_to_set.value
else:
self.value.value = value_to_set
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self.converted_size = None
self._batchedWriteValues = { }
@property
def converted(self):
data_view = og.AttributeValueHelper(self._attributes.converted)
return data_view.get(reserved_element_count=self.converted_size)
@converted.setter
def converted(self, value):
data_view = og.AttributeValueHelper(self._attributes.converted)
data_view.set(value)
self.converted_size = data_view.get_array_size()
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnToStringDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnToStringDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnToStringDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
| 6,228 | Python | 50.908333 | 767 | 0.677906 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnReadPrimDatabase.py | """Support for simplified access to data on nodes of type omni.graph.nodes.ReadPrim
DEPRECATED - use ReadPrimAttributes!
"""
import carb
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnReadPrimDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.nodes.ReadPrim
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.attrNamesToImport
inputs.computeBoundingBox
inputs.prim
inputs.usdTimecode
Outputs:
outputs.primBundle
State:
state.attrNamesToImport
state.computeBoundingBox
state.primPath
state.primTypes
state.usdTimecode
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:attrNamesToImport', 'token', 0, 'Attributes To Import', "A list of wildcard patterns used to match the attribute names that are to be imported\n\nSupported syntax of wildcard pattern:\n '*' - match an arbitrary number of any characters\n '?' - match any single character\n '^' - (caret) is used to define a pattern that is to be excluded\n\nExample of wildcard patterns, input: ['points', 'faceVertexCount', 'faceVertexIndices', 'size']\n '*' - match any\n '* ^points' - match any, but exclude 'points'\n '* ^face*' - match any, but exclude 'faceVertexCount' and 'faceVertexIndices'", {ogn.MetadataKeys.DEFAULT: '"*"'}, True, "*", False, ''),
('inputs:computeBoundingBox', 'bool', 0, 'Compute Bounding Box', "For each primitive compute local bounding box and store them as 'bboxMinCorner', 'bboxMaxCorner' and 'bboxTransform' attributes.", {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''),
('inputs:prim', 'bundle', 0, None, "The prims to be read from when 'usePathPattern' is false", {}, False, None, False, ''),
('inputs:usdTimecode', 'timecode', 0, 'Time', 'The time at which to evaluate the transform of the USD prim. A value of "NaN" indicates that the default USD time stamp should be used', {ogn.MetadataKeys.DEFAULT: '"NaN"'}, True, float("NaN"), False, ''),
('outputs:primBundle', 'bundle', 0, None, 'A bundle of the target Prim attributes.\nIn addition to the data attributes, there is a token attribute named sourcePrimPath\nwhich contains the path of the Prim being read', {}, True, None, False, ''),
('state:attrNamesToImport', 'uint64', 0, None, 'State from previous evaluation', {}, True, None, False, ''),
('state:computeBoundingBox', 'bool', 0, None, 'State from previous evaluation', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''),
('state:primPath', 'uint64', 0, None, 'State from previous evaluation', {}, True, None, False, ''),
('state:primTypes', 'uint64', 0, None, 'State from previous evaluation', {}, True, None, False, ''),
('state:usdTimecode', 'timecode', 0, None, 'State from previous evaluation', {ogn.MetadataKeys.DEFAULT: '"NaN"'}, True, float("NaN"), False, ''),
])
@classmethod
def _populate_role_data(cls):
"""Populate a role structure with the non-default roles on this node type"""
role_data = super()._populate_role_data()
role_data.inputs.prim = og.AttributeRole.BUNDLE
role_data.inputs.usdTimecode = og.AttributeRole.TIMECODE
role_data.outputs.primBundle = og.AttributeRole.BUNDLE
role_data.state.usdTimecode = og.AttributeRole.TIMECODE
return role_data
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self.__bundles = og.BundleContainer(context, node, attributes, [], read_only=True, gpu_ptr_kinds={})
self._batchedReadAttributes = []
self._batchedReadValues = []
@property
def attrNamesToImport(self):
data_view = og.AttributeValueHelper(self._attributes.attrNamesToImport)
return data_view.get()
@attrNamesToImport.setter
def attrNamesToImport(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.attrNamesToImport)
data_view = og.AttributeValueHelper(self._attributes.attrNamesToImport)
data_view.set(value)
@property
def computeBoundingBox(self):
data_view = og.AttributeValueHelper(self._attributes.computeBoundingBox)
return data_view.get()
@computeBoundingBox.setter
def computeBoundingBox(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.computeBoundingBox)
data_view = og.AttributeValueHelper(self._attributes.computeBoundingBox)
data_view.set(value)
@property
def prim(self) -> og.BundleContents:
"""Get the bundle wrapper class for the attribute inputs.prim"""
return self.__bundles.prim
@property
def usdTimecode(self):
data_view = og.AttributeValueHelper(self._attributes.usdTimecode)
return data_view.get()
@usdTimecode.setter
def usdTimecode(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.usdTimecode)
data_view = og.AttributeValueHelper(self._attributes.usdTimecode)
data_view.set(value)
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self.__bundles = og.BundleContainer(context, node, attributes, [], read_only=False, gpu_ptr_kinds={})
self._batchedWriteValues = { }
@property
def primBundle(self) -> og.BundleContents:
"""Get the bundle wrapper class for the attribute outputs.primBundle"""
return self.__bundles.primBundle
@primBundle.setter
def primBundle(self, bundle: og.BundleContents):
"""Overwrite the bundle attribute outputs.primBundle with a new bundle"""
if not isinstance(bundle, og.BundleContents):
carb.log_error("Only bundle attributes can be assigned to another bundle attribute")
self.__bundles.primBundle.bundle = bundle
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
@property
def attrNamesToImport(self):
data_view = og.AttributeValueHelper(self._attributes.attrNamesToImport)
return data_view.get()
@attrNamesToImport.setter
def attrNamesToImport(self, value):
data_view = og.AttributeValueHelper(self._attributes.attrNamesToImport)
data_view.set(value)
@property
def computeBoundingBox(self):
data_view = og.AttributeValueHelper(self._attributes.computeBoundingBox)
return data_view.get()
@computeBoundingBox.setter
def computeBoundingBox(self, value):
data_view = og.AttributeValueHelper(self._attributes.computeBoundingBox)
data_view.set(value)
@property
def primPath(self):
data_view = og.AttributeValueHelper(self._attributes.primPath)
return data_view.get()
@primPath.setter
def primPath(self, value):
data_view = og.AttributeValueHelper(self._attributes.primPath)
data_view.set(value)
@property
def primTypes(self):
data_view = og.AttributeValueHelper(self._attributes.primTypes)
return data_view.get()
@primTypes.setter
def primTypes(self, value):
data_view = og.AttributeValueHelper(self._attributes.primTypes)
data_view.set(value)
@property
def usdTimecode(self):
data_view = og.AttributeValueHelper(self._attributes.usdTimecode)
return data_view.get()
@usdTimecode.setter
def usdTimecode(self, value):
data_view = og.AttributeValueHelper(self._attributes.usdTimecode)
data_view.set(value)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnReadPrimDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnReadPrimDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnReadPrimDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
| 11,149 | Python | 49.681818 | 677 | 0.658983 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnRandomUnitVectorDatabase.py | """Support for simplified access to data on nodes of type omni.graph.nodes.RandomUnitVector
Generates a random vector with uniform distribution on the unit sphere.
"""
import numpy
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnRandomUnitVectorDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.nodes.RandomUnitVector
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.execIn
inputs.isNoise
inputs.seed
inputs.useSeed
Outputs:
outputs.execOut
outputs.random
State:
state.gen
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:execIn', 'execution', 0, None, 'The input execution port to output a new random value', {}, True, None, False, ''),
('inputs:isNoise', 'bool', 0, 'Is noise function', 'Turn this node into a noise generator function\nFor a given seed, it will then always output the same number(s)', {ogn.MetadataKeys.HIDDEN: 'true', ogn.MetadataKeys.LITERAL_ONLY: '1', ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''),
('inputs:seed', 'uint64', 0, 'Seed', 'The seed of the random generator.', {}, False, None, False, ''),
('inputs:useSeed', 'bool', 0, 'Use seed', 'Use the custom seed instead of a random one', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''),
('outputs:execOut', 'execution', 0, None, 'The output execution port', {}, True, None, False, ''),
('outputs:random', 'vector3f', 0, 'Random Unit Vector', 'The random unit vector that was generated', {}, True, None, False, ''),
('state:gen', 'matrix3d', 0, None, 'Random number generator internal state (abusing matrix3d because it is large enough)', {}, True, None, False, ''),
])
@classmethod
def _populate_role_data(cls):
"""Populate a role structure with the non-default roles on this node type"""
role_data = super()._populate_role_data()
role_data.inputs.execIn = og.AttributeRole.EXECUTION
role_data.outputs.execOut = og.AttributeRole.EXECUTION
role_data.outputs.random = og.AttributeRole.VECTOR
role_data.state.gen = og.AttributeRole.MATRIX
return role_data
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = []
self._batchedReadValues = []
@property
def execIn(self):
data_view = og.AttributeValueHelper(self._attributes.execIn)
return data_view.get()
@execIn.setter
def execIn(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.execIn)
data_view = og.AttributeValueHelper(self._attributes.execIn)
data_view.set(value)
@property
def isNoise(self):
data_view = og.AttributeValueHelper(self._attributes.isNoise)
return data_view.get()
@isNoise.setter
def isNoise(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.isNoise)
data_view = og.AttributeValueHelper(self._attributes.isNoise)
data_view.set(value)
@property
def seed(self):
data_view = og.AttributeValueHelper(self._attributes.seed)
return data_view.get()
@seed.setter
def seed(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.seed)
data_view = og.AttributeValueHelper(self._attributes.seed)
data_view.set(value)
@property
def useSeed(self):
data_view = og.AttributeValueHelper(self._attributes.useSeed)
return data_view.get()
@useSeed.setter
def useSeed(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.useSeed)
data_view = og.AttributeValueHelper(self._attributes.useSeed)
data_view.set(value)
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedWriteValues = { }
@property
def execOut(self):
data_view = og.AttributeValueHelper(self._attributes.execOut)
return data_view.get()
@execOut.setter
def execOut(self, value):
data_view = og.AttributeValueHelper(self._attributes.execOut)
data_view.set(value)
@property
def random(self):
data_view = og.AttributeValueHelper(self._attributes.random)
return data_view.get()
@random.setter
def random(self, value):
data_view = og.AttributeValueHelper(self._attributes.random)
data_view.set(value)
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
@property
def gen(self):
data_view = og.AttributeValueHelper(self._attributes.gen)
return data_view.get()
@gen.setter
def gen(self, value):
data_view = og.AttributeValueHelper(self._attributes.gen)
data_view.set(value)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnRandomUnitVectorDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnRandomUnitVectorDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnRandomUnitVectorDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
| 8,417 | Python | 44.016043 | 304 | 0.646667 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnReadVariableDatabase.py | """Support for simplified access to data on nodes of type omni.graph.core.ReadVariable
Node that reads a value from a variable
"""
from typing import Any
import usdrt
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnReadVariableDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.core.ReadVariable
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.graph
inputs.targetPath
inputs.variableName
Outputs:
outputs.value
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:graph', 'target', 0, None, 'Ignored. Do not use', {ogn.MetadataKeys.HIDDEN: 'true'}, False, [], False, ''),
('inputs:targetPath', 'token', 0, None, 'Ignored. Do not use.', {ogn.MetadataKeys.HIDDEN: 'true'}, False, None, False, ''),
('inputs:variableName', 'token', 0, None, 'The name of the graph variable to use.', {ogn.MetadataKeys.HIDDEN: 'true', ogn.MetadataKeys.LITERAL_ONLY: '1'}, True, "", False, ''),
('outputs:value', 'any', 2, None, 'The variable value that we returned.', {}, True, None, False, ''),
])
@classmethod
def _populate_role_data(cls):
"""Populate a role structure with the non-default roles on this node type"""
role_data = super()._populate_role_data()
role_data.inputs.graph = og.AttributeRole.TARGET
return role_data
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = []
self._batchedReadValues = []
@property
def graph(self):
data_view = og.AttributeValueHelper(self._attributes.graph)
return data_view.get()
@graph.setter
def graph(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.graph)
data_view = og.AttributeValueHelper(self._attributes.graph)
data_view.set(value)
self.graph_size = data_view.get_array_size()
@property
def targetPath(self):
data_view = og.AttributeValueHelper(self._attributes.targetPath)
return data_view.get()
@targetPath.setter
def targetPath(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.targetPath)
data_view = og.AttributeValueHelper(self._attributes.targetPath)
data_view.set(value)
@property
def variableName(self):
data_view = og.AttributeValueHelper(self._attributes.variableName)
return data_view.get()
@variableName.setter
def variableName(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.variableName)
data_view = og.AttributeValueHelper(self._attributes.variableName)
data_view.set(value)
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedWriteValues = { }
@property
def value(self) -> og.RuntimeAttribute:
"""Get the runtime wrapper class for the attribute outputs.value"""
return og.RuntimeAttribute(self._attributes.value.get_attribute_data(), self._context, False)
@value.setter
def value(self, value_to_set: Any):
"""Assign another attribute's value to outputs.value"""
if isinstance(value_to_set, og.RuntimeAttribute):
self.value.value = value_to_set.value
else:
self.value.value = value_to_set
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnReadVariableDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnReadVariableDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnReadVariableDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
| 6,886 | Python | 44.913333 | 184 | 0.654807 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnBlendVariantsDatabase.py | """Support for simplified access to data on nodes of type omni.graph.nodes.BlendVariants
Add new variant by blending two variants
"""
import carb
import usdrt
import carb
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnBlendVariantsDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.nodes.BlendVariants
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.blend
inputs.execIn
inputs.prim
inputs.setVariant
inputs.variantNameA
inputs.variantNameB
inputs.variantSetName
Outputs:
outputs.bundle
outputs.execOut
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:blend', 'double', 0, None, 'The blend value in [0.0, 1.0]', {ogn.MetadataKeys.DEFAULT: '0.0'}, True, 0.0, False, ''),
('inputs:execIn', 'execution', 0, None, 'The input execution', {}, True, None, False, ''),
('inputs:prim', 'target', 0, None, 'The prim with the variantSet', {}, True, [], False, ''),
('inputs:setVariant', 'bool', 0, None, 'Sets the variant selection when finished rather than writing to the attribute values', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''),
('inputs:variantNameA', 'token', 0, None, 'The first variant name', {}, True, "", False, ''),
('inputs:variantNameB', 'token', 0, None, 'The second variant name', {}, True, "", False, ''),
('inputs:variantSetName', 'token', 0, None, 'The variantSet name', {}, True, "", False, ''),
('outputs:bundle', 'bundle', 0, 'Bundle', 'Output bundle with blended attributes', {}, True, None, False, ''),
('outputs:execOut', 'execution', 0, None, 'The output execution', {}, True, None, False, ''),
])
@classmethod
def _populate_role_data(cls):
"""Populate a role structure with the non-default roles on this node type"""
role_data = super()._populate_role_data()
role_data.inputs.execIn = og.AttributeRole.EXECUTION
role_data.inputs.prim = og.AttributeRole.TARGET
role_data.outputs.bundle = og.AttributeRole.BUNDLE
role_data.outputs.execOut = og.AttributeRole.EXECUTION
return role_data
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = []
self._batchedReadValues = []
@property
def blend(self):
data_view = og.AttributeValueHelper(self._attributes.blend)
return data_view.get()
@blend.setter
def blend(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.blend)
data_view = og.AttributeValueHelper(self._attributes.blend)
data_view.set(value)
@property
def execIn(self):
data_view = og.AttributeValueHelper(self._attributes.execIn)
return data_view.get()
@execIn.setter
def execIn(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.execIn)
data_view = og.AttributeValueHelper(self._attributes.execIn)
data_view.set(value)
@property
def prim(self):
data_view = og.AttributeValueHelper(self._attributes.prim)
return data_view.get()
@prim.setter
def prim(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.prim)
data_view = og.AttributeValueHelper(self._attributes.prim)
data_view.set(value)
self.prim_size = data_view.get_array_size()
@property
def setVariant(self):
data_view = og.AttributeValueHelper(self._attributes.setVariant)
return data_view.get()
@setVariant.setter
def setVariant(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.setVariant)
data_view = og.AttributeValueHelper(self._attributes.setVariant)
data_view.set(value)
@property
def variantNameA(self):
data_view = og.AttributeValueHelper(self._attributes.variantNameA)
return data_view.get()
@variantNameA.setter
def variantNameA(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.variantNameA)
data_view = og.AttributeValueHelper(self._attributes.variantNameA)
data_view.set(value)
@property
def variantNameB(self):
data_view = og.AttributeValueHelper(self._attributes.variantNameB)
return data_view.get()
@variantNameB.setter
def variantNameB(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.variantNameB)
data_view = og.AttributeValueHelper(self._attributes.variantNameB)
data_view.set(value)
@property
def variantSetName(self):
data_view = og.AttributeValueHelper(self._attributes.variantSetName)
return data_view.get()
@variantSetName.setter
def variantSetName(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.variantSetName)
data_view = og.AttributeValueHelper(self._attributes.variantSetName)
data_view.set(value)
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self.__bundles = og.BundleContainer(context, node, attributes, [], read_only=False, gpu_ptr_kinds={})
self._batchedWriteValues = { }
@property
def bundle(self) -> og.BundleContents:
"""Get the bundle wrapper class for the attribute outputs.bundle"""
return self.__bundles.bundle
@bundle.setter
def bundle(self, bundle: og.BundleContents):
"""Overwrite the bundle attribute outputs.bundle with a new bundle"""
if not isinstance(bundle, og.BundleContents):
carb.log_error("Only bundle attributes can be assigned to another bundle attribute")
self.__bundles.bundle.bundle = bundle
@property
def execOut(self):
data_view = og.AttributeValueHelper(self._attributes.execOut)
return data_view.get()
@execOut.setter
def execOut(self, value):
data_view = og.AttributeValueHelper(self._attributes.execOut)
data_view.set(value)
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnBlendVariantsDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnBlendVariantsDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnBlendVariantsDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
| 9,889 | Python | 43.549549 | 196 | 0.640004 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnSourceIndicesDatabase.py | """Support for simplified access to data on nodes of type omni.graph.nodes.SourceIndices
Takes an input array of index values in 'sourceStartsInTarget' encoded as the list of index values at which the output array
value will be incremented, starting at the second entry, and with the last entry into the array being the desired sized
of the output array 'sourceIndices'. For example the input [1,2,3,5,6,6] would generate an output array of size 5 (last
index) consisting of the values [0,0,2,3,3,3]:
- the first two 0s to fill the output array up to index input[1]=2
- the first two 0s to fill the output array up to index input[1]=2
- the 2 to fill the output array up to index input[2]=3
- the three 3s to fill the output array up to index input[3]=6
"""
import numpy
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnSourceIndicesDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.nodes.SourceIndices
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.sourceStartsInTarget
Outputs:
outputs.sourceIndices
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:sourceStartsInTarget', 'int[]', 0, None, 'List of index values encoding the increments for the output array values', {ogn.MetadataKeys.DEFAULT: '[]'}, True, [], False, ''),
('outputs:sourceIndices', 'int[]', 0, None, 'Decoded list of index values as described by the node algorithm', {ogn.MetadataKeys.DEFAULT: '[]'}, True, [], False, ''),
])
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = []
self._batchedReadValues = []
@property
def sourceStartsInTarget(self):
data_view = og.AttributeValueHelper(self._attributes.sourceStartsInTarget)
return data_view.get()
@sourceStartsInTarget.setter
def sourceStartsInTarget(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.sourceStartsInTarget)
data_view = og.AttributeValueHelper(self._attributes.sourceStartsInTarget)
data_view.set(value)
self.sourceStartsInTarget_size = data_view.get_array_size()
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self.sourceIndices_size = 0
self._batchedWriteValues = { }
@property
def sourceIndices(self):
data_view = og.AttributeValueHelper(self._attributes.sourceIndices)
return data_view.get(reserved_element_count=self.sourceIndices_size)
@sourceIndices.setter
def sourceIndices(self, value):
data_view = og.AttributeValueHelper(self._attributes.sourceIndices)
data_view.set(value)
self.sourceIndices_size = data_view.get_array_size()
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnSourceIndicesDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnSourceIndicesDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnSourceIndicesDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
| 6,168 | Python | 49.565573 | 189 | 0.686122 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnTranslateToTargetDatabase.py | """Support for simplified access to data on nodes of type omni.graph.nodes.TranslateToTarget
This node smoothly translates a prim object to a target prim object given a speed and easing factor. At the end of the maneuver,
the source prim will have the same translation as the target prim
"""
import usdrt
import carb
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnTranslateToTargetDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.nodes.TranslateToTarget
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.execIn
inputs.exponent
inputs.sourcePrim
inputs.sourcePrimPath
inputs.speed
inputs.stop
inputs.targetPrim
inputs.targetPrimPath
inputs.useSourcePath
inputs.useTargetPath
Outputs:
outputs.finished
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:execIn', 'execution', 0, 'Execute In', 'The input execution', {}, True, None, False, ''),
('inputs:exponent', 'float', 0, None, 'The blend exponent, which is the degree of the ease curve\n (1 = linear, 2 = quadratic, 3 = cubic, etc). ', {ogn.MetadataKeys.DEFAULT: '2.0'}, True, 2.0, False, ''),
('inputs:sourcePrim', 'target', 0, None, 'The source prim to be transformed', {}, False, [], False, ''),
('inputs:sourcePrimPath', 'path', 0, None, "The source prim to be transformed, used when 'useSourcePath' is true", {}, False, None, False, ''),
('inputs:speed', 'double', 0, None, 'The peak speed of approach (Units / Second)', {ogn.MetadataKeys.DEFAULT: '1.0'}, True, 1.0, False, ''),
('inputs:stop', 'execution', 0, 'Stop', 'Stops the maneuver', {}, True, None, False, ''),
('inputs:targetPrim', 'bundle', 0, None, "The destination prim. The target's translation will be matched by the sourcePrim", {}, False, None, False, ''),
('inputs:targetPrimPath', 'path', 0, None, "The destination prim. The target's translation will be matched by the sourcePrim, used when 'useTargetPath' is true", {}, False, None, False, ''),
('inputs:useSourcePath', 'bool', 0, None, "When true, the 'sourcePrimPath' attribute is used, otherwise it will read the connection at the 'sourcePrim' attribute", {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''),
('inputs:useTargetPath', 'bool', 0, None, "When true, the 'targetPrimPath' attribute is used, otherwise it will read the connection at the 'targetPrim' attribute", {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''),
('outputs:finished', 'execution', 0, 'Finished', 'The output execution, sent one the maneuver is completed', {}, True, None, False, ''),
])
@classmethod
def _populate_role_data(cls):
"""Populate a role structure with the non-default roles on this node type"""
role_data = super()._populate_role_data()
role_data.inputs.execIn = og.AttributeRole.EXECUTION
role_data.inputs.sourcePrim = og.AttributeRole.TARGET
role_data.inputs.sourcePrimPath = og.AttributeRole.PATH
role_data.inputs.stop = og.AttributeRole.EXECUTION
role_data.inputs.targetPrim = og.AttributeRole.BUNDLE
role_data.inputs.targetPrimPath = og.AttributeRole.PATH
role_data.outputs.finished = og.AttributeRole.EXECUTION
return role_data
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self.__bundles = og.BundleContainer(context, node, attributes, [], read_only=True, gpu_ptr_kinds={})
self._batchedReadAttributes = []
self._batchedReadValues = []
@property
def execIn(self):
data_view = og.AttributeValueHelper(self._attributes.execIn)
return data_view.get()
@execIn.setter
def execIn(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.execIn)
data_view = og.AttributeValueHelper(self._attributes.execIn)
data_view.set(value)
@property
def exponent(self):
data_view = og.AttributeValueHelper(self._attributes.exponent)
return data_view.get()
@exponent.setter
def exponent(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.exponent)
data_view = og.AttributeValueHelper(self._attributes.exponent)
data_view.set(value)
@property
def sourcePrim(self):
data_view = og.AttributeValueHelper(self._attributes.sourcePrim)
return data_view.get()
@sourcePrim.setter
def sourcePrim(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.sourcePrim)
data_view = og.AttributeValueHelper(self._attributes.sourcePrim)
data_view.set(value)
self.sourcePrim_size = data_view.get_array_size()
@property
def sourcePrimPath(self):
data_view = og.AttributeValueHelper(self._attributes.sourcePrimPath)
return data_view.get()
@sourcePrimPath.setter
def sourcePrimPath(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.sourcePrimPath)
data_view = og.AttributeValueHelper(self._attributes.sourcePrimPath)
data_view.set(value)
self.sourcePrimPath_size = data_view.get_array_size()
@property
def speed(self):
data_view = og.AttributeValueHelper(self._attributes.speed)
return data_view.get()
@speed.setter
def speed(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.speed)
data_view = og.AttributeValueHelper(self._attributes.speed)
data_view.set(value)
@property
def stop(self):
data_view = og.AttributeValueHelper(self._attributes.stop)
return data_view.get()
@stop.setter
def stop(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.stop)
data_view = og.AttributeValueHelper(self._attributes.stop)
data_view.set(value)
@property
def targetPrim(self) -> og.BundleContents:
"""Get the bundle wrapper class for the attribute inputs.targetPrim"""
return self.__bundles.targetPrim
@property
def targetPrimPath(self):
data_view = og.AttributeValueHelper(self._attributes.targetPrimPath)
return data_view.get()
@targetPrimPath.setter
def targetPrimPath(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.targetPrimPath)
data_view = og.AttributeValueHelper(self._attributes.targetPrimPath)
data_view.set(value)
self.targetPrimPath_size = data_view.get_array_size()
@property
def useSourcePath(self):
data_view = og.AttributeValueHelper(self._attributes.useSourcePath)
return data_view.get()
@useSourcePath.setter
def useSourcePath(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.useSourcePath)
data_view = og.AttributeValueHelper(self._attributes.useSourcePath)
data_view.set(value)
@property
def useTargetPath(self):
data_view = og.AttributeValueHelper(self._attributes.useTargetPath)
return data_view.get()
@useTargetPath.setter
def useTargetPath(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.useTargetPath)
data_view = og.AttributeValueHelper(self._attributes.useTargetPath)
data_view.set(value)
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedWriteValues = { }
@property
def finished(self):
data_view = og.AttributeValueHelper(self._attributes.finished)
return data_view.get()
@finished.setter
def finished(self, value):
data_view = og.AttributeValueHelper(self._attributes.finished)
data_view.set(value)
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnTranslateToTargetDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnTranslateToTargetDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnTranslateToTargetDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
| 11,759 | Python | 46.419355 | 233 | 0.648184 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnFModDatabase.py | """Support for simplified access to data on nodes of type omni.graph.nodes.FMod
Computes the floating point remainder of A / B. If B is zero, the result is zero. The returned value has the same sign as
A
"""
from typing import Any
import sys
import traceback
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnFModDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.nodes.FMod
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.a
inputs.b
Outputs:
outputs.result
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:a', 'colord[3],colord[3][],colord[4],colord[4][],colorf[3],colorf[3][],colorf[4],colorf[4][],colorh[3],colorh[3][],colorh[4],colorh[4][],double,double[2],double[2][],double[3],double[3][],double[4],double[4][],double[],float,float[2],float[2][],float[3],float[3][],float[4],float[4][],float[],half,half[2],half[2][],half[3],half[3][],half[4],half[4][],half[],normald[3],normald[3][],normalf[3],normalf[3][],normalh[3],normalh[3][],pointd[3],pointd[3][],pointf[3],pointf[3][],pointh[3],pointh[3][],quatd[4],quatd[4][],quatf[4],quatf[4][],quath[4],quath[4][],texcoordd[2],texcoordd[2][],texcoordd[3],texcoordd[3][],texcoordf[2],texcoordf[2][],texcoordf[3],texcoordf[3][],texcoordh[2],texcoordh[2][],texcoordh[3],texcoordh[3][],timecode,timecode[],vectord[3],vectord[3][],vectorf[3],vectorf[3][],vectorh[3],vectorh[3][]', 1, 'A', 'The dividend of (A / B)', {}, True, None, False, ''),
('inputs:b', 'colord[3],colord[3][],colord[4],colord[4][],colorf[3],colorf[3][],colorf[4],colorf[4][],colorh[3],colorh[3][],colorh[4],colorh[4][],double,double[2],double[2][],double[3],double[3][],double[4],double[4][],double[],float,float[2],float[2][],float[3],float[3][],float[4],float[4][],float[],half,half[2],half[2][],half[3],half[3][],half[4],half[4][],half[],normald[3],normald[3][],normalf[3],normalf[3][],normalh[3],normalh[3][],pointd[3],pointd[3][],pointf[3],pointf[3][],pointh[3],pointh[3][],quatd[4],quatd[4][],quatf[4],quatf[4][],quath[4],quath[4][],texcoordd[2],texcoordd[2][],texcoordd[3],texcoordd[3][],texcoordf[2],texcoordf[2][],texcoordf[3],texcoordf[3][],texcoordh[2],texcoordh[2][],texcoordh[3],texcoordh[3][],timecode,timecode[],vectord[3],vectord[3][],vectorf[3],vectorf[3][],vectorh[3],vectorh[3][]', 1, 'B', 'The divisor of (A / B)', {}, True, None, False, ''),
('outputs:result', 'colord[3],colord[3][],colord[4],colord[4][],colorf[3],colorf[3][],colorf[4],colorf[4][],colorh[3],colorh[3][],colorh[4],colorh[4][],double,double[2],double[2][],double[3],double[3][],double[4],double[4][],double[],float,float[2],float[2][],float[3],float[3][],float[4],float[4][],float[],half,half[2],half[2][],half[3],half[3][],half[4],half[4][],half[],normald[3],normald[3][],normalf[3],normalf[3][],normalh[3],normalh[3][],pointd[3],pointd[3][],pointf[3],pointf[3][],pointh[3],pointh[3][],quatd[4],quatd[4][],quatf[4],quatf[4][],quath[4],quath[4][],texcoordd[2],texcoordd[2][],texcoordd[3],texcoordd[3][],texcoordf[2],texcoordf[2][],texcoordf[3],texcoordf[3][],texcoordh[2],texcoordh[2][],texcoordh[3],texcoordh[3][],timecode,timecode[],vectord[3],vectord[3][],vectorf[3],vectorf[3][],vectorh[3],vectorh[3][]', 1, 'Result', 'The floating point remainder of A / B', {}, True, None, False, ''),
])
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = []
self._batchedReadValues = []
@property
def a(self) -> og.RuntimeAttribute:
"""Get the runtime wrapper class for the attribute inputs.a"""
return og.RuntimeAttribute(self._attributes.a.get_attribute_data(), self._context, True)
@a.setter
def a(self, value_to_set: Any):
"""Assign another attribute's value to outputs.a"""
if isinstance(value_to_set, og.RuntimeAttribute):
self.a.value = value_to_set.value
else:
self.a.value = value_to_set
@property
def b(self) -> og.RuntimeAttribute:
"""Get the runtime wrapper class for the attribute inputs.b"""
return og.RuntimeAttribute(self._attributes.b.get_attribute_data(), self._context, True)
@b.setter
def b(self, value_to_set: Any):
"""Assign another attribute's value to outputs.b"""
if isinstance(value_to_set, og.RuntimeAttribute):
self.b.value = value_to_set.value
else:
self.b.value = value_to_set
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedWriteValues = { }
@property
def result(self) -> og.RuntimeAttribute:
"""Get the runtime wrapper class for the attribute outputs.result"""
return og.RuntimeAttribute(self._attributes.result.get_attribute_data(), self._context, False)
@result.setter
def result(self, value_to_set: Any):
"""Assign another attribute's value to outputs.result"""
if isinstance(value_to_set, og.RuntimeAttribute):
self.result.value = value_to_set.value
else:
self.result.value = value_to_set
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnFModDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnFModDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnFModDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
class abi:
"""Class defining the ABI interface for the node type"""
@staticmethod
def get_node_type():
get_node_type_function = getattr(OgnFModDatabase.NODE_TYPE_CLASS, 'get_node_type', None)
if callable(get_node_type_function):
return get_node_type_function()
return 'omni.graph.nodes.FMod'
@staticmethod
def compute(context, node):
def database_valid():
if db.inputs.a.type.base_type == og.BaseDataType.UNKNOWN:
db.log_warning('Required extended attribute inputs:a is not resolved, compute skipped')
return False
if db.inputs.b.type.base_type == og.BaseDataType.UNKNOWN:
db.log_warning('Required extended attribute inputs:b is not resolved, compute skipped')
return False
if db.outputs.result.type.base_type == og.BaseDataType.UNKNOWN:
db.log_warning('Required extended attribute outputs:result is not resolved, compute skipped')
return False
return True
try:
per_node_data = OgnFModDatabase.PER_NODE_DATA[node.node_id()]
db = per_node_data.get('_db')
if db is None:
db = OgnFModDatabase(node)
per_node_data['_db'] = db
if not database_valid():
per_node_data['_db'] = None
return False
except:
db = OgnFModDatabase(node)
try:
compute_function = getattr(OgnFModDatabase.NODE_TYPE_CLASS, 'compute', None)
if callable(compute_function) and compute_function.__code__.co_argcount > 1:
return compute_function(context, node)
db.inputs._prefetch()
db.inputs._setting_locked = True
with og.in_compute():
return OgnFModDatabase.NODE_TYPE_CLASS.compute(db)
except Exception as error:
stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next))
db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False)
finally:
db.inputs._setting_locked = False
db.outputs._commit()
return False
@staticmethod
def initialize(context, node):
OgnFModDatabase._initialize_per_node_data(node)
initialize_function = getattr(OgnFModDatabase.NODE_TYPE_CLASS, 'initialize', None)
if callable(initialize_function):
initialize_function(context, node)
per_node_data = OgnFModDatabase.PER_NODE_DATA[node.node_id()]
def on_connection_or_disconnection(*args):
per_node_data['_db'] = None
node.register_on_connected_callback(on_connection_or_disconnection)
node.register_on_disconnected_callback(on_connection_or_disconnection)
@staticmethod
def release(node):
release_function = getattr(OgnFModDatabase.NODE_TYPE_CLASS, 'release', None)
if callable(release_function):
release_function(node)
OgnFModDatabase._release_per_node_data(node)
@staticmethod
def release_instance(node, target):
OgnFModDatabase._release_per_node_instance_data(node, target)
@staticmethod
def update_node_version(context, node, old_version, new_version):
update_node_version_function = getattr(OgnFModDatabase.NODE_TYPE_CLASS, 'update_node_version', None)
if callable(update_node_version_function):
return update_node_version_function(context, node, old_version, new_version)
return False
@staticmethod
def initialize_type(node_type):
initialize_type_function = getattr(OgnFModDatabase.NODE_TYPE_CLASS, 'initialize_type', None)
needs_initializing = True
if callable(initialize_type_function):
needs_initializing = initialize_type_function(node_type)
if needs_initializing:
node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.nodes")
node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Float Remainder")
node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "math:operator")
node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "Computes the floating point remainder of A / B. If B is zero, the result is zero. The returned value has the same sign as A")
node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python")
OgnFModDatabase.INTERFACE.add_to_node_type(node_type)
@staticmethod
def on_connection_type_resolve(node):
on_connection_type_resolve_function = getattr(OgnFModDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None)
if callable(on_connection_type_resolve_function):
on_connection_type_resolve_function(node)
NODE_TYPE_CLASS = None
@staticmethod
def register(node_type_class):
OgnFModDatabase.NODE_TYPE_CLASS = node_type_class
og.register_node_type(OgnFModDatabase.abi, 1)
@staticmethod
def deregister():
og.deregister_node_type("omni.graph.nodes.FMod")
| 13,963 | Python | 55.534413 | 923 | 0.630595 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnCreateTubeTopologyDatabase.py | """Support for simplified access to data on nodes of type omni.graph.nodes.CreateTubeTopology
Creates the face vertex counts and indices describing a tube topology with the given number of rows and columns.
"""
import numpy
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnCreateTubeTopologyDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.nodes.CreateTubeTopology
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.cols
inputs.rows
Outputs:
outputs.faceVertexCounts
outputs.faceVertexIndices
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:cols', 'int[]', 0, 'Column Array', 'Array of columns in the topology to be generated', {}, True, [], False, ''),
('inputs:rows', 'int[]', 0, 'Row Array', 'Array of rows in the topology to be generated', {}, True, [], False, ''),
('outputs:faceVertexCounts', 'int[]', 0, 'Face Vertex Counts', 'Array of vertex counts for each face in the tube topology', {}, True, None, False, ''),
('outputs:faceVertexIndices', 'int[]', 0, 'Face Vertex Indices', 'Array of vertex indices for each face in the tube topology', {}, True, None, False, ''),
])
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = []
self._batchedReadValues = []
@property
def cols(self):
data_view = og.AttributeValueHelper(self._attributes.cols)
return data_view.get()
@cols.setter
def cols(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.cols)
data_view = og.AttributeValueHelper(self._attributes.cols)
data_view.set(value)
self.cols_size = data_view.get_array_size()
@property
def rows(self):
data_view = og.AttributeValueHelper(self._attributes.rows)
return data_view.get()
@rows.setter
def rows(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.rows)
data_view = og.AttributeValueHelper(self._attributes.rows)
data_view.set(value)
self.rows_size = data_view.get_array_size()
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self.faceVertexCounts_size = None
self.faceVertexIndices_size = None
self._batchedWriteValues = { }
@property
def faceVertexCounts(self):
data_view = og.AttributeValueHelper(self._attributes.faceVertexCounts)
return data_view.get(reserved_element_count=self.faceVertexCounts_size)
@faceVertexCounts.setter
def faceVertexCounts(self, value):
data_view = og.AttributeValueHelper(self._attributes.faceVertexCounts)
data_view.set(value)
self.faceVertexCounts_size = data_view.get_array_size()
@property
def faceVertexIndices(self):
data_view = og.AttributeValueHelper(self._attributes.faceVertexIndices)
return data_view.get(reserved_element_count=self.faceVertexIndices_size)
@faceVertexIndices.setter
def faceVertexIndices(self, value):
data_view = og.AttributeValueHelper(self._attributes.faceVertexIndices)
data_view.set(value)
self.faceVertexIndices_size = data_view.get_array_size()
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnCreateTubeTopologyDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnCreateTubeTopologyDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnCreateTubeTopologyDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
| 6,796 | Python | 46.866197 | 162 | 0.665097 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnGetPrimsDatabase.py | """Support for simplified access to data on nodes of type omni.graph.nodes.GetPrims
Filters primitives in the input bundle by path and type.
"""
import usdrt
import carb
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnGetPrimsDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.nodes.GetPrims
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.bundle
inputs.inverse
inputs.pathPattern
inputs.prims
inputs.typePattern
Outputs:
outputs.bundle
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:bundle', 'bundle', 0, None, 'The bundle to be read from', {}, True, None, False, ''),
('inputs:inverse', 'bool', 0, 'Inverse', 'By default all primitives matching the path patterns and types are added to the output bundle;\nwhen this option is on, all mismatching primitives will be added instead.', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''),
('inputs:pathPattern', 'string', 0, 'Path Pattern', "A list of wildcard patterns used to match primitive path.\n\nSupported syntax of wildcard pattern:\n `*` - match an arbitrary number of any characters\n `?` - match any single character\n `^` - (caret) is used to define a pattern that is to be excluded\n\nExample of wildcard patterns, input: ['/Cube0', '/Cube1', '/Box']\n '*' - match any\n '* ^/Box' - match any, but exclude '/Box'\n '* ^/Cube*' - match any, but exclude '/Cube0' and '/Cube1'", {ogn.MetadataKeys.DEFAULT: '"*"'}, True, "*", False, ''),
('inputs:prims', 'target', 0, None, 'The prim to be extracted from Multiple Primitives in Bundle.', {ogn.MetadataKeys.ALLOW_MULTI_INPUTS: '1'}, False, [], False, ''),
('inputs:typePattern', 'string', 0, 'Type Pattern', "A list of wildcard patterns used to match primitive type.\n\nSupported syntax of wildcard pattern:\n `*` - match an arbitrary number of any characters\n `?` - match any single character\n `^` - (caret) is used to define a pattern that is to be excluded\n\nExample of wildcard patterns, input: ['Mesh', 'Cone', 'Cube']\n '*' - match any\n '* ^Mesh' - match any, but exclude 'Mesh'\n '* ^Cone ^Cube' - match any, but exclude 'Cone' and 'Cube'", {ogn.MetadataKeys.DEFAULT: '"*"'}, True, "*", False, ''),
('outputs:bundle', 'bundle', 0, None, 'The output bundle that contains filtered primitives', {}, True, None, False, ''),
])
@classmethod
def _populate_role_data(cls):
"""Populate a role structure with the non-default roles on this node type"""
role_data = super()._populate_role_data()
role_data.inputs.bundle = og.AttributeRole.BUNDLE
role_data.inputs.pathPattern = og.AttributeRole.TEXT
role_data.inputs.prims = og.AttributeRole.TARGET
role_data.inputs.typePattern = og.AttributeRole.TEXT
role_data.outputs.bundle = og.AttributeRole.BUNDLE
return role_data
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self.__bundles = og.BundleContainer(context, node, attributes, [], read_only=True, gpu_ptr_kinds={})
self._batchedReadAttributes = []
self._batchedReadValues = []
@property
def bundle(self) -> og.BundleContents:
"""Get the bundle wrapper class for the attribute inputs.bundle"""
return self.__bundles.bundle
@property
def inverse(self):
data_view = og.AttributeValueHelper(self._attributes.inverse)
return data_view.get()
@inverse.setter
def inverse(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.inverse)
data_view = og.AttributeValueHelper(self._attributes.inverse)
data_view.set(value)
@property
def pathPattern(self):
data_view = og.AttributeValueHelper(self._attributes.pathPattern)
return data_view.get()
@pathPattern.setter
def pathPattern(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.pathPattern)
data_view = og.AttributeValueHelper(self._attributes.pathPattern)
data_view.set(value)
self.pathPattern_size = data_view.get_array_size()
@property
def prims(self):
data_view = og.AttributeValueHelper(self._attributes.prims)
return data_view.get()
@prims.setter
def prims(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.prims)
data_view = og.AttributeValueHelper(self._attributes.prims)
data_view.set(value)
self.prims_size = data_view.get_array_size()
@property
def typePattern(self):
data_view = og.AttributeValueHelper(self._attributes.typePattern)
return data_view.get()
@typePattern.setter
def typePattern(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.typePattern)
data_view = og.AttributeValueHelper(self._attributes.typePattern)
data_view.set(value)
self.typePattern_size = data_view.get_array_size()
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self.__bundles = og.BundleContainer(context, node, attributes, [], read_only=False, gpu_ptr_kinds={})
self._batchedWriteValues = { }
@property
def bundle(self) -> og.BundleContents:
"""Get the bundle wrapper class for the attribute outputs.bundle"""
return self.__bundles.bundle
@bundle.setter
def bundle(self, bundle: og.BundleContents):
"""Overwrite the bundle attribute outputs.bundle with a new bundle"""
if not isinstance(bundle, og.BundleContents):
carb.log_error("Only bundle attributes can be assigned to another bundle attribute")
self.__bundles.bundle.bundle = bundle
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnGetPrimsDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnGetPrimsDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnGetPrimsDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
| 9,413 | Python | 51.88764 | 583 | 0.653033 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnCurveTubePositionsDatabase.py | """Support for simplified access to data on nodes of type omni.graph.nodes.CurveTubePositions
Generate tube positions from a curve description
"""
import numpy
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnCurveTubePositionsDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.nodes.CurveTubePositions
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.cols
inputs.curvePoints
inputs.curveVertexCounts
inputs.curveVertexStarts
inputs.out
inputs.tubePointStarts
inputs.up
inputs.width
Outputs:
outputs.points
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:cols', 'int[]', 0, 'Columns', 'Columns of the tubes', {}, True, [], False, ''),
('inputs:curvePoints', 'float3[]', 0, 'Curve Points', 'Points on the curve to be framed', {}, True, [], False, ''),
('inputs:curveVertexCounts', 'int[]', 0, 'Curve Vertex Counts', 'Vertex counts for the curve points', {}, True, [], False, ''),
('inputs:curveVertexStarts', 'int[]', 0, 'Curve Vertex Starts', 'Vertex starting points', {}, True, [], False, ''),
('inputs:out', 'float3[]', 0, 'Out Vectors', 'Out vector directions on the tube', {}, True, [], False, ''),
('inputs:tubePointStarts', 'int[]', 0, 'Tube Point Starts', 'Tube starting point index values', {}, True, [], False, ''),
('inputs:up', 'float3[]', 0, 'Up Vectors', 'Up vectors on the tube', {}, True, [], False, ''),
('inputs:width', 'float[]', 0, 'Tube Widths', 'Width of tube positions', {}, True, [], False, ''),
('outputs:points', 'float3[]', 0, 'Points', 'Points on the tube', {}, True, None, False, ''),
])
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = []
self._batchedReadValues = []
@property
def cols(self):
data_view = og.AttributeValueHelper(self._attributes.cols)
return data_view.get()
@cols.setter
def cols(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.cols)
data_view = og.AttributeValueHelper(self._attributes.cols)
data_view.set(value)
self.cols_size = data_view.get_array_size()
@property
def curvePoints(self):
data_view = og.AttributeValueHelper(self._attributes.curvePoints)
return data_view.get()
@curvePoints.setter
def curvePoints(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.curvePoints)
data_view = og.AttributeValueHelper(self._attributes.curvePoints)
data_view.set(value)
self.curvePoints_size = data_view.get_array_size()
@property
def curveVertexCounts(self):
data_view = og.AttributeValueHelper(self._attributes.curveVertexCounts)
return data_view.get()
@curveVertexCounts.setter
def curveVertexCounts(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.curveVertexCounts)
data_view = og.AttributeValueHelper(self._attributes.curveVertexCounts)
data_view.set(value)
self.curveVertexCounts_size = data_view.get_array_size()
@property
def curveVertexStarts(self):
data_view = og.AttributeValueHelper(self._attributes.curveVertexStarts)
return data_view.get()
@curveVertexStarts.setter
def curveVertexStarts(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.curveVertexStarts)
data_view = og.AttributeValueHelper(self._attributes.curveVertexStarts)
data_view.set(value)
self.curveVertexStarts_size = data_view.get_array_size()
@property
def out(self):
data_view = og.AttributeValueHelper(self._attributes.out)
return data_view.get()
@out.setter
def out(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.out)
data_view = og.AttributeValueHelper(self._attributes.out)
data_view.set(value)
self.out_size = data_view.get_array_size()
@property
def tubePointStarts(self):
data_view = og.AttributeValueHelper(self._attributes.tubePointStarts)
return data_view.get()
@tubePointStarts.setter
def tubePointStarts(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.tubePointStarts)
data_view = og.AttributeValueHelper(self._attributes.tubePointStarts)
data_view.set(value)
self.tubePointStarts_size = data_view.get_array_size()
@property
def up(self):
data_view = og.AttributeValueHelper(self._attributes.up)
return data_view.get()
@up.setter
def up(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.up)
data_view = og.AttributeValueHelper(self._attributes.up)
data_view.set(value)
self.up_size = data_view.get_array_size()
@property
def width(self):
data_view = og.AttributeValueHelper(self._attributes.width)
return data_view.get()
@width.setter
def width(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.width)
data_view = og.AttributeValueHelper(self._attributes.width)
data_view.set(value)
self.width_size = data_view.get_array_size()
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self.points_size = None
self._batchedWriteValues = { }
@property
def points(self):
data_view = og.AttributeValueHelper(self._attributes.points)
return data_view.get(reserved_element_count=self.points_size)
@points.setter
def points(self, value):
data_view = og.AttributeValueHelper(self._attributes.points)
data_view.set(value)
self.points_size = data_view.get_array_size()
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnCurveTubePositionsDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnCurveTubePositionsDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnCurveTubePositionsDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
| 9,775 | Python | 43.844036 | 135 | 0.633555 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnExtractPrimDatabase.py | """Support for simplified access to data on nodes of type omni.graph.nodes.ExtractPrim
Extract a child bundle that contains a primitive with requested path/prim. This node is designed to work with Multiple Primitives
in a Bundle. It searches for a child bundle in the input bundle, with 'sourcePrimPath' that matches 'inputs:prim' or 'inputs:primPath'.
The found child bundle will be provided to 'outputs_primBundle', or invalid, bundle otherwise.
"""
import usdrt
import carb
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnExtractPrimDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.nodes.ExtractPrim
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.prim
inputs.primPath
inputs.prims
Outputs:
outputs.primBundle
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:prim', 'target', 0, None, 'The prim to be extracted from Multiple Primitives in Bundle.', {}, True, [], False, ''),
('inputs:primPath', 'path', 0, 'Prim Path', 'The path of the prim to be extracted from Multiple Primitives in Bundle.', {}, True, "", True, 'Use prim input instead'),
('inputs:prims', 'bundle', 0, 'Prims Bundle', 'The Multiple Primitives in Bundle to extract from.', {}, True, None, False, ''),
('outputs:primBundle', 'bundle', 0, None, 'The extracted Single Primitive in Bundle', {}, True, None, False, ''),
])
@classmethod
def _populate_role_data(cls):
"""Populate a role structure with the non-default roles on this node type"""
role_data = super()._populate_role_data()
role_data.inputs.prim = og.AttributeRole.TARGET
role_data.inputs.primPath = og.AttributeRole.PATH
role_data.inputs.prims = og.AttributeRole.BUNDLE
role_data.outputs.primBundle = og.AttributeRole.BUNDLE
return role_data
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self.__bundles = og.BundleContainer(context, node, attributes, [], read_only=True, gpu_ptr_kinds={})
self._batchedReadAttributes = []
self._batchedReadValues = []
@property
def prim(self):
data_view = og.AttributeValueHelper(self._attributes.prim)
return data_view.get()
@prim.setter
def prim(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.prim)
data_view = og.AttributeValueHelper(self._attributes.prim)
data_view.set(value)
self.prim_size = data_view.get_array_size()
@property
def primPath(self):
data_view = og.AttributeValueHelper(self._attributes.primPath)
return data_view.get()
@primPath.setter
def primPath(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.primPath)
data_view = og.AttributeValueHelper(self._attributes.primPath)
data_view.set(value)
self.primPath_size = data_view.get_array_size()
@property
def prims(self) -> og.BundleContents:
"""Get the bundle wrapper class for the attribute inputs.prims"""
return self.__bundles.prims
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self.__bundles = og.BundleContainer(context, node, attributes, [], read_only=False, gpu_ptr_kinds={})
self._batchedWriteValues = { }
@property
def primBundle(self) -> og.BundleContents:
"""Get the bundle wrapper class for the attribute outputs.primBundle"""
return self.__bundles.primBundle
@primBundle.setter
def primBundle(self, bundle: og.BundleContents):
"""Overwrite the bundle attribute outputs.primBundle with a new bundle"""
if not isinstance(bundle, og.BundleContents):
carb.log_error("Only bundle attributes can be assigned to another bundle attribute")
self.__bundles.primBundle.bundle = bundle
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnExtractPrimDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnExtractPrimDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnExtractPrimDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
| 7,389 | Python | 48.266666 | 174 | 0.665855 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnBooleanExprDatabase.py | """Support for simplified access to data on nodes of type omni.graph.nodes.BooleanExpr
NOTE: DEPRECATED AS OF 1.26.0 IN FAVOUR OF INDIVIDAL BOOLEAN OP NODES Boolean operation on two inputs. The supported operations
are:
AND, OR, NAND, NOR, XOR, XNOR
"""
import sys
import traceback
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnBooleanExprDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.nodes.BooleanExpr
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.a
inputs.b
inputs.operator
Outputs:
outputs.result
Predefined Tokens:
tokens.AND
tokens.OR
tokens.NAND
tokens.NOR
tokens.XOR
tokens.XNOR
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:a', 'bool', 0, None, 'Input A', {}, True, False, False, ''),
('inputs:b', 'bool', 0, None, 'Input B', {}, True, False, False, ''),
('inputs:operator', 'token', 0, 'Operator', 'The boolean operation to perform (AND, OR, NAND, NOR, XOR, XNOR)', {ogn.MetadataKeys.ALLOWED_TOKENS: 'AND,OR,NAND,NOR,XOR,XNOR', ogn.MetadataKeys.ALLOWED_TOKENS_RAW: '{"AND": "AND", "OR": "OR", "NAND": "NAND", "NOR": "NOR", "XOR": "XOR", "XNOR": "XNOR"}', ogn.MetadataKeys.DEFAULT: '"AND"'}, True, "AND", False, ''),
('outputs:result', 'bool', 0, 'Result', 'The result of the boolean expression', {}, True, None, False, ''),
])
class tokens:
AND = "AND"
OR = "OR"
NAND = "NAND"
NOR = "NOR"
XOR = "XOR"
XNOR = "XNOR"
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = {"a", "b", "operator", "_setting_locked", "_batchedReadAttributes", "_batchedReadValues"}
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = [self._attributes.a, self._attributes.b, self._attributes.operator]
self._batchedReadValues = [False, False, "AND"]
@property
def a(self):
return self._batchedReadValues[0]
@a.setter
def a(self, value):
self._batchedReadValues[0] = value
@property
def b(self):
return self._batchedReadValues[1]
@b.setter
def b(self, value):
self._batchedReadValues[1] = value
@property
def operator(self):
return self._batchedReadValues[2]
@operator.setter
def operator(self, value):
self._batchedReadValues[2] = value
def __getattr__(self, item: str):
if item in self.LOCAL_PROPERTY_NAMES:
return object.__getattribute__(self, item)
else:
return super().__getattr__(item)
def __setattr__(self, item: str, new_value):
if item in self.LOCAL_PROPERTY_NAMES:
object.__setattr__(self, item, new_value)
else:
super().__setattr__(item, new_value)
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = {"result", "_batchedWriteValues"}
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedWriteValues = { }
@property
def result(self):
value = self._batchedWriteValues.get(self._attributes.result)
if value:
return value
else:
data_view = og.AttributeValueHelper(self._attributes.result)
return data_view.get()
@result.setter
def result(self, value):
self._batchedWriteValues[self._attributes.result] = value
def __getattr__(self, item: str):
if item in self.LOCAL_PROPERTY_NAMES:
return object.__getattribute__(self, item)
else:
return super().__getattr__(item)
def __setattr__(self, item: str, new_value):
if item in self.LOCAL_PROPERTY_NAMES:
object.__setattr__(self, item, new_value)
else:
super().__setattr__(item, new_value)
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnBooleanExprDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnBooleanExprDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnBooleanExprDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
class abi:
"""Class defining the ABI interface for the node type"""
@staticmethod
def get_node_type():
get_node_type_function = getattr(OgnBooleanExprDatabase.NODE_TYPE_CLASS, 'get_node_type', None)
if callable(get_node_type_function):
return get_node_type_function()
return 'omni.graph.nodes.BooleanExpr'
@staticmethod
def compute(context, node):
def database_valid():
return True
try:
per_node_data = OgnBooleanExprDatabase.PER_NODE_DATA[node.node_id()]
db = per_node_data.get('_db')
if db is None:
db = OgnBooleanExprDatabase(node)
per_node_data['_db'] = db
if not database_valid():
per_node_data['_db'] = None
return False
except:
db = OgnBooleanExprDatabase(node)
try:
compute_function = getattr(OgnBooleanExprDatabase.NODE_TYPE_CLASS, 'compute', None)
if callable(compute_function) and compute_function.__code__.co_argcount > 1:
return compute_function(context, node)
db.inputs._prefetch()
db.inputs._setting_locked = True
with og.in_compute():
return OgnBooleanExprDatabase.NODE_TYPE_CLASS.compute(db)
except Exception as error:
stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next))
db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False)
finally:
db.inputs._setting_locked = False
db.outputs._commit()
return False
@staticmethod
def initialize(context, node):
OgnBooleanExprDatabase._initialize_per_node_data(node)
initialize_function = getattr(OgnBooleanExprDatabase.NODE_TYPE_CLASS, 'initialize', None)
if callable(initialize_function):
initialize_function(context, node)
per_node_data = OgnBooleanExprDatabase.PER_NODE_DATA[node.node_id()]
def on_connection_or_disconnection(*args):
per_node_data['_db'] = None
node.register_on_connected_callback(on_connection_or_disconnection)
node.register_on_disconnected_callback(on_connection_or_disconnection)
@staticmethod
def release(node):
release_function = getattr(OgnBooleanExprDatabase.NODE_TYPE_CLASS, 'release', None)
if callable(release_function):
release_function(node)
OgnBooleanExprDatabase._release_per_node_data(node)
@staticmethod
def release_instance(node, target):
OgnBooleanExprDatabase._release_per_node_instance_data(node, target)
@staticmethod
def update_node_version(context, node, old_version, new_version):
update_node_version_function = getattr(OgnBooleanExprDatabase.NODE_TYPE_CLASS, 'update_node_version', None)
if callable(update_node_version_function):
return update_node_version_function(context, node, old_version, new_version)
return False
@staticmethod
def initialize_type(node_type):
initialize_type_function = getattr(OgnBooleanExprDatabase.NODE_TYPE_CLASS, 'initialize_type', None)
needs_initializing = True
if callable(initialize_type_function):
needs_initializing = initialize_type_function(node_type)
if needs_initializing:
node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.nodes")
node_type.set_metadata(ogn.MetadataKeys.HIDDEN, "true")
node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Boolean Expression")
node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "math:operator")
node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "NOTE: DEPRECATED AS OF 1.26.0 IN FAVOUR OF INDIVIDAL BOOLEAN OP NODES Boolean operation on two inputs. The supported operations are:\n AND, OR, NAND, NOR, XOR, XNOR")
node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python")
OgnBooleanExprDatabase.INTERFACE.add_to_node_type(node_type)
@staticmethod
def on_connection_type_resolve(node):
on_connection_type_resolve_function = getattr(OgnBooleanExprDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None)
if callable(on_connection_type_resolve_function):
on_connection_type_resolve_function(node)
NODE_TYPE_CLASS = None
@staticmethod
def register(node_type_class):
OgnBooleanExprDatabase.NODE_TYPE_CLASS = node_type_class
og.register_node_type(OgnBooleanExprDatabase.abi, 1)
@staticmethod
def deregister():
og.deregister_node_type("omni.graph.nodes.BooleanExpr")
| 12,296 | Python | 43.075269 | 369 | 0.62069 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnWritePrimsDatabase.py | """Support for simplified access to data on nodes of type omni.graph.nodes.WritePrims
DEPRECATED - use WritePrimsV2!
"""
import carb
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnWritePrimsDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.nodes.WritePrims
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.attrNamesToExport
inputs.execIn
inputs.pathPattern
inputs.primsBundle
inputs.typePattern
inputs.usdWriteBack
Outputs:
outputs.execOut
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:attrNamesToExport', 'string', 0, 'Attribute Name Pattern', "A list of wildcard patterns used to match primitive attributes by name.\n\nSupported syntax of wildcard pattern:\n `*` - match an arbitrary number of any characters\n `?` - match any single character\n `^` - (caret) is used to define a pattern that is to be excluded\n\nExample of wildcard patterns, input: ['xFormOp:translate', 'xformOp:scale','radius']\n '*' - match any\n 'xformOp:*' - matches 'xFormOp:translate' and 'xformOp:scale'\n '* ^radius' - match any, but exclude 'radius'\n '* ^xformOp*' - match any, but exclude 'xFormOp:translate', 'xformOp:scale'", {ogn.MetadataKeys.DEFAULT: '"*"'}, True, "*", False, ''),
('inputs:execIn', 'execution', 0, None, 'The input execution (for action graphs only)', {}, True, None, False, ''),
('inputs:pathPattern', 'string', 0, 'Prim Path Pattern', "A list of wildcard patterns used to match primitives by path.\n\nSupported syntax of wildcard pattern:\n `*` - match an arbitrary number of any characters\n `?` - match any single character\n `^` - (caret) is used to define a pattern that is to be excluded\n\nExample of wildcard patterns, input: ['/Cube0', '/Cube1', '/Box']\n '*' - match any\n '* ^/Box' - match any, but exclude '/Box'\n '* ^/Cube*' - match any, but exclude '/Cube0' and '/Cube1'", {ogn.MetadataKeys.DEFAULT: '"*"'}, True, "*", False, ''),
('inputs:primsBundle', 'bundle', 0, 'Prims Bundle', 'The bundle(s) of multiple prims to be written back.\nThe sourcePrimPath attribute is used to find the destination prim.', {ogn.MetadataKeys.ALLOW_MULTI_INPUTS: '1'}, True, None, False, ''),
('inputs:typePattern', 'string', 0, 'Prim Type Pattern', "A list of wildcard patterns used to match primitives by type.\n\nSupported syntax of wildcard pattern:\n `*` - match an arbitrary number of any characters\n `?` - match any single character\n `^` - (caret) is used to define a pattern that is to be excluded\n\nExample of wildcard patterns, input: ['Mesh', 'Cone', 'Cube']\n '*' - match any\n '* ^Mesh' - match any, but exclude 'Mesh'\n '* ^Cone ^Cube' - match any, but exclude 'Cone' and 'Cube'", {ogn.MetadataKeys.DEFAULT: '"*"'}, True, "*", False, ''),
('inputs:usdWriteBack', 'bool', 0, 'Persist To USD', 'Whether or not the value should be written back to USD, or kept a Fabric only value', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''),
('outputs:execOut', 'execution', 0, None, 'The output execution port (for action graphs only)', {}, True, None, False, ''),
])
@classmethod
def _populate_role_data(cls):
"""Populate a role structure with the non-default roles on this node type"""
role_data = super()._populate_role_data()
role_data.inputs.attrNamesToExport = og.AttributeRole.TEXT
role_data.inputs.execIn = og.AttributeRole.EXECUTION
role_data.inputs.pathPattern = og.AttributeRole.TEXT
role_data.inputs.primsBundle = og.AttributeRole.BUNDLE
role_data.inputs.typePattern = og.AttributeRole.TEXT
role_data.outputs.execOut = og.AttributeRole.EXECUTION
return role_data
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self.__bundles = og.BundleContainer(context, node, attributes, [], read_only=True, gpu_ptr_kinds={})
self._batchedReadAttributes = []
self._batchedReadValues = []
@property
def attrNamesToExport(self):
data_view = og.AttributeValueHelper(self._attributes.attrNamesToExport)
return data_view.get()
@attrNamesToExport.setter
def attrNamesToExport(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.attrNamesToExport)
data_view = og.AttributeValueHelper(self._attributes.attrNamesToExport)
data_view.set(value)
self.attrNamesToExport_size = data_view.get_array_size()
@property
def execIn(self):
data_view = og.AttributeValueHelper(self._attributes.execIn)
return data_view.get()
@execIn.setter
def execIn(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.execIn)
data_view = og.AttributeValueHelper(self._attributes.execIn)
data_view.set(value)
@property
def pathPattern(self):
data_view = og.AttributeValueHelper(self._attributes.pathPattern)
return data_view.get()
@pathPattern.setter
def pathPattern(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.pathPattern)
data_view = og.AttributeValueHelper(self._attributes.pathPattern)
data_view.set(value)
self.pathPattern_size = data_view.get_array_size()
@property
def primsBundle(self) -> og.BundleContents:
"""Get the bundle wrapper class for the attribute inputs.primsBundle"""
return self.__bundles.primsBundle
@property
def typePattern(self):
data_view = og.AttributeValueHelper(self._attributes.typePattern)
return data_view.get()
@typePattern.setter
def typePattern(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.typePattern)
data_view = og.AttributeValueHelper(self._attributes.typePattern)
data_view.set(value)
self.typePattern_size = data_view.get_array_size()
@property
def usdWriteBack(self):
data_view = og.AttributeValueHelper(self._attributes.usdWriteBack)
return data_view.get()
@usdWriteBack.setter
def usdWriteBack(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.usdWriteBack)
data_view = og.AttributeValueHelper(self._attributes.usdWriteBack)
data_view.set(value)
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedWriteValues = { }
@property
def execOut(self):
data_view = og.AttributeValueHelper(self._attributes.execOut)
return data_view.get()
@execOut.setter
def execOut(self, value):
data_view = og.AttributeValueHelper(self._attributes.execOut)
data_view.set(value)
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnWritePrimsDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnWritePrimsDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnWritePrimsDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
| 10,478 | Python | 54.444444 | 720 | 0.657091 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnSelectIfDatabase.py | """Support for simplified access to data on nodes of type omni.graph.nodes.SelectIf
Selects an output from the given inputs based on a boolean condition. If the condition is an array, and the inputs are arrays
of equal length, and values will be selected from ifTrue, ifFalse depending on the bool at the same index. If one input is
an array and the other is a scaler of the same base type, the scaler will be extended to the length of the other input.
"""
from typing import Any
import carb
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnSelectIfDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.nodes.SelectIf
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.condition
inputs.ifFalse
inputs.ifTrue
Outputs:
outputs.result
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:condition', 'bool,bool[]', 1, None, 'The selection variable', {}, True, None, False, ''),
('inputs:ifFalse', 'any', 2, 'If False', 'Value if condition is False', {}, True, None, False, ''),
('inputs:ifTrue', 'any', 2, 'If True', 'Value if condition is True', {}, True, None, False, ''),
('outputs:result', 'any', 2, 'Result', 'The selected value from ifTrue and ifFalse', {}, True, None, False, ''),
])
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = []
self._batchedReadValues = []
@property
def condition(self) -> og.RuntimeAttribute:
"""Get the runtime wrapper class for the attribute inputs.condition"""
return og.RuntimeAttribute(self._attributes.condition.get_attribute_data(), self._context, True)
@condition.setter
def condition(self, value_to_set: Any):
"""Assign another attribute's value to outputs.condition"""
if isinstance(value_to_set, og.RuntimeAttribute):
self.condition.value = value_to_set.value
else:
self.condition.value = value_to_set
@property
def ifFalse(self) -> og.RuntimeAttribute:
"""Get the runtime wrapper class for the attribute inputs.ifFalse"""
return og.RuntimeAttribute(self._attributes.ifFalse.get_attribute_data(), self._context, True)
@ifFalse.setter
def ifFalse(self, value_to_set: Any):
"""Assign another attribute's value to outputs.ifFalse"""
if isinstance(value_to_set, og.RuntimeAttribute):
self.ifFalse.value = value_to_set.value
else:
self.ifFalse.value = value_to_set
@property
def ifTrue(self) -> og.RuntimeAttribute:
"""Get the runtime wrapper class for the attribute inputs.ifTrue"""
return og.RuntimeAttribute(self._attributes.ifTrue.get_attribute_data(), self._context, True)
@ifTrue.setter
def ifTrue(self, value_to_set: Any):
"""Assign another attribute's value to outputs.ifTrue"""
if isinstance(value_to_set, og.RuntimeAttribute):
self.ifTrue.value = value_to_set.value
else:
self.ifTrue.value = value_to_set
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedWriteValues = { }
@property
def result(self) -> og.RuntimeAttribute:
"""Get the runtime wrapper class for the attribute outputs.result"""
return og.RuntimeAttribute(self._attributes.result.get_attribute_data(), self._context, False)
@result.setter
def result(self, value_to_set: Any):
"""Assign another attribute's value to outputs.result"""
if isinstance(value_to_set, og.RuntimeAttribute):
self.result.value = value_to_set.value
else:
self.result.value = value_to_set
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnSelectIfDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnSelectIfDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnSelectIfDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
| 7,214 | Python | 48.081632 | 125 | 0.657749 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnEaseDatabase.py | """Support for simplified access to data on nodes of type omni.graph.nodes.Ease
Easing function which iterpolates between a start and end value. Vectors are eased component-wise. The easing functions can
be applied to decimal types. Linear: Interpolates between start and finish at a fixed rate. EaseIn: Starts slowly and ends
fast according to an exponential, the slope is determined by the 'exponent' input. EaseOut: Same as EaseIn, but starts fast
and ends slow EaseInOut: Combines EaseIn and EaseOut SinIn: Starts slowly and ends fast according to a sinusoidal curve SinOut:
Same as SinIn, but starts fast and ends slow SinInOut: Combines SinIn and SinOut
"""
from typing import Any
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnEaseDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.nodes.Ease
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.alpha
inputs.blendExponent
inputs.easeFunc
inputs.end
inputs.start
Outputs:
outputs.result
Predefined Tokens:
tokens.EaseIn
tokens.EaseOut
tokens.EaseInOut
tokens.Linear
tokens.SinIn
tokens.SinOut
tokens.SinInOut
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:alpha', 'float,float[]', 1, None, 'The normalized time (0 - 1.0). Values outside this range will be clamped', {}, True, None, False, ''),
('inputs:blendExponent', 'int', 0, None, 'The blend exponent, which is the degree of the ease curve\n (1 = linear, 2 = quadratic, 3 = cubic, etc). \nThis only applies to the Ease* functions', {ogn.MetadataKeys.DEFAULT: '2'}, True, 2, False, ''),
('inputs:easeFunc', 'token', 0, 'Operation', 'The easing function to apply (EaseIn, EaseOut, EaseInOut, Linear, SinIn, SinOut, SinInOut)', {ogn.MetadataKeys.ALLOWED_TOKENS: 'EaseIn,EaseOut,EaseInOut,Linear,SinIn,SinOut,SinInOut', ogn.MetadataKeys.ALLOWED_TOKENS_RAW: '["EaseIn", "EaseOut", "EaseInOut", "Linear", "SinIn", "SinOut", "SinInOut"]', ogn.MetadataKeys.DEFAULT: '"EaseInOut"'}, True, "EaseInOut", False, ''),
('inputs:end', 'colord[3],colord[3][],colord[4],colord[4][],colorf[3],colorf[3][],colorf[4],colorf[4][],colorh[3],colorh[3][],colorh[4],colorh[4][],double,double[2],double[2][],double[3],double[3][],double[4],double[4][],double[],float,float[2],float[2][],float[3],float[3][],float[4],float[4][],float[],half,half[2],half[2][],half[3],half[3][],half[4],half[4][],half[],normald[3],normald[3][],normalf[3],normalf[3][],normalh[3],normalh[3][],pointd[3],pointd[3][],pointf[3],pointf[3][],pointh[3],pointh[3][],quatd[4],quatd[4][],quatf[4],quatf[4][],quath[4],quath[4][],texcoordd[2],texcoordd[2][],texcoordd[3],texcoordd[3][],texcoordf[2],texcoordf[2][],texcoordf[3],texcoordf[3][],texcoordh[2],texcoordh[2][],texcoordh[3],texcoordh[3][],timecode,timecode[],vectord[3],vectord[3][],vectorf[3],vectorf[3][],vectorh[3],vectorh[3][]', 1, None, 'The end value', {}, True, None, False, ''),
('inputs:start', 'colord[3],colord[3][],colord[4],colord[4][],colorf[3],colorf[3][],colorf[4],colorf[4][],colorh[3],colorh[3][],colorh[4],colorh[4][],double,double[2],double[2][],double[3],double[3][],double[4],double[4][],double[],float,float[2],float[2][],float[3],float[3][],float[4],float[4][],float[],half,half[2],half[2][],half[3],half[3][],half[4],half[4][],half[],normald[3],normald[3][],normalf[3],normalf[3][],normalh[3],normalh[3][],pointd[3],pointd[3][],pointf[3],pointf[3][],pointh[3],pointh[3][],quatd[4],quatd[4][],quatf[4],quatf[4][],quath[4],quath[4][],texcoordd[2],texcoordd[2][],texcoordd[3],texcoordd[3][],texcoordf[2],texcoordf[2][],texcoordf[3],texcoordf[3][],texcoordh[2],texcoordh[2][],texcoordh[3],texcoordh[3][],timecode,timecode[],vectord[3],vectord[3][],vectorf[3],vectorf[3][],vectorh[3],vectorh[3][]', 1, None, 'The start value', {}, True, None, False, ''),
('outputs:result', 'colord[3],colord[3][],colord[4],colord[4][],colorf[3],colorf[3][],colorf[4],colorf[4][],colorh[3],colorh[3][],colorh[4],colorh[4][],double,double[2],double[2][],double[3],double[3][],double[4],double[4][],double[],float,float[2],float[2][],float[3],float[3][],float[4],float[4][],float[],half,half[2],half[2][],half[3],half[3][],half[4],half[4][],half[],normald[3],normald[3][],normalf[3],normalf[3][],normalh[3],normalh[3][],pointd[3],pointd[3][],pointf[3],pointf[3][],pointh[3],pointh[3][],quatd[4],quatd[4][],quatf[4],quatf[4][],quath[4],quath[4][],texcoordd[2],texcoordd[2][],texcoordd[3],texcoordd[3][],texcoordf[2],texcoordf[2][],texcoordf[3],texcoordf[3][],texcoordh[2],texcoordh[2][],texcoordh[3],texcoordh[3][],timecode,timecode[],vectord[3],vectord[3][],vectorf[3],vectorf[3][],vectorh[3],vectorh[3][]', 1, 'Result', 'The eased result of the function applied to value', {}, True, None, False, ''),
])
class tokens:
EaseIn = "EaseIn"
EaseOut = "EaseOut"
EaseInOut = "EaseInOut"
Linear = "Linear"
SinIn = "SinIn"
SinOut = "SinOut"
SinInOut = "SinInOut"
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = []
self._batchedReadValues = []
@property
def alpha(self) -> og.RuntimeAttribute:
"""Get the runtime wrapper class for the attribute inputs.alpha"""
return og.RuntimeAttribute(self._attributes.alpha.get_attribute_data(), self._context, True)
@alpha.setter
def alpha(self, value_to_set: Any):
"""Assign another attribute's value to outputs.alpha"""
if isinstance(value_to_set, og.RuntimeAttribute):
self.alpha.value = value_to_set.value
else:
self.alpha.value = value_to_set
@property
def blendExponent(self):
data_view = og.AttributeValueHelper(self._attributes.blendExponent)
return data_view.get()
@blendExponent.setter
def blendExponent(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.blendExponent)
data_view = og.AttributeValueHelper(self._attributes.blendExponent)
data_view.set(value)
@property
def easeFunc(self):
data_view = og.AttributeValueHelper(self._attributes.easeFunc)
return data_view.get()
@easeFunc.setter
def easeFunc(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.easeFunc)
data_view = og.AttributeValueHelper(self._attributes.easeFunc)
data_view.set(value)
@property
def end(self) -> og.RuntimeAttribute:
"""Get the runtime wrapper class for the attribute inputs.end"""
return og.RuntimeAttribute(self._attributes.end.get_attribute_data(), self._context, True)
@end.setter
def end(self, value_to_set: Any):
"""Assign another attribute's value to outputs.end"""
if isinstance(value_to_set, og.RuntimeAttribute):
self.end.value = value_to_set.value
else:
self.end.value = value_to_set
@property
def start(self) -> og.RuntimeAttribute:
"""Get the runtime wrapper class for the attribute inputs.start"""
return og.RuntimeAttribute(self._attributes.start.get_attribute_data(), self._context, True)
@start.setter
def start(self, value_to_set: Any):
"""Assign another attribute's value to outputs.start"""
if isinstance(value_to_set, og.RuntimeAttribute):
self.start.value = value_to_set.value
else:
self.start.value = value_to_set
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedWriteValues = { }
@property
def result(self) -> og.RuntimeAttribute:
"""Get the runtime wrapper class for the attribute outputs.result"""
return og.RuntimeAttribute(self._attributes.result.get_attribute_data(), self._context, False)
@result.setter
def result(self, value_to_set: Any):
"""Assign another attribute's value to outputs.result"""
if isinstance(value_to_set, og.RuntimeAttribute):
self.result.value = value_to_set.value
else:
self.result.value = value_to_set
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnEaseDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnEaseDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnEaseDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
| 11,770 | Python | 59.675257 | 935 | 0.650382 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnConcatenateFloat3ArraysDatabase.py | """Support for simplified access to data on nodes of type omni.graph.nodes.ConcatenateFloat3Arrays
Flatten the array of float3 arrays in 'inputArrays' by concatenating all of the array contents into a single float3 array
in 'outputArray'. The sizes of each of the input arrays is preserved in the output 'arraySizes'.
"""
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
import numpy
from typing import Any
class OgnConcatenateFloat3ArraysDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.nodes.ConcatenateFloat3Arrays
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.inputArrays
Outputs:
outputs.arraySizes
outputs.outputArray
"""
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:inputArrays', 'any', 2, None, 'Array of arrays of float3 values to be flattened', {}, True, None, False, ''),
('outputs:arraySizes', 'int[]', 0, None, 'List of sizes of each of the float3 input arrays', {}, True, None, False, ''),
('outputs:outputArray', 'float3[]', 0, None, 'Flattened array of float3 values', {}, True, None, False, ''),
])
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = []
self._batchedReadValues = []
@property
def inputArrays(self) -> og.RuntimeAttribute:
"""Get the runtime wrapper class for the attribute inputs.inputArrays"""
return og.RuntimeAttribute(self._attributes.inputArrays.get_attribute_data(), self._context, True)
@inputArrays.setter
def inputArrays(self, value_to_set: Any):
"""Assign another attribute's value to outputs.inputArrays"""
if isinstance(value_to_set, og.RuntimeAttribute):
self.inputArrays.value = value_to_set.value
else:
self.inputArrays.value = value_to_set
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self.arraySizes_size = None
self.outputArray_size = None
self._batchedWriteValues = { }
@property
def arraySizes(self):
data_view = og.AttributeValueHelper(self._attributes.arraySizes)
return data_view.get(reserved_element_count=self.arraySizes_size)
@arraySizes.setter
def arraySizes(self, value):
data_view = og.AttributeValueHelper(self._attributes.arraySizes)
data_view.set(value)
self.arraySizes_size = data_view.get_array_size()
@property
def outputArray(self):
data_view = og.AttributeValueHelper(self._attributes.outputArray)
return data_view.get(reserved_element_count=self.outputArray_size)
@outputArray.setter
def outputArray(self, value):
data_view = og.AttributeValueHelper(self._attributes.outputArray)
data_view.set(value)
self.outputArray_size = data_view.get_array_size()
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnConcatenateFloat3ArraysDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnConcatenateFloat3ArraysDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnConcatenateFloat3ArraysDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
| 6,159 | Python | 52.565217 | 128 | 0.67722 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnGetPrimRelationshipDatabase.py | """Support for simplified access to data on nodes of type omni.graph.nodes.GetPrimRelationship
DEPRECATED - Use ReadPrimRelationship!
"""
import numpy
import usdrt
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnGetPrimRelationshipDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.nodes.GetPrimRelationship
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.name
inputs.path
inputs.prim
inputs.usePath
Outputs:
outputs.paths
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:name', 'token', 0, 'Relationship Name', 'Name of the relationship property', {}, True, "", False, ''),
('inputs:path', 'token', 0, 'Prim Path', 'Path of the prim with the relationship property', {}, False, None, True, 'Use prim input with a GetPrimsAtPath node instead'),
('inputs:prim', 'target', 0, None, 'The prim with the relationship', {}, False, [], False, ''),
('inputs:usePath', 'bool', 0, None, "When true, the 'path' attribute is used, otherwise it will read the connection at the 'prim' attribute.", {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, True, 'Use prim input with a GetPrimsAtPath node instead'),
('outputs:paths', 'token[]', 0, 'Paths', 'The prim paths for the given relationship', {}, True, None, False, ''),
])
@classmethod
def _populate_role_data(cls):
"""Populate a role structure with the non-default roles on this node type"""
role_data = super()._populate_role_data()
role_data.inputs.prim = og.AttributeRole.TARGET
return role_data
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = []
self._batchedReadValues = []
@property
def name(self):
data_view = og.AttributeValueHelper(self._attributes.name)
return data_view.get()
@name.setter
def name(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.name)
data_view = og.AttributeValueHelper(self._attributes.name)
data_view.set(value)
@property
def path(self):
data_view = og.AttributeValueHelper(self._attributes.path)
return data_view.get()
@path.setter
def path(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.path)
data_view = og.AttributeValueHelper(self._attributes.path)
data_view.set(value)
@property
def prim(self):
data_view = og.AttributeValueHelper(self._attributes.prim)
return data_view.get()
@prim.setter
def prim(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.prim)
data_view = og.AttributeValueHelper(self._attributes.prim)
data_view.set(value)
self.prim_size = data_view.get_array_size()
@property
def usePath(self):
data_view = og.AttributeValueHelper(self._attributes.usePath)
return data_view.get()
@usePath.setter
def usePath(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.usePath)
data_view = og.AttributeValueHelper(self._attributes.usePath)
data_view.set(value)
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self.paths_size = None
self._batchedWriteValues = { }
@property
def paths(self):
data_view = og.AttributeValueHelper(self._attributes.paths)
return data_view.get(reserved_element_count=self.paths_size)
@paths.setter
def paths(self, value):
data_view = og.AttributeValueHelper(self._attributes.paths)
data_view.set(value)
self.paths_size = data_view.get_array_size()
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnGetPrimRelationshipDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnGetPrimRelationshipDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnGetPrimRelationshipDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
| 7,365 | Python | 44.190184 | 260 | 0.650373 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnReadTimeDatabase.py | """Support for simplified access to data on nodes of type omni.graph.nodes.ReadTime
Holds the values related to the current global time and the timeline
"""
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnReadTimeDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.nodes.ReadTime
Class Members:
node: Node being evaluated
Attribute Value Properties:
Outputs:
outputs.absoluteSimTime
outputs.deltaSeconds
outputs.frame
outputs.isPlaying
outputs.time
outputs.timeSinceStart
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('outputs:absoluteSimTime', 'double', 0, 'Absolute Simulation Time (Seconds)', 'The accumulated total of elapsed times between rendered frames', {}, True, None, False, ''),
('outputs:deltaSeconds', 'double', 0, 'Delta (Seconds)', 'The number of seconds elapsed since the last OmniGraph update', {}, True, None, False, ''),
('outputs:frame', 'double', 0, 'Animation Time (Frames)', 'The global animation time in frames, equivalent to (time * fps), during playback', {}, True, None, False, ''),
('outputs:isPlaying', 'bool', 0, 'Is Playing', 'True during global animation timeline playback', {}, True, None, False, ''),
('outputs:time', 'double', 0, 'Animation Time (Seconds)', 'The global animation time in seconds during playback', {}, True, None, False, ''),
('outputs:timeSinceStart', 'double', 0, 'Time Since Start (Seconds)', 'Elapsed time since the App started', {}, True, None, False, ''),
])
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = []
self._batchedReadValues = []
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedWriteValues = { }
@property
def absoluteSimTime(self):
data_view = og.AttributeValueHelper(self._attributes.absoluteSimTime)
return data_view.get()
@absoluteSimTime.setter
def absoluteSimTime(self, value):
data_view = og.AttributeValueHelper(self._attributes.absoluteSimTime)
data_view.set(value)
@property
def deltaSeconds(self):
data_view = og.AttributeValueHelper(self._attributes.deltaSeconds)
return data_view.get()
@deltaSeconds.setter
def deltaSeconds(self, value):
data_view = og.AttributeValueHelper(self._attributes.deltaSeconds)
data_view.set(value)
@property
def frame(self):
data_view = og.AttributeValueHelper(self._attributes.frame)
return data_view.get()
@frame.setter
def frame(self, value):
data_view = og.AttributeValueHelper(self._attributes.frame)
data_view.set(value)
@property
def isPlaying(self):
data_view = og.AttributeValueHelper(self._attributes.isPlaying)
return data_view.get()
@isPlaying.setter
def isPlaying(self, value):
data_view = og.AttributeValueHelper(self._attributes.isPlaying)
data_view.set(value)
@property
def time(self):
data_view = og.AttributeValueHelper(self._attributes.time)
return data_view.get()
@time.setter
def time(self, value):
data_view = og.AttributeValueHelper(self._attributes.time)
data_view.set(value)
@property
def timeSinceStart(self):
data_view = og.AttributeValueHelper(self._attributes.timeSinceStart)
return data_view.get()
@timeSinceStart.setter
def timeSinceStart(self, value):
data_view = og.AttributeValueHelper(self._attributes.timeSinceStart)
data_view.set(value)
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnReadTimeDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnReadTimeDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnReadTimeDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
| 7,115 | Python | 45.207792 | 180 | 0.65889 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnRpResourceExampleAllocatorDatabase.py | """Support for simplified access to data on nodes of type omni.graph.nodes.RpResourceExampleAllocator
Allocate CUDA-interoperable RpResource
"""
import numpy
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnRpResourceExampleAllocatorDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.nodes.RpResourceExampleAllocator
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.points
inputs.primPath
inputs.reload
inputs.stream
inputs.verbose
Outputs:
outputs.pointCountCollection
outputs.primPathCollection
outputs.reload
outputs.resourcePointerCollection
outputs.stream
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:points', 'float3[]', 0, 'Prim Points', 'Points attribute input. Points and a prim path may be supplied directly as an alternative to a bundle input.', {}, True, [], False, ''),
('inputs:primPath', 'token', 0, 'Prim path input', 'Prim path input. Points and a prim path may be supplied directly as an alternative to a bundle input.', {}, True, "", False, ''),
('inputs:reload', 'bool', 0, 'Reload', 'Force RpResource reload', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''),
('inputs:stream', 'uint64', 0, 'stream', 'Pointer to the CUDA Stream', {}, True, 0, False, ''),
('inputs:verbose', 'bool', 0, 'Verbose', 'verbose printing', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''),
('outputs:pointCountCollection', 'uint64[]', 0, 'Point Counts', 'Point count for each prim being deformed', {}, True, None, False, ''),
('outputs:primPathCollection', 'token[]', 0, 'Prim Paths', 'Path for each prim being deformed', {}, True, None, False, ''),
('outputs:reload', 'bool', 0, 'Reload', 'Force RpResource reload', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''),
('outputs:resourcePointerCollection', 'uint64[]', 0, 'Resource Pointer Collection', 'Pointers to RpResources \n(two resources per prim are allocated -- one for rest positions and one for deformed positions)', {}, True, None, False, ''),
('outputs:stream', 'uint64', 0, 'stream', 'Pointer to the CUDA Stream', {}, True, None, False, ''),
])
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = []
self._batchedReadValues = []
@property
def points(self):
data_view = og.AttributeValueHelper(self._attributes.points)
return data_view.get()
@points.setter
def points(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.points)
data_view = og.AttributeValueHelper(self._attributes.points)
data_view.set(value)
self.points_size = data_view.get_array_size()
@property
def primPath(self):
data_view = og.AttributeValueHelper(self._attributes.primPath)
return data_view.get()
@primPath.setter
def primPath(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.primPath)
data_view = og.AttributeValueHelper(self._attributes.primPath)
data_view.set(value)
@property
def reload(self):
data_view = og.AttributeValueHelper(self._attributes.reload)
return data_view.get()
@reload.setter
def reload(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.reload)
data_view = og.AttributeValueHelper(self._attributes.reload)
data_view.set(value)
@property
def stream(self):
data_view = og.AttributeValueHelper(self._attributes.stream)
return data_view.get()
@stream.setter
def stream(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.stream)
data_view = og.AttributeValueHelper(self._attributes.stream)
data_view.set(value)
@property
def verbose(self):
data_view = og.AttributeValueHelper(self._attributes.verbose)
return data_view.get()
@verbose.setter
def verbose(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.verbose)
data_view = og.AttributeValueHelper(self._attributes.verbose)
data_view.set(value)
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self.pointCountCollection_size = None
self.primPathCollection_size = None
self.resourcePointerCollection_size = None
self._batchedWriteValues = { }
@property
def pointCountCollection(self):
data_view = og.AttributeValueHelper(self._attributes.pointCountCollection)
return data_view.get(reserved_element_count=self.pointCountCollection_size)
@pointCountCollection.setter
def pointCountCollection(self, value):
data_view = og.AttributeValueHelper(self._attributes.pointCountCollection)
data_view.set(value)
self.pointCountCollection_size = data_view.get_array_size()
@property
def primPathCollection(self):
data_view = og.AttributeValueHelper(self._attributes.primPathCollection)
return data_view.get(reserved_element_count=self.primPathCollection_size)
@primPathCollection.setter
def primPathCollection(self, value):
data_view = og.AttributeValueHelper(self._attributes.primPathCollection)
data_view.set(value)
self.primPathCollection_size = data_view.get_array_size()
@property
def reload(self):
data_view = og.AttributeValueHelper(self._attributes.reload)
return data_view.get()
@reload.setter
def reload(self, value):
data_view = og.AttributeValueHelper(self._attributes.reload)
data_view.set(value)
@property
def resourcePointerCollection(self):
data_view = og.AttributeValueHelper(self._attributes.resourcePointerCollection)
return data_view.get(reserved_element_count=self.resourcePointerCollection_size)
@resourcePointerCollection.setter
def resourcePointerCollection(self, value):
data_view = og.AttributeValueHelper(self._attributes.resourcePointerCollection)
data_view.set(value)
self.resourcePointerCollection_size = data_view.get_array_size()
@property
def stream(self):
data_view = og.AttributeValueHelper(self._attributes.stream)
return data_view.get()
@stream.setter
def stream(self, value):
data_view = og.AttributeValueHelper(self._attributes.stream)
data_view.set(value)
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnRpResourceExampleAllocatorDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnRpResourceExampleAllocatorDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnRpResourceExampleAllocatorDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
| 10,416 | Python | 46.135746 | 244 | 0.65313 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnInsertAttrDatabase.py | """Support for simplified access to data on nodes of type omni.graph.nodes.InsertAttribute
Copies all attributes from an input bundle to the output bundle, as well as copying an additional 'attrToInsert' attribute
from the node itself with a specified name.
"""
from typing import Any
import carb
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnInsertAttrDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.nodes.InsertAttribute
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.attrToInsert
inputs.data
inputs.outputAttrName
Outputs:
outputs.data
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:attrToInsert', 'any', 2, 'Attribute To Insert', 'The the attribute to be copied from the node to the output bundle', {}, True, None, False, ''),
('inputs:data', 'bundle', 0, 'Original Bundle', 'Initial bundle of attributes', {}, True, None, False, ''),
('inputs:outputAttrName', 'token', 0, 'Attribute Name', 'The name of the new output attribute in the bundle', {ogn.MetadataKeys.DEFAULT: '"attr0"'}, True, "attr0", False, ''),
('outputs:data', 'bundle', 0, 'Bundle With Inserted Attribute', 'Bundle of input attributes with the new one inserted with the specified name', {}, True, None, False, ''),
])
@classmethod
def _populate_role_data(cls):
"""Populate a role structure with the non-default roles on this node type"""
role_data = super()._populate_role_data()
role_data.inputs.data = og.AttributeRole.BUNDLE
role_data.outputs.data = og.AttributeRole.BUNDLE
return role_data
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self.__bundles = og.BundleContainer(context, node, attributes, [], read_only=True, gpu_ptr_kinds={})
self._batchedReadAttributes = []
self._batchedReadValues = []
@property
def attrToInsert(self) -> og.RuntimeAttribute:
"""Get the runtime wrapper class for the attribute inputs.attrToInsert"""
return og.RuntimeAttribute(self._attributes.attrToInsert.get_attribute_data(), self._context, True)
@attrToInsert.setter
def attrToInsert(self, value_to_set: Any):
"""Assign another attribute's value to outputs.attrToInsert"""
if isinstance(value_to_set, og.RuntimeAttribute):
self.attrToInsert.value = value_to_set.value
else:
self.attrToInsert.value = value_to_set
@property
def data(self) -> og.BundleContents:
"""Get the bundle wrapper class for the attribute inputs.data"""
return self.__bundles.data
@property
def outputAttrName(self):
data_view = og.AttributeValueHelper(self._attributes.outputAttrName)
return data_view.get()
@outputAttrName.setter
def outputAttrName(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.outputAttrName)
data_view = og.AttributeValueHelper(self._attributes.outputAttrName)
data_view.set(value)
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self.__bundles = og.BundleContainer(context, node, attributes, [], read_only=False, gpu_ptr_kinds={})
self._batchedWriteValues = { }
@property
def data(self) -> og.BundleContents:
"""Get the bundle wrapper class for the attribute outputs.data"""
return self.__bundles.data
@data.setter
def data(self, bundle: og.BundleContents):
"""Overwrite the bundle attribute outputs.data with a new bundle"""
if not isinstance(bundle, og.BundleContents):
carb.log_error("Only bundle attributes can be assigned to another bundle attribute")
self.__bundles.data.bundle = bundle
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnInsertAttrDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnInsertAttrDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnInsertAttrDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
| 7,265 | Python | 48.767123 | 183 | 0.667447 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnSetGatheredAttributeDatabase.py | """Support for simplified access to data on nodes of type omni.graph.nodes.SetGatheredAttribute
Writes a value into the given Gathered attribute. If the number elements of the value is less than the gathered attribute,
the value will be broadcast to all prims. If the given value has more elements than the gathered attribute, an error will
be produced. PROTOTYPE DO NOT USE, Requires GatherPrototype
"""
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
import numpy
from typing import Any
class OgnSetGatheredAttributeDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.nodes.SetGatheredAttribute
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.execIn
inputs.gatherId
inputs.mask
inputs.name
inputs.value
Outputs:
outputs.execOut
"""
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:execIn', 'execution', 0, None, 'Input execution state', {}, True, None, False, ''),
('inputs:gatherId', 'uint64', 0, None, 'The GatherId of the gathered prims', {}, True, 0, False, ''),
('inputs:mask', 'bool[]', 0, None, 'Only writes values to the indexes which are true.', {}, False, None, False, ''),
('inputs:name', 'token', 0, None, 'The name of the attribute to set in the given Gather', {}, True, '', False, ''),
('inputs:value', 'any', 2, None, 'The new value to be written to the gathered attributes', {}, True, None, False, ''),
('outputs:execOut', 'execution', 0, None, 'Output execution', {}, True, None, False, ''),
])
@classmethod
def _populate_role_data(cls):
"""Populate a role structure with the non-default roles on this node type"""
role_data = super()._populate_role_data()
role_data.inputs.execIn = og.Database.ROLE_EXECUTION
role_data.outputs.execOut = og.Database.ROLE_EXECUTION
return role_data
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = {"execIn", "gatherId", "name", "_setting_locked", "_batchedReadAttributes", "_batchedReadValues"}
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = [self._attributes.execIn, self._attributes.gatherId, self._attributes.name]
self._batchedReadValues = [None, 0, ""]
@property
def mask(self):
data_view = og.AttributeValueHelper(self._attributes.mask)
return data_view.get()
@mask.setter
def mask(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.mask)
data_view = og.AttributeValueHelper(self._attributes.mask)
data_view.set(value)
self.mask_size = data_view.get_array_size()
@property
def value(self) -> og.RuntimeAttribute:
"""Get the runtime wrapper class for the attribute inputs.value"""
return og.RuntimeAttribute(self._attributes.value.get_attribute_data(), self._context, True)
@value.setter
def value(self, value_to_set: Any):
"""Assign another attribute's value to outputs.value"""
if isinstance(value_to_set, og.RuntimeAttribute):
self.value.value = value_to_set.value
else:
self.value.value = value_to_set
@property
def execIn(self):
return self._batchedReadValues[0]
@execIn.setter
def execIn(self, value):
self._batchedReadValues[0] = value
@property
def gatherId(self):
return self._batchedReadValues[1]
@gatherId.setter
def gatherId(self, value):
self._batchedReadValues[1] = value
@property
def name(self):
return self._batchedReadValues[2]
@name.setter
def name(self, value):
self._batchedReadValues[2] = value
def __getattr__(self, item: str):
if item in self.LOCAL_PROPERTY_NAMES:
return object.__getattribute__(self, item)
else:
return super().__getattr__(item)
def __setattr__(self, item: str, new_value):
if item in self.LOCAL_PROPERTY_NAMES:
object.__setattr__(self, item, new_value)
else:
super().__setattr__(item, new_value)
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = {"execOut", "_batchedWriteValues"}
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedWriteValues = { }
@property
def execOut(self):
value = self._batchedWriteValues.get(self._attributes.execOut)
if value:
return value
else:
data_view = og.AttributeValueHelper(self._attributes.execOut)
return data_view.get()
@execOut.setter
def execOut(self, value):
self._batchedWriteValues[self._attributes.execOut] = value
def __getattr__(self, item: str):
if item in self.LOCAL_PROPERTY_NAMES:
return object.__getattribute__(self, item)
else:
return super().__getattr__(item)
def __setattr__(self, item: str, new_value):
if item in self.LOCAL_PROPERTY_NAMES:
object.__setattr__(self, item, new_value)
else:
super().__setattr__(item, new_value)
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnSetGatheredAttributeDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnSetGatheredAttributeDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnSetGatheredAttributeDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
| 8,511 | Python | 46.553072 | 128 | 0.636118 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnReadPrimsV2Database.py | """Support for simplified access to data on nodes of type omni.graph.nodes.ReadPrimsV2
Reads primitives and outputs multiple primitive in a bundle.
"""
import usdrt
import carb
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnReadPrimsV2Database(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.nodes.ReadPrimsV2
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs._debugStamp
inputs.applySkelBinding
inputs.attrNamesToImport
inputs.computeBoundingBox
inputs.enableBundleChangeTracking
inputs.enableChangeTracking
inputs.pathPattern
inputs.prims
inputs.typePattern
inputs.usdTimecode
Outputs:
outputs.primsBundle
State:
state.applySkelBinding
state.attrNamesToImport
state.computeBoundingBox
state.enableBundleChangeTracking
state.enableChangeTracking
state.pathPattern
state.typePattern
state.usdTimecode
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:_debugStamp', 'int', 0, None, 'For internal testing only, and subject to change. Please do not depend on this attribute!\nWhen not zero, this _debugStamp attribute will be copied to root and child bundles that change\nWhen a full update is performed, the negative _debugStamp is written.\nWhen only derived attributes (like bounding boxes and world matrices) are updated, _debugStamp + 1000000 is written', {ogn.MetadataKeys.LITERAL_ONLY: '1', ogn.MetadataKeys.HIDDEN: 'true', ogn.MetadataKeys.DEFAULT: '0'}, True, 0, False, ''),
('inputs:applySkelBinding', 'bool', 0, 'Apply Skel Binding', 'If an input USD prim is skinnable and has the SkelBindingAPI schema applied, read skeletal data and apply SkelBinding to deform the prim.\nThe output bundle will have additional child bundles created to hold data for the skeleton and skel animation prims if present. After\nevaluation, deformed points and normals will be written to the `points` and `normals` attributes, while non-deformed points and normals\nwill be copied to the `points:default` and `normals:default` attributes.', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''),
('inputs:attrNamesToImport', 'string', 0, 'Attribute Name Pattern', "A list of wildcard patterns used to match the attribute names that are to be imported\n\nSupported syntax of wildcard pattern:\n '*' - match an arbitrary number of any characters\n '?' - match any single character\n '^' - (caret) is used to define a pattern that is to be excluded\n\nExample of wildcard patterns, input: ['points', 'faceVertexCount', 'faceVertexIndices', 'size']\n '*' - match any\n '* ^points' - match any, but exclude 'points'\n '* ^face*' - match any, but exclude 'faceVertexCount' and 'faceVertexIndices'", {ogn.MetadataKeys.DEFAULT: '"*"'}, True, "*", False, ''),
('inputs:computeBoundingBox', 'bool', 0, 'Compute Bounding Box', "For each primitive compute local bounding box and store them as 'bboxMinCorner', 'bboxMaxCorner' and 'bboxTransform' attributes.", {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''),
('inputs:enableBundleChangeTracking', 'bool', 0, 'Bundle change tracking', 'Enable change tracking for output bundle, its children and attributes.\nThe change tracking system for bundles has some overhead, but enables\nusers to inspect the changes that occurred in a bundle.\nThrough inspecting the type of changes user can mitigate excessive computations.', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''),
('inputs:enableChangeTracking', 'bool', 0, 'USD change tracking', 'Should the output bundles only be updated when the associated USD prims change?\nThis uses a USD notice handler, and has a small overhead,\nso if you know that the imported USD prims will change frequently,\nyou might want to disable this.', {ogn.MetadataKeys.DEFAULT: 'true'}, True, True, False, ''),
('inputs:pathPattern', 'string', 0, 'Prim Path Pattern', "A list of wildcard patterns used to match the prim paths that are to be imported\n\nSupported syntax of wildcard pattern:\n '*' - match an arbitrary number of any characters\n '?' - match any single character\n '^' - (caret) is used to define a pattern that is to be excluded\n\nExample of wildcard patterns, input: ['/Cube0', '/Cube1', '/Box']\n '*' - match any\n '* ^/Box' - match any, but exclude '/Box'\n '* ^/Cube*' - match any, but exclude '/Cube0' and '/Cube1'", {ogn.MetadataKeys.DEFAULT: '""'}, True, "", False, ''),
('inputs:prims', 'target', 0, 'Prims', 'The root prim(s) that pattern matching uses to search from.\nIf \'pathPattern\' input is empty, the directly connected prims will be read.\nOtherwise, all the subtree (including root) will be tested against pattern matcher inputs,\nand the matched prims will be read into the output bundle.\nIf no prims are connected, and \'pathPattern\' is none empty, absolute root "/" will be searched as root prim.', {ogn.MetadataKeys.ALLOW_MULTI_INPUTS: '1'}, True, [], False, ''),
('inputs:typePattern', 'string', 0, 'Prim Type Pattern', "A list of wildcard patterns used to match the prim types that are to be imported\n\nSupported syntax of wildcard pattern:\n '*' - match an arbitrary number of any characters\n '?' - match any single character\n '^' - (caret) is used to define a pattern that is to be excluded\n\nExample of wildcard patterns, input: ['Mesh', 'Cone', 'Cube']\n '*' - match any\n '* ^Mesh' - match any, but exclude 'Mesh'\n '* ^Cone ^Cube' - match any, but exclude 'Cone' and 'Cube'", {ogn.MetadataKeys.DEFAULT: '"*"'}, True, "*", False, ''),
('inputs:usdTimecode', 'timecode', 0, 'Time', 'The time at which to evaluate the transform of the USD prim. A value of "NaN" indicates that the default USD time stamp should be used', {ogn.MetadataKeys.DEFAULT: '"NaN"'}, True, float("NaN"), False, ''),
('outputs:primsBundle', 'bundle', 0, None, 'An output bundle containing multiple prims as children.\nEach child contains data attributes and two additional token attributes named sourcePrimPath and sourcePrimType\nwhich contains the path of the Prim being read', {}, True, None, False, ''),
('state:applySkelBinding', 'bool', 0, None, 'State from previous evaluation', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''),
('state:attrNamesToImport', 'string', 0, None, 'State from previous evaluation', {}, True, None, False, ''),
('state:computeBoundingBox', 'bool', 0, None, 'State from previous evaluation', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''),
('state:enableBundleChangeTracking', 'bool', 0, None, 'State from previous evaluation', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''),
('state:enableChangeTracking', 'bool', 0, None, 'State from previous evaluation', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''),
('state:pathPattern', 'string', 0, None, 'State from previous evaluation', {}, True, None, False, ''),
('state:typePattern', 'string', 0, None, 'State from previous evaluation', {}, True, None, False, ''),
('state:usdTimecode', 'timecode', 0, None, 'State from previous evaluation', {ogn.MetadataKeys.DEFAULT: '-1'}, True, -1, False, ''),
])
@classmethod
def _populate_role_data(cls):
"""Populate a role structure with the non-default roles on this node type"""
role_data = super()._populate_role_data()
role_data.inputs.attrNamesToImport = og.AttributeRole.TEXT
role_data.inputs.pathPattern = og.AttributeRole.TEXT
role_data.inputs.prims = og.AttributeRole.TARGET
role_data.inputs.typePattern = og.AttributeRole.TEXT
role_data.inputs.usdTimecode = og.AttributeRole.TIMECODE
role_data.outputs.primsBundle = og.AttributeRole.BUNDLE
role_data.state.attrNamesToImport = og.AttributeRole.TEXT
role_data.state.pathPattern = og.AttributeRole.TEXT
role_data.state.typePattern = og.AttributeRole.TEXT
role_data.state.usdTimecode = og.AttributeRole.TIMECODE
return role_data
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = []
self._batchedReadValues = []
@property
def _debugStamp(self):
data_view = og.AttributeValueHelper(self._attributes._debugStamp)
return data_view.get()
@_debugStamp.setter
def _debugStamp(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes._debugStamp)
data_view = og.AttributeValueHelper(self._attributes._debugStamp)
data_view.set(value)
@property
def applySkelBinding(self):
data_view = og.AttributeValueHelper(self._attributes.applySkelBinding)
return data_view.get()
@applySkelBinding.setter
def applySkelBinding(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.applySkelBinding)
data_view = og.AttributeValueHelper(self._attributes.applySkelBinding)
data_view.set(value)
@property
def attrNamesToImport(self):
data_view = og.AttributeValueHelper(self._attributes.attrNamesToImport)
return data_view.get()
@attrNamesToImport.setter
def attrNamesToImport(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.attrNamesToImport)
data_view = og.AttributeValueHelper(self._attributes.attrNamesToImport)
data_view.set(value)
self.attrNamesToImport_size = data_view.get_array_size()
@property
def computeBoundingBox(self):
data_view = og.AttributeValueHelper(self._attributes.computeBoundingBox)
return data_view.get()
@computeBoundingBox.setter
def computeBoundingBox(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.computeBoundingBox)
data_view = og.AttributeValueHelper(self._attributes.computeBoundingBox)
data_view.set(value)
@property
def enableBundleChangeTracking(self):
data_view = og.AttributeValueHelper(self._attributes.enableBundleChangeTracking)
return data_view.get()
@enableBundleChangeTracking.setter
def enableBundleChangeTracking(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.enableBundleChangeTracking)
data_view = og.AttributeValueHelper(self._attributes.enableBundleChangeTracking)
data_view.set(value)
@property
def enableChangeTracking(self):
data_view = og.AttributeValueHelper(self._attributes.enableChangeTracking)
return data_view.get()
@enableChangeTracking.setter
def enableChangeTracking(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.enableChangeTracking)
data_view = og.AttributeValueHelper(self._attributes.enableChangeTracking)
data_view.set(value)
@property
def pathPattern(self):
data_view = og.AttributeValueHelper(self._attributes.pathPattern)
return data_view.get()
@pathPattern.setter
def pathPattern(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.pathPattern)
data_view = og.AttributeValueHelper(self._attributes.pathPattern)
data_view.set(value)
self.pathPattern_size = data_view.get_array_size()
@property
def prims(self):
data_view = og.AttributeValueHelper(self._attributes.prims)
return data_view.get()
@prims.setter
def prims(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.prims)
data_view = og.AttributeValueHelper(self._attributes.prims)
data_view.set(value)
self.prims_size = data_view.get_array_size()
@property
def typePattern(self):
data_view = og.AttributeValueHelper(self._attributes.typePattern)
return data_view.get()
@typePattern.setter
def typePattern(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.typePattern)
data_view = og.AttributeValueHelper(self._attributes.typePattern)
data_view.set(value)
self.typePattern_size = data_view.get_array_size()
@property
def usdTimecode(self):
data_view = og.AttributeValueHelper(self._attributes.usdTimecode)
return data_view.get()
@usdTimecode.setter
def usdTimecode(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.usdTimecode)
data_view = og.AttributeValueHelper(self._attributes.usdTimecode)
data_view.set(value)
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self.__bundles = og.BundleContainer(context, node, attributes, [], read_only=False, gpu_ptr_kinds={})
self._batchedWriteValues = { }
@property
def primsBundle(self) -> og.BundleContents:
"""Get the bundle wrapper class for the attribute outputs.primsBundle"""
return self.__bundles.primsBundle
@primsBundle.setter
def primsBundle(self, bundle: og.BundleContents):
"""Overwrite the bundle attribute outputs.primsBundle with a new bundle"""
if not isinstance(bundle, og.BundleContents):
carb.log_error("Only bundle attributes can be assigned to another bundle attribute")
self.__bundles.primsBundle.bundle = bundle
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self.attrNamesToImport_size = None
self.pathPattern_size = None
self.typePattern_size = None
@property
def applySkelBinding(self):
data_view = og.AttributeValueHelper(self._attributes.applySkelBinding)
return data_view.get()
@applySkelBinding.setter
def applySkelBinding(self, value):
data_view = og.AttributeValueHelper(self._attributes.applySkelBinding)
data_view.set(value)
@property
def attrNamesToImport(self):
data_view = og.AttributeValueHelper(self._attributes.attrNamesToImport)
self.attrNamesToImport_size = data_view.get_array_size()
return data_view.get()
@attrNamesToImport.setter
def attrNamesToImport(self, value):
data_view = og.AttributeValueHelper(self._attributes.attrNamesToImport)
data_view.set(value)
self.attrNamesToImport_size = data_view.get_array_size()
@property
def computeBoundingBox(self):
data_view = og.AttributeValueHelper(self._attributes.computeBoundingBox)
return data_view.get()
@computeBoundingBox.setter
def computeBoundingBox(self, value):
data_view = og.AttributeValueHelper(self._attributes.computeBoundingBox)
data_view.set(value)
@property
def enableBundleChangeTracking(self):
data_view = og.AttributeValueHelper(self._attributes.enableBundleChangeTracking)
return data_view.get()
@enableBundleChangeTracking.setter
def enableBundleChangeTracking(self, value):
data_view = og.AttributeValueHelper(self._attributes.enableBundleChangeTracking)
data_view.set(value)
@property
def enableChangeTracking(self):
data_view = og.AttributeValueHelper(self._attributes.enableChangeTracking)
return data_view.get()
@enableChangeTracking.setter
def enableChangeTracking(self, value):
data_view = og.AttributeValueHelper(self._attributes.enableChangeTracking)
data_view.set(value)
@property
def pathPattern(self):
data_view = og.AttributeValueHelper(self._attributes.pathPattern)
self.pathPattern_size = data_view.get_array_size()
return data_view.get()
@pathPattern.setter
def pathPattern(self, value):
data_view = og.AttributeValueHelper(self._attributes.pathPattern)
data_view.set(value)
self.pathPattern_size = data_view.get_array_size()
@property
def typePattern(self):
data_view = og.AttributeValueHelper(self._attributes.typePattern)
self.typePattern_size = data_view.get_array_size()
return data_view.get()
@typePattern.setter
def typePattern(self, value):
data_view = og.AttributeValueHelper(self._attributes.typePattern)
data_view.set(value)
self.typePattern_size = data_view.get_array_size()
@property
def usdTimecode(self):
data_view = og.AttributeValueHelper(self._attributes.usdTimecode)
return data_view.get()
@usdTimecode.setter
def usdTimecode(self, value):
data_view = og.AttributeValueHelper(self._attributes.usdTimecode)
data_view.set(value)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnReadPrimsV2Database.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnReadPrimsV2Database.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnReadPrimsV2Database.ValuesForState(node, self.attributes.state, dynamic_attributes)
| 20,941 | Python | 56.218579 | 680 | 0.667065 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnGetLookAtRotationDatabase.py | """Support for simplified access to data on nodes of type omni.graph.nodes.GetLookAtRotation
Computes the rotation angles to align a forward direction vector to a direction vector formed by starting at 'start' and
pointing at 'target'. The forward vector is the 'default' orientation of the asset being rotated, usually +X or +Z
"""
import numpy
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnGetLookAtRotationDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.nodes.GetLookAtRotation
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.forward
inputs.start
inputs.target
inputs.up
Outputs:
outputs.orientation
outputs.rotateXYZ
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:forward', 'double3', 0, None, 'The direction vector to be aligned with the look vector', {ogn.MetadataKeys.DEFAULT: '[0.0, 0.0, 1.0]'}, True, [0.0, 0.0, 1.0], False, ''),
('inputs:start', 'point3d', 0, None, 'The position to look from', {}, True, [0.0, 0.0, 0.0], False, ''),
('inputs:target', 'point3d', 0, None, 'The position to look at', {}, True, [0.0, 0.0, 0.0], False, ''),
('inputs:up', 'double3', 0, None, "The direction considered to be 'up'. If not specified scene-up will be used.", {}, False, None, False, ''),
('outputs:orientation', 'quatd', 0, None, 'The orientation quaternion equivalent to outputs:rotateXYZ', {}, True, None, False, ''),
('outputs:rotateXYZ', 'double3', 0, None, 'The rotation vector [X, Y, Z]', {}, True, None, False, ''),
])
@classmethod
def _populate_role_data(cls):
"""Populate a role structure with the non-default roles on this node type"""
role_data = super()._populate_role_data()
role_data.inputs.start = og.AttributeRole.POSITION
role_data.inputs.target = og.AttributeRole.POSITION
role_data.outputs.orientation = og.AttributeRole.QUATERNION
return role_data
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = []
self._batchedReadValues = []
@property
def forward(self):
data_view = og.AttributeValueHelper(self._attributes.forward)
return data_view.get()
@forward.setter
def forward(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.forward)
data_view = og.AttributeValueHelper(self._attributes.forward)
data_view.set(value)
@property
def start(self):
data_view = og.AttributeValueHelper(self._attributes.start)
return data_view.get()
@start.setter
def start(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.start)
data_view = og.AttributeValueHelper(self._attributes.start)
data_view.set(value)
@property
def target(self):
data_view = og.AttributeValueHelper(self._attributes.target)
return data_view.get()
@target.setter
def target(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.target)
data_view = og.AttributeValueHelper(self._attributes.target)
data_view.set(value)
@property
def up(self):
data_view = og.AttributeValueHelper(self._attributes.up)
return data_view.get()
@up.setter
def up(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.up)
data_view = og.AttributeValueHelper(self._attributes.up)
data_view.set(value)
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedWriteValues = { }
@property
def orientation(self):
data_view = og.AttributeValueHelper(self._attributes.orientation)
return data_view.get()
@orientation.setter
def orientation(self, value):
data_view = og.AttributeValueHelper(self._attributes.orientation)
data_view.set(value)
@property
def rotateXYZ(self):
data_view = og.AttributeValueHelper(self._attributes.rotateXYZ)
return data_view.get()
@rotateXYZ.setter
def rotateXYZ(self, value):
data_view = og.AttributeValueHelper(self._attributes.rotateXYZ)
data_view.set(value)
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnGetLookAtRotationDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnGetLookAtRotationDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnGetLookAtRotationDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
| 7,919 | Python | 44.517241 | 187 | 0.648819 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnTimelineGetDatabase.py | """Support for simplified access to data on nodes of type omni.graph.nodes.GetTimeline
Get the main timeline properties
"""
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnTimelineGetDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.nodes.GetTimeline
Class Members:
node: Node being evaluated
Attribute Value Properties:
Outputs:
outputs.endFrame
outputs.endTime
outputs.frame
outputs.framesPerSecond
outputs.isLooping
outputs.isPlaying
outputs.startFrame
outputs.startTime
outputs.time
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('outputs:endFrame', 'double', 0, 'End Frame', "The end frame of the main timeline's play range.", {}, True, None, False, ''),
('outputs:endTime', 'double', 0, 'End Time', "The end time (in seconds) of the main timeline's play range.", {}, True, None, False, ''),
('outputs:frame', 'double', 0, 'Current Frame', "The current frame number of the main timeline's playhead.", {}, True, None, False, ''),
('outputs:framesPerSecond', 'double', 0, 'Frames Per Second', 'The number of frames per second of the main timeline.', {}, True, None, False, ''),
('outputs:isLooping', 'bool', 0, 'Is Looping', 'Is the main timeline currently looping?', {}, True, None, False, ''),
('outputs:isPlaying', 'bool', 0, 'Is Playing', 'Is the main timeline currently playing?', {}, True, None, False, ''),
('outputs:startFrame', 'double', 0, 'Start Frame', "The start frame of the main timeline's play range.", {}, True, None, False, ''),
('outputs:startTime', 'double', 0, 'Start Time', "The start time (in seconds) of the main timeline's play range.", {}, True, None, False, ''),
('outputs:time', 'double', 0, 'Current Time', "The current time (in seconds) of the main timeline's playhead.", {}, True, None, False, ''),
])
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = []
self._batchedReadValues = []
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedWriteValues = { }
@property
def endFrame(self):
data_view = og.AttributeValueHelper(self._attributes.endFrame)
return data_view.get()
@endFrame.setter
def endFrame(self, value):
data_view = og.AttributeValueHelper(self._attributes.endFrame)
data_view.set(value)
@property
def endTime(self):
data_view = og.AttributeValueHelper(self._attributes.endTime)
return data_view.get()
@endTime.setter
def endTime(self, value):
data_view = og.AttributeValueHelper(self._attributes.endTime)
data_view.set(value)
@property
def frame(self):
data_view = og.AttributeValueHelper(self._attributes.frame)
return data_view.get()
@frame.setter
def frame(self, value):
data_view = og.AttributeValueHelper(self._attributes.frame)
data_view.set(value)
@property
def framesPerSecond(self):
data_view = og.AttributeValueHelper(self._attributes.framesPerSecond)
return data_view.get()
@framesPerSecond.setter
def framesPerSecond(self, value):
data_view = og.AttributeValueHelper(self._attributes.framesPerSecond)
data_view.set(value)
@property
def isLooping(self):
data_view = og.AttributeValueHelper(self._attributes.isLooping)
return data_view.get()
@isLooping.setter
def isLooping(self, value):
data_view = og.AttributeValueHelper(self._attributes.isLooping)
data_view.set(value)
@property
def isPlaying(self):
data_view = og.AttributeValueHelper(self._attributes.isPlaying)
return data_view.get()
@isPlaying.setter
def isPlaying(self, value):
data_view = og.AttributeValueHelper(self._attributes.isPlaying)
data_view.set(value)
@property
def startFrame(self):
data_view = og.AttributeValueHelper(self._attributes.startFrame)
return data_view.get()
@startFrame.setter
def startFrame(self, value):
data_view = og.AttributeValueHelper(self._attributes.startFrame)
data_view.set(value)
@property
def startTime(self):
data_view = og.AttributeValueHelper(self._attributes.startTime)
return data_view.get()
@startTime.setter
def startTime(self, value):
data_view = og.AttributeValueHelper(self._attributes.startTime)
data_view.set(value)
@property
def time(self):
data_view = og.AttributeValueHelper(self._attributes.time)
return data_view.get()
@time.setter
def time(self, value):
data_view = og.AttributeValueHelper(self._attributes.time)
data_view.set(value)
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnTimelineGetDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnTimelineGetDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnTimelineGetDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
| 8,448 | Python | 43.468421 | 154 | 0.642874 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnWritePrimRelationshipDatabase.py | """Support for simplified access to data on nodes of type omni.graph.nodes.WritePrimRelationship
Writes the target(s) to a relationship on a given prim
"""
import usdrt
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnWritePrimRelationshipDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.nodes.WritePrimRelationship
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.execIn
inputs.name
inputs.prim
inputs.usdWriteBack
inputs.value
Outputs:
outputs.execOut
State:
state.correctlySetup
state.name
state.prim
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:execIn', 'execution', 0, None, 'The input execution port', {}, True, None, False, ''),
('inputs:name', 'token', 0, 'Relationship Name', 'The name of the relationship to write', {}, True, "", False, ''),
('inputs:prim', 'target', 0, None, 'The prim to write the relationship to', {}, True, [], False, ''),
('inputs:usdWriteBack', 'bool', 0, 'Persist To USD', 'Whether or not the value should be written back to USD, or kept a Fabric only value', {ogn.MetadataKeys.DEFAULT: 'true'}, True, True, False, ''),
('inputs:value', 'target', 0, None, 'The target(s) to write to the relationship', {}, True, [], False, ''),
('outputs:execOut', 'execution', 0, None, 'The output execution port', {}, True, None, False, ''),
('state:correctlySetup', 'bool', 0, None, 'Whether or not the instance is properly setup', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''),
('state:name', 'token', 0, None, 'The prefetched relationship name', {}, True, None, False, ''),
('state:prim', 'target', 0, None, 'The currently prefetched prim', {}, True, [], False, ''),
])
@classmethod
def _populate_role_data(cls):
"""Populate a role structure with the non-default roles on this node type"""
role_data = super()._populate_role_data()
role_data.inputs.execIn = og.AttributeRole.EXECUTION
role_data.inputs.prim = og.AttributeRole.TARGET
role_data.inputs.value = og.AttributeRole.TARGET
role_data.outputs.execOut = og.AttributeRole.EXECUTION
role_data.state.prim = og.AttributeRole.TARGET
return role_data
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = []
self._batchedReadValues = []
@property
def execIn(self):
data_view = og.AttributeValueHelper(self._attributes.execIn)
return data_view.get()
@execIn.setter
def execIn(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.execIn)
data_view = og.AttributeValueHelper(self._attributes.execIn)
data_view.set(value)
@property
def name(self):
data_view = og.AttributeValueHelper(self._attributes.name)
return data_view.get()
@name.setter
def name(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.name)
data_view = og.AttributeValueHelper(self._attributes.name)
data_view.set(value)
@property
def prim(self):
data_view = og.AttributeValueHelper(self._attributes.prim)
return data_view.get()
@prim.setter
def prim(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.prim)
data_view = og.AttributeValueHelper(self._attributes.prim)
data_view.set(value)
self.prim_size = data_view.get_array_size()
@property
def usdWriteBack(self):
data_view = og.AttributeValueHelper(self._attributes.usdWriteBack)
return data_view.get()
@usdWriteBack.setter
def usdWriteBack(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.usdWriteBack)
data_view = og.AttributeValueHelper(self._attributes.usdWriteBack)
data_view.set(value)
@property
def value(self):
data_view = og.AttributeValueHelper(self._attributes.value)
return data_view.get()
@value.setter
def value(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.value)
data_view = og.AttributeValueHelper(self._attributes.value)
data_view.set(value)
self.value_size = data_view.get_array_size()
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedWriteValues = { }
@property
def execOut(self):
data_view = og.AttributeValueHelper(self._attributes.execOut)
return data_view.get()
@execOut.setter
def execOut(self, value):
data_view = og.AttributeValueHelper(self._attributes.execOut)
data_view.set(value)
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self.prim_size = None
@property
def correctlySetup(self):
data_view = og.AttributeValueHelper(self._attributes.correctlySetup)
return data_view.get()
@correctlySetup.setter
def correctlySetup(self, value):
data_view = og.AttributeValueHelper(self._attributes.correctlySetup)
data_view.set(value)
@property
def name(self):
data_view = og.AttributeValueHelper(self._attributes.name)
return data_view.get()
@name.setter
def name(self, value):
data_view = og.AttributeValueHelper(self._attributes.name)
data_view.set(value)
@property
def prim(self):
data_view = og.AttributeValueHelper(self._attributes.prim)
self.prim_size = data_view.get_array_size()
return data_view.get()
@prim.setter
def prim(self, value):
data_view = og.AttributeValueHelper(self._attributes.prim)
data_view.set(value)
self.prim_size = data_view.get_array_size()
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnWritePrimRelationshipDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnWritePrimRelationshipDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnWritePrimRelationshipDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
| 9,600 | Python | 42.840182 | 207 | 0.635937 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnGetLocationAtDistanceOnCurveDatabase.py | """Support for simplified access to data on nodes of type omni.graph.nodes.GetLocationAtDistanceOnCurve
DEPRECATED: Use GetLocationAtDistanceOnCurve2
"""
import numpy
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnGetLocationAtDistanceOnCurveDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.nodes.GetLocationAtDistanceOnCurve
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.curve
inputs.distance
inputs.forwardAxis
inputs.upAxis
Outputs:
outputs.location
outputs.orientation
outputs.rotateXYZ
Predefined Tokens:
tokens.x
tokens.y
tokens.z
tokens.X
tokens.Y
tokens.Z
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:curve', 'point3d[]', 0, 'Curve', 'The curve to be examined', {}, True, [], False, ''),
('inputs:distance', 'double[]', 0, 'Distances', 'The distances along the curve, wrapped to the range 0-1.0', {}, True, [], False, ''),
('inputs:forwardAxis', 'token', 0, 'Forward', 'The direction vector from which the returned rotation is relative, one of X, Y, Z', {ogn.MetadataKeys.DEFAULT: '"X"'}, True, "X", False, ''),
('inputs:upAxis', 'token', 0, 'Up', 'The world Up vector, the curve should be in a plane perpendicular with this - one of X, Y, Z', {ogn.MetadataKeys.DEFAULT: '"Y"'}, True, "Y", False, ''),
('outputs:location', 'point3d[]', 0, 'Locations on curve at the given distances in world space', 'Locations', {}, True, None, False, ''),
('outputs:orientation', 'quatf[]', 0, 'World space orientations of the curve at the given distances, may not be smooth for some curves', 'Orientations', {}, True, None, False, ''),
('outputs:rotateXYZ', 'vector3d[]', 0, 'World space rotations of the curve at the given distances, may not be smooth for some curves', 'Rotations', {}, True, None, False, ''),
])
class tokens:
x = "x"
y = "y"
z = "z"
X = "X"
Y = "Y"
Z = "Z"
@classmethod
def _populate_role_data(cls):
"""Populate a role structure with the non-default roles on this node type"""
role_data = super()._populate_role_data()
role_data.inputs.curve = og.AttributeRole.POSITION
role_data.outputs.location = og.AttributeRole.POSITION
role_data.outputs.orientation = og.AttributeRole.QUATERNION
role_data.outputs.rotateXYZ = og.AttributeRole.VECTOR
return role_data
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = []
self._batchedReadValues = []
@property
def curve(self):
data_view = og.AttributeValueHelper(self._attributes.curve)
return data_view.get()
@curve.setter
def curve(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.curve)
data_view = og.AttributeValueHelper(self._attributes.curve)
data_view.set(value)
self.curve_size = data_view.get_array_size()
@property
def distance(self):
data_view = og.AttributeValueHelper(self._attributes.distance)
return data_view.get()
@distance.setter
def distance(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.distance)
data_view = og.AttributeValueHelper(self._attributes.distance)
data_view.set(value)
self.distance_size = data_view.get_array_size()
@property
def forwardAxis(self):
data_view = og.AttributeValueHelper(self._attributes.forwardAxis)
return data_view.get()
@forwardAxis.setter
def forwardAxis(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.forwardAxis)
data_view = og.AttributeValueHelper(self._attributes.forwardAxis)
data_view.set(value)
@property
def upAxis(self):
data_view = og.AttributeValueHelper(self._attributes.upAxis)
return data_view.get()
@upAxis.setter
def upAxis(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.upAxis)
data_view = og.AttributeValueHelper(self._attributes.upAxis)
data_view.set(value)
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self.location_size = None
self.orientation_size = None
self.rotateXYZ_size = None
self._batchedWriteValues = { }
@property
def location(self):
data_view = og.AttributeValueHelper(self._attributes.location)
return data_view.get(reserved_element_count=self.location_size)
@location.setter
def location(self, value):
data_view = og.AttributeValueHelper(self._attributes.location)
data_view.set(value)
self.location_size = data_view.get_array_size()
@property
def orientation(self):
data_view = og.AttributeValueHelper(self._attributes.orientation)
return data_view.get(reserved_element_count=self.orientation_size)
@orientation.setter
def orientation(self, value):
data_view = og.AttributeValueHelper(self._attributes.orientation)
data_view.set(value)
self.orientation_size = data_view.get_array_size()
@property
def rotateXYZ(self):
data_view = og.AttributeValueHelper(self._attributes.rotateXYZ)
return data_view.get(reserved_element_count=self.rotateXYZ_size)
@rotateXYZ.setter
def rotateXYZ(self, value):
data_view = og.AttributeValueHelper(self._attributes.rotateXYZ)
data_view.set(value)
self.rotateXYZ_size = data_view.get_array_size()
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnGetLocationAtDistanceOnCurveDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnGetLocationAtDistanceOnCurveDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnGetLocationAtDistanceOnCurveDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
| 9,416 | Python | 43.842857 | 197 | 0.644966 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnTimelineSetDatabase.py | """Support for simplified access to data on nodes of type omni.graph.nodes.SetTimeline
Set properties of the main timeline
"""
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnTimelineSetDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.nodes.SetTimeline
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.execIn
inputs.propName
inputs.propValue
Outputs:
outputs.clamped
outputs.execOut
Predefined Tokens:
tokens.Frame
tokens.Time
tokens.StartFrame
tokens.StartTime
tokens.EndFrame
tokens.EndTime
tokens.FramesPerSecond
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:execIn', 'execution', 0, 'Execute In', 'The input that triggers the execution of this node.', {}, True, None, False, ''),
('inputs:propName', 'token', 0, 'Property Name', 'The name of the property to set.', {'displayGroup': 'parameters', ogn.MetadataKeys.LITERAL_ONLY: '1', ogn.MetadataKeys.ALLOWED_TOKENS: 'Frame,Time,StartFrame,StartTime,EndFrame,EndTime,FramesPerSecond', ogn.MetadataKeys.ALLOWED_TOKENS_RAW: '["Frame", "Time", "StartFrame", "StartTime", "EndFrame", "EndTime", "FramesPerSecond"]', ogn.MetadataKeys.DEFAULT: '"Frame"'}, True, "Frame", False, ''),
('inputs:propValue', 'double', 0, 'Property Value', 'The value of the property to set.', {}, True, 0.0, False, ''),
('outputs:clamped', 'bool', 0, 'Clamp to range', 'Was the input frame or time clamped to the playback range?', {}, True, None, False, ''),
('outputs:execOut', 'execution', 0, 'Execute Out', 'The output that is triggered when this node executed.', {}, True, None, False, ''),
])
class tokens:
Frame = "Frame"
Time = "Time"
StartFrame = "StartFrame"
StartTime = "StartTime"
EndFrame = "EndFrame"
EndTime = "EndTime"
FramesPerSecond = "FramesPerSecond"
@classmethod
def _populate_role_data(cls):
"""Populate a role structure with the non-default roles on this node type"""
role_data = super()._populate_role_data()
role_data.inputs.execIn = og.AttributeRole.EXECUTION
role_data.outputs.execOut = og.AttributeRole.EXECUTION
return role_data
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = []
self._batchedReadValues = []
@property
def execIn(self):
data_view = og.AttributeValueHelper(self._attributes.execIn)
return data_view.get()
@execIn.setter
def execIn(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.execIn)
data_view = og.AttributeValueHelper(self._attributes.execIn)
data_view.set(value)
@property
def propName(self):
data_view = og.AttributeValueHelper(self._attributes.propName)
return data_view.get()
@propName.setter
def propName(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.propName)
data_view = og.AttributeValueHelper(self._attributes.propName)
data_view.set(value)
@property
def propValue(self):
data_view = og.AttributeValueHelper(self._attributes.propValue)
return data_view.get()
@propValue.setter
def propValue(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.propValue)
data_view = og.AttributeValueHelper(self._attributes.propValue)
data_view.set(value)
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedWriteValues = { }
@property
def clamped(self):
data_view = og.AttributeValueHelper(self._attributes.clamped)
return data_view.get()
@clamped.setter
def clamped(self, value):
data_view = og.AttributeValueHelper(self._attributes.clamped)
data_view.set(value)
@property
def execOut(self):
data_view = og.AttributeValueHelper(self._attributes.execOut)
return data_view.get()
@execOut.setter
def execOut(self, value):
data_view = og.AttributeValueHelper(self._attributes.execOut)
data_view.set(value)
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnTimelineSetDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnTimelineSetDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnTimelineSetDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
| 7,808 | Python | 43.622857 | 452 | 0.651511 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnDistance3DDatabase.py | """Support for simplified access to data on nodes of type omni.graph.nodes.Distance3D
Computes the distance between two 3D points A and B. Which is the length of the vector with start and end points A and B
If one input is an array and the other is a single point, the scaler will be broadcast to the size of the array
"""
from typing import Any
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnDistance3DDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.nodes.Distance3D
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.a
inputs.b
Outputs:
outputs.distance
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:a', 'pointd[3],pointd[3][],pointf[3],pointf[3][],pointh[3],pointh[3][]', 1, 'A', 'Vector A', {}, True, None, False, ''),
('inputs:b', 'pointd[3],pointd[3][],pointf[3],pointf[3][],pointh[3],pointh[3][]', 1, 'B', 'Vector B', {}, True, None, False, ''),
('outputs:distance', 'double,double[],float,float[],half,half[]', 1, None, 'The distance between the input vectors', {}, True, None, False, ''),
])
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = []
self._batchedReadValues = []
@property
def a(self) -> og.RuntimeAttribute:
"""Get the runtime wrapper class for the attribute inputs.a"""
return og.RuntimeAttribute(self._attributes.a.get_attribute_data(), self._context, True)
@a.setter
def a(self, value_to_set: Any):
"""Assign another attribute's value to outputs.a"""
if isinstance(value_to_set, og.RuntimeAttribute):
self.a.value = value_to_set.value
else:
self.a.value = value_to_set
@property
def b(self) -> og.RuntimeAttribute:
"""Get the runtime wrapper class for the attribute inputs.b"""
return og.RuntimeAttribute(self._attributes.b.get_attribute_data(), self._context, True)
@b.setter
def b(self, value_to_set: Any):
"""Assign another attribute's value to outputs.b"""
if isinstance(value_to_set, og.RuntimeAttribute):
self.b.value = value_to_set.value
else:
self.b.value = value_to_set
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedWriteValues = { }
@property
def distance(self) -> og.RuntimeAttribute:
"""Get the runtime wrapper class for the attribute outputs.distance"""
return og.RuntimeAttribute(self._attributes.distance.get_attribute_data(), self._context, False)
@distance.setter
def distance(self, value_to_set: Any):
"""Assign another attribute's value to outputs.distance"""
if isinstance(value_to_set, og.RuntimeAttribute):
self.distance.value = value_to_set.value
else:
self.distance.value = value_to_set
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnDistance3DDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnDistance3DDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnDistance3DDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
| 6,358 | Python | 47.915384 | 152 | 0.654294 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnCurveFrameDatabase.py | """Support for simplified access to data on nodes of type omni.graph.nodes.CurveToFrame
Create a frame object based on a curve description
"""
import numpy
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnCurveFrameDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.nodes.CurveToFrame
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.curvePoints
inputs.curveVertexCounts
inputs.curveVertexStarts
Outputs:
outputs.out
outputs.tangent
outputs.up
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:curvePoints', 'float3[]', 0, 'Curve Points', 'Points on the curve to be framed', {}, True, [], False, ''),
('inputs:curveVertexCounts', 'int[]', 0, 'Curve Vertex Counts', 'Vertex counts for the curve points', {}, True, [], False, ''),
('inputs:curveVertexStarts', 'int[]', 0, 'Curve Vertex Starts', 'Vertex starting points', {}, True, [], False, ''),
('outputs:out', 'float3[]', 0, 'Out Vectors', 'Out vector directions on the curve frame', {}, True, None, False, ''),
('outputs:tangent', 'float3[]', 0, 'Tangents', 'Tangents on the curve frame', {}, True, None, False, ''),
('outputs:up', 'float3[]', 0, 'Up Vectors', 'Up vectors on the curve frame', {}, True, None, False, ''),
])
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = []
self._batchedReadValues = []
@property
def curvePoints(self):
data_view = og.AttributeValueHelper(self._attributes.curvePoints)
return data_view.get()
@curvePoints.setter
def curvePoints(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.curvePoints)
data_view = og.AttributeValueHelper(self._attributes.curvePoints)
data_view.set(value)
self.curvePoints_size = data_view.get_array_size()
@property
def curveVertexCounts(self):
data_view = og.AttributeValueHelper(self._attributes.curveVertexCounts)
return data_view.get()
@curveVertexCounts.setter
def curveVertexCounts(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.curveVertexCounts)
data_view = og.AttributeValueHelper(self._attributes.curveVertexCounts)
data_view.set(value)
self.curveVertexCounts_size = data_view.get_array_size()
@property
def curveVertexStarts(self):
data_view = og.AttributeValueHelper(self._attributes.curveVertexStarts)
return data_view.get()
@curveVertexStarts.setter
def curveVertexStarts(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.curveVertexStarts)
data_view = og.AttributeValueHelper(self._attributes.curveVertexStarts)
data_view.set(value)
self.curveVertexStarts_size = data_view.get_array_size()
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self.out_size = None
self.tangent_size = None
self.up_size = None
self._batchedWriteValues = { }
@property
def out(self):
data_view = og.AttributeValueHelper(self._attributes.out)
return data_view.get(reserved_element_count=self.out_size)
@out.setter
def out(self, value):
data_view = og.AttributeValueHelper(self._attributes.out)
data_view.set(value)
self.out_size = data_view.get_array_size()
@property
def tangent(self):
data_view = og.AttributeValueHelper(self._attributes.tangent)
return data_view.get(reserved_element_count=self.tangent_size)
@tangent.setter
def tangent(self, value):
data_view = og.AttributeValueHelper(self._attributes.tangent)
data_view.set(value)
self.tangent_size = data_view.get_array_size()
@property
def up(self):
data_view = og.AttributeValueHelper(self._attributes.up)
return data_view.get(reserved_element_count=self.up_size)
@up.setter
def up(self, value):
data_view = og.AttributeValueHelper(self._attributes.up)
data_view.set(value)
self.up_size = data_view.get_array_size()
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnCurveFrameDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnCurveFrameDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnCurveFrameDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
| 7,832 | Python | 44.807017 | 135 | 0.648238 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnCurveTubeSTDatabase.py | """Support for simplified access to data on nodes of type omni.graph.nodes.CurveTubeST
Compute curve tube ST values
"""
import numpy
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnCurveTubeSTDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.nodes.CurveTubeST
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.cols
inputs.curveVertexCounts
inputs.curveVertexStarts
inputs.scaleTLikeS
inputs.t
inputs.tubeQuadStarts
inputs.tubeSTStarts
inputs.width
Outputs:
outputs.primvars_st
outputs.primvars_st_indices
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:cols', 'int[]', 0, 'Columns', 'Columns of the tubes', {}, True, [], False, ''),
('inputs:curveVertexCounts', 'int[]', 0, 'Curve Vertex Counts', 'Vertex counts for the curve points', {}, True, [], False, ''),
('inputs:curveVertexStarts', 'int[]', 0, 'Curve Vertex Starts', 'Vertex starting points', {}, True, [], False, ''),
('inputs:scaleTLikeS', 'bool', 0, 'Scale T Like S', 'If true then scale T the same as S', {}, True, False, False, ''),
('inputs:t', 'float[]', 0, 'T Values', 'T values of the tubes', {}, True, [], False, ''),
('inputs:tubeQuadStarts', 'int[]', 0, 'Tube Quad Starts', 'Vertex index values for the tube quad starting points', {}, True, [], False, ''),
('inputs:tubeSTStarts', 'int[]', 0, 'Tube ST Starts', 'Vertex index values for the tube ST starting points', {}, True, [], False, ''),
('inputs:width', 'float[]', 0, 'Tube Widths', 'Width of tube positions, if scaling T like S', {}, True, [], False, ''),
('outputs:primvars:st', 'float2[]', 0, 'ST Values', 'Array of computed ST values', {}, True, None, False, ''),
('outputs:primvars:st:indices', 'int[]', 0, 'ST Indices', 'Array of computed ST indices', {}, True, None, False, ''),
])
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = []
self._batchedReadValues = []
@property
def cols(self):
data_view = og.AttributeValueHelper(self._attributes.cols)
return data_view.get()
@cols.setter
def cols(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.cols)
data_view = og.AttributeValueHelper(self._attributes.cols)
data_view.set(value)
self.cols_size = data_view.get_array_size()
@property
def curveVertexCounts(self):
data_view = og.AttributeValueHelper(self._attributes.curveVertexCounts)
return data_view.get()
@curveVertexCounts.setter
def curveVertexCounts(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.curveVertexCounts)
data_view = og.AttributeValueHelper(self._attributes.curveVertexCounts)
data_view.set(value)
self.curveVertexCounts_size = data_view.get_array_size()
@property
def curveVertexStarts(self):
data_view = og.AttributeValueHelper(self._attributes.curveVertexStarts)
return data_view.get()
@curveVertexStarts.setter
def curveVertexStarts(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.curveVertexStarts)
data_view = og.AttributeValueHelper(self._attributes.curveVertexStarts)
data_view.set(value)
self.curveVertexStarts_size = data_view.get_array_size()
@property
def scaleTLikeS(self):
data_view = og.AttributeValueHelper(self._attributes.scaleTLikeS)
return data_view.get()
@scaleTLikeS.setter
def scaleTLikeS(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.scaleTLikeS)
data_view = og.AttributeValueHelper(self._attributes.scaleTLikeS)
data_view.set(value)
@property
def t(self):
data_view = og.AttributeValueHelper(self._attributes.t)
return data_view.get()
@t.setter
def t(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.t)
data_view = og.AttributeValueHelper(self._attributes.t)
data_view.set(value)
self.t_size = data_view.get_array_size()
@property
def tubeQuadStarts(self):
data_view = og.AttributeValueHelper(self._attributes.tubeQuadStarts)
return data_view.get()
@tubeQuadStarts.setter
def tubeQuadStarts(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.tubeQuadStarts)
data_view = og.AttributeValueHelper(self._attributes.tubeQuadStarts)
data_view.set(value)
self.tubeQuadStarts_size = data_view.get_array_size()
@property
def tubeSTStarts(self):
data_view = og.AttributeValueHelper(self._attributes.tubeSTStarts)
return data_view.get()
@tubeSTStarts.setter
def tubeSTStarts(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.tubeSTStarts)
data_view = og.AttributeValueHelper(self._attributes.tubeSTStarts)
data_view.set(value)
self.tubeSTStarts_size = data_view.get_array_size()
@property
def width(self):
data_view = og.AttributeValueHelper(self._attributes.width)
return data_view.get()
@width.setter
def width(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.width)
data_view = og.AttributeValueHelper(self._attributes.width)
data_view.set(value)
self.width_size = data_view.get_array_size()
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self.primvars_st_size = None
self.primvars_st_indices_size = None
self._batchedWriteValues = { }
@property
def primvars_st(self):
data_view = og.AttributeValueHelper(self._attributes.primvars_st)
return data_view.get(reserved_element_count=self.primvars_st_size)
@primvars_st.setter
def primvars_st(self, value):
data_view = og.AttributeValueHelper(self._attributes.primvars_st)
data_view.set(value)
self.primvars_st_size = data_view.get_array_size()
@property
def primvars_st_indices(self):
data_view = og.AttributeValueHelper(self._attributes.primvars_st_indices)
return data_view.get(reserved_element_count=self.primvars_st_indices_size)
@primvars_st_indices.setter
def primvars_st_indices(self, value):
data_view = og.AttributeValueHelper(self._attributes.primvars_st_indices)
data_view.set(value)
self.primvars_st_indices_size = data_view.get_array_size()
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnCurveTubeSTDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnCurveTubeSTDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnCurveTubeSTDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
| 10,552 | Python | 44.683982 | 148 | 0.635614 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnReadPrimMaterialDatabase.py | """Support for simplified access to data on nodes of type omni.graph.nodes.ReadPrimMaterial
Given a path to a prim on the current USD stage, outputs the material of the prim. Gives an error if the given prim can
not be found.
"""
import usdrt
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnReadPrimMaterialDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.nodes.ReadPrimMaterial
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.prim
inputs.primPath
Outputs:
outputs.material
outputs.materialPrim
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:prim', 'target', 0, None, 'The prim with the material to be read. If both this and primPath inputs are set, this input takes priority.', {}, True, [], False, ''),
('inputs:primPath', 'path', 0, 'Prim Path', 'Path of the prim with the material to be read.', {}, True, "", True, 'Use prim input instead'),
('outputs:material', 'path', 0, 'Material Path', 'The material of the input prim', {}, True, None, True, 'Use materialPrim output instead'),
('outputs:materialPrim', 'target', 0, 'Material', 'The prim containing the material of the input prim', {}, True, [], False, ''),
])
@classmethod
def _populate_role_data(cls):
"""Populate a role structure with the non-default roles on this node type"""
role_data = super()._populate_role_data()
role_data.inputs.prim = og.AttributeRole.TARGET
role_data.inputs.primPath = og.AttributeRole.PATH
role_data.outputs.material = og.AttributeRole.PATH
role_data.outputs.materialPrim = og.AttributeRole.TARGET
return role_data
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = []
self._batchedReadValues = []
@property
def prim(self):
data_view = og.AttributeValueHelper(self._attributes.prim)
return data_view.get()
@prim.setter
def prim(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.prim)
data_view = og.AttributeValueHelper(self._attributes.prim)
data_view.set(value)
self.prim_size = data_view.get_array_size()
@property
def primPath(self):
data_view = og.AttributeValueHelper(self._attributes.primPath)
return data_view.get()
@primPath.setter
def primPath(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.primPath)
data_view = og.AttributeValueHelper(self._attributes.primPath)
data_view.set(value)
self.primPath_size = data_view.get_array_size()
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self.material_size = None
self.materialPrim_size = None
self._batchedWriteValues = { }
@property
def material(self):
data_view = og.AttributeValueHelper(self._attributes.material)
return data_view.get(reserved_element_count=self.material_size)
@material.setter
def material(self, value):
data_view = og.AttributeValueHelper(self._attributes.material)
data_view.set(value)
self.material_size = data_view.get_array_size()
@property
def materialPrim(self):
data_view = og.AttributeValueHelper(self._attributes.materialPrim)
return data_view.get(reserved_element_count=self.materialPrim_size)
@materialPrim.setter
def materialPrim(self, value):
data_view = og.AttributeValueHelper(self._attributes.materialPrim)
data_view.set(value)
self.materialPrim_size = data_view.get_array_size()
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnReadPrimMaterialDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnReadPrimMaterialDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnReadPrimMaterialDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
| 7,213 | Python | 46.150326 | 179 | 0.661722 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnGetLocationAtDistanceOnCurve2Database.py | """Support for simplified access to data on nodes of type omni.graph.nodes.GetLocationAtDistanceOnCurve2
Given a set of curve points and a normalized distance between 0-1.0, return the location on a closed curve. 0 is the first
point on the curve, 1.0 is also the first point because the is an implicit segment connecting the first and last points.
Values outside the range 0-1.0 will be wrapped to that range, for example -0.4 is equivalent to 0.6 and 1.3 is equivalent
to 0.3 This is a simplistic curve-following node, intended for curves in a plane, for prototyping purposes.
"""
import numpy
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnGetLocationAtDistanceOnCurve2Database(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.nodes.GetLocationAtDistanceOnCurve2
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.curve
inputs.distance
inputs.forwardAxis
inputs.upAxis
Outputs:
outputs.location
outputs.orientation
outputs.rotateXYZ
Predefined Tokens:
tokens.x
tokens.y
tokens.z
tokens.X
tokens.Y
tokens.Z
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:curve', 'point3d[]', 0, 'Curve', 'The curve to be examined', {}, True, [], False, ''),
('inputs:distance', 'double', 0, 'Distance', 'The distance along the curve, wrapped to the range 0-1.0', {}, True, 0.0, False, ''),
('inputs:forwardAxis', 'token', 0, 'Forward', 'The direction vector from which the returned rotation is relative, one of X, Y, Z', {ogn.MetadataKeys.DEFAULT: '"X"'}, True, "X", False, ''),
('inputs:upAxis', 'token', 0, 'Up', 'The world Up vector, the curve should be in a plane perpendicular with this - one of X, Y, Z', {ogn.MetadataKeys.DEFAULT: '"Y"'}, True, "Y", False, ''),
('outputs:location', 'point3d', 0, 'Location on curve at the given distance in world space', 'Location', {}, True, None, False, ''),
('outputs:orientation', 'quatf', 0, 'World space orientation of the curve at the given distance, may not be smooth for some curves', 'Orientation', {}, True, None, False, ''),
('outputs:rotateXYZ', 'vector3d', 0, 'World space rotation of the curve at the given distance, may not be smooth for some curves', 'Rotations', {}, True, None, False, ''),
])
class tokens:
x = "x"
y = "y"
z = "z"
X = "X"
Y = "Y"
Z = "Z"
@classmethod
def _populate_role_data(cls):
"""Populate a role structure with the non-default roles on this node type"""
role_data = super()._populate_role_data()
role_data.inputs.curve = og.AttributeRole.POSITION
role_data.outputs.location = og.AttributeRole.POSITION
role_data.outputs.orientation = og.AttributeRole.QUATERNION
role_data.outputs.rotateXYZ = og.AttributeRole.VECTOR
return role_data
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = []
self._batchedReadValues = []
@property
def curve(self):
data_view = og.AttributeValueHelper(self._attributes.curve)
return data_view.get()
@curve.setter
def curve(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.curve)
data_view = og.AttributeValueHelper(self._attributes.curve)
data_view.set(value)
self.curve_size = data_view.get_array_size()
@property
def distance(self):
data_view = og.AttributeValueHelper(self._attributes.distance)
return data_view.get()
@distance.setter
def distance(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.distance)
data_view = og.AttributeValueHelper(self._attributes.distance)
data_view.set(value)
@property
def forwardAxis(self):
data_view = og.AttributeValueHelper(self._attributes.forwardAxis)
return data_view.get()
@forwardAxis.setter
def forwardAxis(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.forwardAxis)
data_view = og.AttributeValueHelper(self._attributes.forwardAxis)
data_view.set(value)
@property
def upAxis(self):
data_view = og.AttributeValueHelper(self._attributes.upAxis)
return data_view.get()
@upAxis.setter
def upAxis(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.upAxis)
data_view = og.AttributeValueHelper(self._attributes.upAxis)
data_view.set(value)
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedWriteValues = { }
@property
def location(self):
data_view = og.AttributeValueHelper(self._attributes.location)
return data_view.get()
@location.setter
def location(self, value):
data_view = og.AttributeValueHelper(self._attributes.location)
data_view.set(value)
@property
def orientation(self):
data_view = og.AttributeValueHelper(self._attributes.orientation)
return data_view.get()
@orientation.setter
def orientation(self, value):
data_view = og.AttributeValueHelper(self._attributes.orientation)
data_view.set(value)
@property
def rotateXYZ(self):
data_view = og.AttributeValueHelper(self._attributes.rotateXYZ)
return data_view.get()
@rotateXYZ.setter
def rotateXYZ(self, value):
data_view = og.AttributeValueHelper(self._attributes.rotateXYZ)
data_view.set(value)
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnGetLocationAtDistanceOnCurve2Database.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnGetLocationAtDistanceOnCurve2Database.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnGetLocationAtDistanceOnCurve2Database.ValuesForState(node, self.attributes.state, dynamic_attributes)
| 9,345 | Python | 44.368932 | 197 | 0.650187 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnRenameAttrDatabase.py | """Support for simplified access to data on nodes of type omni.graph.nodes.RenameAttribute
Changes the names of attributes from an input bundle for the corresponding output bundle. Attributes whose names are not
in the 'inputAttrNames' list will be copied from the input bundle to the output bundle without changing the name.
"""
import carb
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnRenameAttrDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.nodes.RenameAttribute
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.data
inputs.inputAttrNames
inputs.outputAttrNames
Outputs:
outputs.data
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:data', 'bundle', 0, 'Original Attribute Bundle', 'Collection of attributes to be renamed', {}, True, None, False, ''),
('inputs:inputAttrNames', 'token', 0, 'Attributes To Rename', 'Comma or space separated text, listing the names of attributes in the input data to be renamed', {ogn.MetadataKeys.DEFAULT: '""'}, True, "", False, ''),
('inputs:outputAttrNames', 'token', 0, 'New Attribute Names', 'Comma or space separated text, listing the new names for the attributes listed in inputAttrNames', {ogn.MetadataKeys.DEFAULT: '""'}, True, "", False, ''),
('outputs:data', 'bundle', 0, 'Bundle Of Renamed Attributes', 'Final bundle of attributes, with attributes renamed based on inputAttrNames and outputAttrNames', {}, True, None, False, ''),
])
@classmethod
def _populate_role_data(cls):
"""Populate a role structure with the non-default roles on this node type"""
role_data = super()._populate_role_data()
role_data.inputs.data = og.AttributeRole.BUNDLE
role_data.outputs.data = og.AttributeRole.BUNDLE
return role_data
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self.__bundles = og.BundleContainer(context, node, attributes, [], read_only=True, gpu_ptr_kinds={})
self._batchedReadAttributes = []
self._batchedReadValues = []
@property
def data(self) -> og.BundleContents:
"""Get the bundle wrapper class for the attribute inputs.data"""
return self.__bundles.data
@property
def inputAttrNames(self):
data_view = og.AttributeValueHelper(self._attributes.inputAttrNames)
return data_view.get()
@inputAttrNames.setter
def inputAttrNames(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.inputAttrNames)
data_view = og.AttributeValueHelper(self._attributes.inputAttrNames)
data_view.set(value)
@property
def outputAttrNames(self):
data_view = og.AttributeValueHelper(self._attributes.outputAttrNames)
return data_view.get()
@outputAttrNames.setter
def outputAttrNames(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.outputAttrNames)
data_view = og.AttributeValueHelper(self._attributes.outputAttrNames)
data_view.set(value)
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self.__bundles = og.BundleContainer(context, node, attributes, [], read_only=False, gpu_ptr_kinds={})
self._batchedWriteValues = { }
@property
def data(self) -> og.BundleContents:
"""Get the bundle wrapper class for the attribute outputs.data"""
return self.__bundles.data
@data.setter
def data(self, bundle: og.BundleContents):
"""Overwrite the bundle attribute outputs.data with a new bundle"""
if not isinstance(bundle, og.BundleContents):
carb.log_error("Only bundle attributes can be assigned to another bundle attribute")
self.__bundles.data.bundle = bundle
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnRenameAttrDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnRenameAttrDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnRenameAttrDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
| 7,301 | Python | 49.708333 | 225 | 0.672374 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnDeformedPointsToHydraDatabase.py | """Support for simplified access to data on nodes of type omni.graph.nodes.DeformedPointsToHydra
Copy deformed points into rpresource and send to hydra
"""
import numpy
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnDeformedPointsToHydraDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.nodes.DeformedPointsToHydra
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.points
inputs.primPath
inputs.sendToHydra
inputs.stream
inputs.verbose
Outputs:
outputs.reload
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:points', 'float3[]', 0, 'Prim Points', 'Points attribute input. Points and a prim path may be supplied directly as an alternative to a bundle input.', {ogn.MetadataKeys.MEMORY_TYPE: 'cuda'}, True, [], False, ''),
('inputs:primPath', 'token', 0, 'Prim path input', 'Prim path input. Points and a prim path may be supplied directly as an alternative to a bundle input.', {}, True, "", False, ''),
('inputs:sendToHydra', 'bool', 0, 'Send to hydra', 'send to hydra', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''),
('inputs:stream', 'uint64', 0, 'stream', 'Pointer to the CUDA Stream', {}, True, 0, False, ''),
('inputs:verbose', 'bool', 0, 'Verbose', 'verbose printing', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''),
('outputs:reload', 'bool', 0, 'Reload', 'Force RpResource reload', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''),
])
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = []
self._batchedReadValues = []
@property
def points(self):
data_view = og.AttributeValueHelper(self._attributes.points)
data_view.gpu_ptr_kind = og.PtrToPtrKind.CPU
return data_view.get(on_gpu=True)
@points.setter
def points(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.points)
data_view = og.AttributeValueHelper(self._attributes.points)
data_view.gpu_ptr_kind = og.PtrToPtrKind.CPU
data_view.set(value, on_gpu=True)
self.points_size = data_view.get_array_size()
@property
def primPath(self):
data_view = og.AttributeValueHelper(self._attributes.primPath)
return data_view.get()
@primPath.setter
def primPath(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.primPath)
data_view = og.AttributeValueHelper(self._attributes.primPath)
data_view.set(value)
@property
def sendToHydra(self):
data_view = og.AttributeValueHelper(self._attributes.sendToHydra)
return data_view.get()
@sendToHydra.setter
def sendToHydra(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.sendToHydra)
data_view = og.AttributeValueHelper(self._attributes.sendToHydra)
data_view.set(value)
@property
def stream(self):
data_view = og.AttributeValueHelper(self._attributes.stream)
return data_view.get()
@stream.setter
def stream(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.stream)
data_view = og.AttributeValueHelper(self._attributes.stream)
data_view.set(value)
@property
def verbose(self):
data_view = og.AttributeValueHelper(self._attributes.verbose)
return data_view.get()
@verbose.setter
def verbose(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.verbose)
data_view = og.AttributeValueHelper(self._attributes.verbose)
data_view.set(value)
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedWriteValues = { }
@property
def reload(self):
data_view = og.AttributeValueHelper(self._attributes.reload)
return data_view.get()
@reload.setter
def reload(self, value):
data_view = og.AttributeValueHelper(self._attributes.reload)
data_view.set(value)
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnDeformedPointsToHydraDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnDeformedPointsToHydraDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnDeformedPointsToHydraDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
| 7,808 | Python | 45.2071 | 229 | 0.650102 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnTimerDatabase.py | """Support for simplified access to data on nodes of type omni.graph.nodes.Timer
Timer Node is a node that lets you create animation curve(s), plays back and samples the value(s) along its time to output
values.
"""
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnTimerDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.nodes.Timer
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.duration
inputs.endValue
inputs.play
inputs.startValue
Outputs:
outputs.finished
outputs.updated
outputs.value
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:duration', 'double', 0, 'Duration', 'Number of seconds to play interpolation', {ogn.MetadataKeys.DEFAULT: '1.0'}, True, 1.0, False, ''),
('inputs:endValue', 'double', 0, 'End Value', 'Value value of the end of the duration', {ogn.MetadataKeys.DEFAULT: '1.0'}, True, 1.0, False, ''),
('inputs:play', 'execution', 0, 'Play', 'Play the clip from current frame', {}, True, None, False, ''),
('inputs:startValue', 'double', 0, 'Start Value', 'Value value of the start of the duration', {ogn.MetadataKeys.DEFAULT: '0.0'}, True, 0.0, False, ''),
('outputs:finished', 'execution', 0, 'Finished', 'The Timer node has finished the playback', {}, True, None, False, ''),
('outputs:updated', 'execution', 0, 'Updated', 'The Timer node is ticked, and output value(s) resampled and updated', {}, True, None, False, ''),
('outputs:value', 'double', 0, 'Value', 'Value value of the Timer node between 0.0 and 1.0', {ogn.MetadataKeys.DEFAULT: '0.0'}, True, 0.0, False, ''),
])
@classmethod
def _populate_role_data(cls):
"""Populate a role structure with the non-default roles on this node type"""
role_data = super()._populate_role_data()
role_data.inputs.play = og.AttributeRole.EXECUTION
role_data.outputs.finished = og.AttributeRole.EXECUTION
role_data.outputs.updated = og.AttributeRole.EXECUTION
return role_data
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = []
self._batchedReadValues = []
@property
def duration(self):
data_view = og.AttributeValueHelper(self._attributes.duration)
return data_view.get()
@duration.setter
def duration(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.duration)
data_view = og.AttributeValueHelper(self._attributes.duration)
data_view.set(value)
@property
def endValue(self):
data_view = og.AttributeValueHelper(self._attributes.endValue)
return data_view.get()
@endValue.setter
def endValue(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.endValue)
data_view = og.AttributeValueHelper(self._attributes.endValue)
data_view.set(value)
@property
def play(self):
data_view = og.AttributeValueHelper(self._attributes.play)
return data_view.get()
@play.setter
def play(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.play)
data_view = og.AttributeValueHelper(self._attributes.play)
data_view.set(value)
@property
def startValue(self):
data_view = og.AttributeValueHelper(self._attributes.startValue)
return data_view.get()
@startValue.setter
def startValue(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.startValue)
data_view = og.AttributeValueHelper(self._attributes.startValue)
data_view.set(value)
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedWriteValues = { }
@property
def finished(self):
data_view = og.AttributeValueHelper(self._attributes.finished)
return data_view.get()
@finished.setter
def finished(self, value):
data_view = og.AttributeValueHelper(self._attributes.finished)
data_view.set(value)
@property
def updated(self):
data_view = og.AttributeValueHelper(self._attributes.updated)
return data_view.get()
@updated.setter
def updated(self, value):
data_view = og.AttributeValueHelper(self._attributes.updated)
data_view.set(value)
@property
def value(self):
data_view = og.AttributeValueHelper(self._attributes.value)
return data_view.get()
@value.setter
def value(self, value):
data_view = og.AttributeValueHelper(self._attributes.value)
data_view.set(value)
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnTimerDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnTimerDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnTimerDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
| 8,310 | Python | 43.924324 | 159 | 0.644404 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnReadPrimsDatabase.py | """Support for simplified access to data on nodes of type omni.graph.nodes.ReadPrims
DEPRECATED - use ReadPrimsV2!
"""
import numpy
import usdrt
import carb
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnReadPrimsDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.nodes.ReadPrims
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.applySkelBinding
inputs.attrNamesToImport
inputs.computeBoundingBox
inputs.pathPattern
inputs.prims
inputs.typePattern
inputs.usdTimecode
inputs.useFindPrims
Outputs:
outputs.primsBundle
State:
state.applySkelBinding
state.attrNamesToImport
state.computeBoundingBox
state.pathPattern
state.primPaths
state.typePattern
state.usdTimecode
state.useFindPrims
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:applySkelBinding', 'bool', 0, 'Apply Skel Binding', 'If an input USD prim is skinnable and has the SkelBindingAPI schema applied, read skeletal data and apply SkelBinding to deform the prim.\nThe output bundle will have additional child bundles created to hold data for the skeleton and skel animation prims if present. After\nevaluation, deformed points and normals will be written to the `points` and `normals` attributes, while non-deformed points and normals\nwill be copied to the `points:default` and `normals:default` attributes.', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''),
('inputs:attrNamesToImport', 'string', 0, 'Attribute Name Pattern', "A list of wildcard patterns used to match the attribute names that are to be imported\n\nSupported syntax of wildcard pattern:\n '*' - match an arbitrary number of any characters\n '?' - match any single character\n '^' - (caret) is used to define a pattern that is to be excluded\n\nExample of wildcard patterns, input: ['points', 'faceVertexCount', 'faceVertexIndices', 'size']\n '*' - match any\n '* ^points' - match any, but exclude 'points'\n '* ^face*' - match any, but exclude 'faceVertexCount' and 'faceVertexIndices'", {ogn.MetadataKeys.DEFAULT: '"*"'}, True, "*", False, ''),
('inputs:computeBoundingBox', 'bool', 0, 'Compute Bounding Box', "For each primitive compute local bounding box and store them as 'bboxMinCorner', 'bboxMaxCorner' and 'bboxTransform' attributes.", {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''),
('inputs:pathPattern', 'string', 0, 'Prim Path Pattern', "A list of wildcard patterns used to match the prim paths that are to be imported\n\nSupported syntax of wildcard pattern:\n '*' - match an arbitrary number of any characters\n '?' - match any single character\n '^' - (caret) is used to define a pattern that is to be excluded\n\nExample of wildcard patterns, input: ['/Cube0', '/Cube1', '/Box']\n '*' - match any\n '* ^/Box' - match any, but exclude '/Box'\n '* ^/Cube*' - match any, but exclude '/Cube0' and '/Cube1'", {ogn.MetadataKeys.DEFAULT: '""'}, True, "", False, ''),
('inputs:prims', 'target', 0, None, "The prims to be read from when 'useFindPrims' is false", {ogn.MetadataKeys.ALLOW_MULTI_INPUTS: '1'}, False, [], False, ''),
('inputs:typePattern', 'string', 0, 'Prim Type Pattern', "A list of wildcard patterns used to match the prim types that are to be imported\n\nSupported syntax of wildcard pattern:\n '*' - match an arbitrary number of any characters\n '?' - match any single character\n '^' - (caret) is used to define a pattern that is to be excluded\n\nExample of wildcard patterns, input: ['Mesh', 'Cone', 'Cube']\n '*' - match any\n '* ^Mesh' - match any, but exclude 'Mesh'\n '* ^Cone ^Cube' - match any, but exclude 'Cone' and 'Cube'", {ogn.MetadataKeys.DEFAULT: '"*"'}, True, "*", False, ''),
('inputs:usdTimecode', 'timecode', 0, 'Time', 'The time at which to evaluate the transform of the USD prim. A value of "NaN" indicates that the default USD time stamp should be used', {ogn.MetadataKeys.DEFAULT: '"NaN"'}, True, float("NaN"), False, ''),
('inputs:useFindPrims', 'bool', 0, 'Use Find Prims', "When true, the 'pathPattern' and 'typePattern' attribute is used as the pattern to search for the prims to read\notherwise it will read the connection at the 'prim' attribute.", {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''),
('outputs:primsBundle', 'bundle', 0, None, 'An output bundle containing multiple prims as children.\nEach child contains data attributes and two additional token attributes named sourcePrimPath and sourcePrimType\nwhich contains the path of the Prim being read', {}, True, None, False, ''),
('state:applySkelBinding', 'bool', 0, None, 'State from previous evaluation', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''),
('state:attrNamesToImport', 'string', 0, None, 'State from previous evaluation', {}, True, None, False, ''),
('state:computeBoundingBox', 'bool', 0, None, 'State from previous evaluation', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''),
('state:pathPattern', 'string', 0, None, 'State from previous evaluation', {}, True, None, False, ''),
('state:primPaths', 'uint64[]', 0, None, 'State from previous evaluation', {}, True, None, False, ''),
('state:typePattern', 'string', 0, None, 'State from previous evaluation', {}, True, None, False, ''),
('state:usdTimecode', 'timecode', 0, None, 'State from previous evaluation', {ogn.MetadataKeys.DEFAULT: '-1'}, True, -1, False, ''),
('state:useFindPrims', 'bool', 0, None, 'State from previous evaluation', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''),
])
@classmethod
def _populate_role_data(cls):
"""Populate a role structure with the non-default roles on this node type"""
role_data = super()._populate_role_data()
role_data.inputs.attrNamesToImport = og.AttributeRole.TEXT
role_data.inputs.pathPattern = og.AttributeRole.TEXT
role_data.inputs.prims = og.AttributeRole.TARGET
role_data.inputs.typePattern = og.AttributeRole.TEXT
role_data.inputs.usdTimecode = og.AttributeRole.TIMECODE
role_data.outputs.primsBundle = og.AttributeRole.BUNDLE
role_data.state.attrNamesToImport = og.AttributeRole.TEXT
role_data.state.pathPattern = og.AttributeRole.TEXT
role_data.state.typePattern = og.AttributeRole.TEXT
role_data.state.usdTimecode = og.AttributeRole.TIMECODE
return role_data
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = []
self._batchedReadValues = []
@property
def applySkelBinding(self):
data_view = og.AttributeValueHelper(self._attributes.applySkelBinding)
return data_view.get()
@applySkelBinding.setter
def applySkelBinding(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.applySkelBinding)
data_view = og.AttributeValueHelper(self._attributes.applySkelBinding)
data_view.set(value)
@property
def attrNamesToImport(self):
data_view = og.AttributeValueHelper(self._attributes.attrNamesToImport)
return data_view.get()
@attrNamesToImport.setter
def attrNamesToImport(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.attrNamesToImport)
data_view = og.AttributeValueHelper(self._attributes.attrNamesToImport)
data_view.set(value)
self.attrNamesToImport_size = data_view.get_array_size()
@property
def computeBoundingBox(self):
data_view = og.AttributeValueHelper(self._attributes.computeBoundingBox)
return data_view.get()
@computeBoundingBox.setter
def computeBoundingBox(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.computeBoundingBox)
data_view = og.AttributeValueHelper(self._attributes.computeBoundingBox)
data_view.set(value)
@property
def pathPattern(self):
data_view = og.AttributeValueHelper(self._attributes.pathPattern)
return data_view.get()
@pathPattern.setter
def pathPattern(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.pathPattern)
data_view = og.AttributeValueHelper(self._attributes.pathPattern)
data_view.set(value)
self.pathPattern_size = data_view.get_array_size()
@property
def prims(self):
data_view = og.AttributeValueHelper(self._attributes.prims)
return data_view.get()
@prims.setter
def prims(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.prims)
data_view = og.AttributeValueHelper(self._attributes.prims)
data_view.set(value)
self.prims_size = data_view.get_array_size()
@property
def typePattern(self):
data_view = og.AttributeValueHelper(self._attributes.typePattern)
return data_view.get()
@typePattern.setter
def typePattern(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.typePattern)
data_view = og.AttributeValueHelper(self._attributes.typePattern)
data_view.set(value)
self.typePattern_size = data_view.get_array_size()
@property
def usdTimecode(self):
data_view = og.AttributeValueHelper(self._attributes.usdTimecode)
return data_view.get()
@usdTimecode.setter
def usdTimecode(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.usdTimecode)
data_view = og.AttributeValueHelper(self._attributes.usdTimecode)
data_view.set(value)
@property
def useFindPrims(self):
data_view = og.AttributeValueHelper(self._attributes.useFindPrims)
return data_view.get()
@useFindPrims.setter
def useFindPrims(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.useFindPrims)
data_view = og.AttributeValueHelper(self._attributes.useFindPrims)
data_view.set(value)
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self.__bundles = og.BundleContainer(context, node, attributes, [], read_only=False, gpu_ptr_kinds={})
self._batchedWriteValues = { }
@property
def primsBundle(self) -> og.BundleContents:
"""Get the bundle wrapper class for the attribute outputs.primsBundle"""
return self.__bundles.primsBundle
@primsBundle.setter
def primsBundle(self, bundle: og.BundleContents):
"""Overwrite the bundle attribute outputs.primsBundle with a new bundle"""
if not isinstance(bundle, og.BundleContents):
carb.log_error("Only bundle attributes can be assigned to another bundle attribute")
self.__bundles.primsBundle.bundle = bundle
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self.attrNamesToImport_size = None
self.pathPattern_size = None
self.primPaths_size = None
self.typePattern_size = None
@property
def applySkelBinding(self):
data_view = og.AttributeValueHelper(self._attributes.applySkelBinding)
return data_view.get()
@applySkelBinding.setter
def applySkelBinding(self, value):
data_view = og.AttributeValueHelper(self._attributes.applySkelBinding)
data_view.set(value)
@property
def attrNamesToImport(self):
data_view = og.AttributeValueHelper(self._attributes.attrNamesToImport)
self.attrNamesToImport_size = data_view.get_array_size()
return data_view.get()
@attrNamesToImport.setter
def attrNamesToImport(self, value):
data_view = og.AttributeValueHelper(self._attributes.attrNamesToImport)
data_view.set(value)
self.attrNamesToImport_size = data_view.get_array_size()
@property
def computeBoundingBox(self):
data_view = og.AttributeValueHelper(self._attributes.computeBoundingBox)
return data_view.get()
@computeBoundingBox.setter
def computeBoundingBox(self, value):
data_view = og.AttributeValueHelper(self._attributes.computeBoundingBox)
data_view.set(value)
@property
def pathPattern(self):
data_view = og.AttributeValueHelper(self._attributes.pathPattern)
self.pathPattern_size = data_view.get_array_size()
return data_view.get()
@pathPattern.setter
def pathPattern(self, value):
data_view = og.AttributeValueHelper(self._attributes.pathPattern)
data_view.set(value)
self.pathPattern_size = data_view.get_array_size()
@property
def primPaths(self):
data_view = og.AttributeValueHelper(self._attributes.primPaths)
self.primPaths_size = data_view.get_array_size()
return data_view.get()
@primPaths.setter
def primPaths(self, value):
data_view = og.AttributeValueHelper(self._attributes.primPaths)
data_view.set(value)
self.primPaths_size = data_view.get_array_size()
@property
def typePattern(self):
data_view = og.AttributeValueHelper(self._attributes.typePattern)
self.typePattern_size = data_view.get_array_size()
return data_view.get()
@typePattern.setter
def typePattern(self, value):
data_view = og.AttributeValueHelper(self._attributes.typePattern)
data_view.set(value)
self.typePattern_size = data_view.get_array_size()
@property
def usdTimecode(self):
data_view = og.AttributeValueHelper(self._attributes.usdTimecode)
return data_view.get()
@usdTimecode.setter
def usdTimecode(self, value):
data_view = og.AttributeValueHelper(self._attributes.usdTimecode)
data_view.set(value)
@property
def useFindPrims(self):
data_view = og.AttributeValueHelper(self._attributes.useFindPrims)
return data_view.get()
@useFindPrims.setter
def useFindPrims(self, value):
data_view = og.AttributeValueHelper(self._attributes.useFindPrims)
data_view.set(value)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnReadPrimsDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnReadPrimsDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnReadPrimsDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
| 18,349 | Python | 52.654971 | 680 | 0.655186 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnAppendPathDatabase.py | """Support for simplified access to data on nodes of type omni.graph.nodes.AppendPath
Generates a path token by appending the given relative path token to the given root or prim path token
"""
from typing import Any
import omni.graph.core as og
import omni.graph.core._omni_graph_core as _og
import omni.graph.tools.ogn as ogn
class OgnAppendPathDatabase(og.Database):
"""Helper class providing simplified access to data on nodes of type omni.graph.nodes.AppendPath
Class Members:
node: Node being evaluated
Attribute Value Properties:
Inputs:
inputs.path
inputs.suffix
Outputs:
outputs.path
State:
state.path
state.suffix
"""
# Imprint the generator and target ABI versions in the file for JIT generation
GENERATOR_VERSION = (1, 41, 3)
TARGET_VERSION = (2, 139, 12)
# This is an internal object that provides per-class storage of a per-node data dictionary
PER_NODE_DATA = {}
# This is an internal object that describes unchanging attributes in a generic way
# The values in this list are in no particular order, as a per-attribute tuple
# Name, Type, ExtendedTypeIndex, UiName, Description, Metadata,
# Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg
# You should not need to access any of this data directly, use the defined database interfaces
INTERFACE = og.Database._get_interface([
('inputs:path', 'token,token[]', 1, None, 'The path token(s) to be appended to. Must be a base or prim path (ex. /World)', {}, True, None, False, ''),
('inputs:suffix', 'token', 0, None, 'The prim or prim-property path to append (ex. Cube or Cube.attr)', {}, True, "", False, ''),
('outputs:path', 'token,token[]', 1, None, 'The new path token(s) (ex. /World/Cube or /World/Cube.attr)', {}, True, None, False, ''),
('state:path', 'token', 0, None, 'Snapshot of previously seen path', {}, True, None, False, ''),
('state:suffix', 'token', 0, None, 'Snapshot of previously seen suffix', {}, True, None, False, ''),
])
class ValuesForInputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to input attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedReadAttributes = []
self._batchedReadValues = []
@property
def path(self) -> og.RuntimeAttribute:
"""Get the runtime wrapper class for the attribute inputs.path"""
return og.RuntimeAttribute(self._attributes.path.get_attribute_data(), self._context, True)
@path.setter
def path(self, value_to_set: Any):
"""Assign another attribute's value to outputs.path"""
if isinstance(value_to_set, og.RuntimeAttribute):
self.path.value = value_to_set.value
else:
self.path.value = value_to_set
@property
def suffix(self):
data_view = og.AttributeValueHelper(self._attributes.suffix)
return data_view.get()
@suffix.setter
def suffix(self, value):
if self._setting_locked:
raise og.ReadOnlyError(self._attributes.suffix)
data_view = og.AttributeValueHelper(self._attributes.suffix)
data_view.set(value)
def _prefetch(self):
readAttributes = self._batchedReadAttributes
newValues = _og._prefetch_input_attributes_data(readAttributes)
if len(readAttributes) == len(newValues):
self._batchedReadValues = newValues
class ValuesForOutputs(og.DynamicAttributeAccess):
LOCAL_PROPERTY_NAMES = { }
"""Helper class that creates natural hierarchical access to output attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
self._batchedWriteValues = { }
@property
def path(self) -> og.RuntimeAttribute:
"""Get the runtime wrapper class for the attribute outputs.path"""
return og.RuntimeAttribute(self._attributes.path.get_attribute_data(), self._context, False)
@path.setter
def path(self, value_to_set: Any):
"""Assign another attribute's value to outputs.path"""
if isinstance(value_to_set, og.RuntimeAttribute):
self.path.value = value_to_set.value
else:
self.path.value = value_to_set
def _commit(self):
_og._commit_output_attributes_data(self._batchedWriteValues)
self._batchedWriteValues = { }
class ValuesForState(og.DynamicAttributeAccess):
"""Helper class that creates natural hierarchical access to state attributes"""
def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface):
"""Initialize simplified access for the attribute data"""
context = node.get_graph().get_default_graph_context()
super().__init__(context, node, attributes, dynamic_attributes)
@property
def path(self):
data_view = og.AttributeValueHelper(self._attributes.path)
return data_view.get()
@path.setter
def path(self, value):
data_view = og.AttributeValueHelper(self._attributes.path)
data_view.set(value)
@property
def suffix(self):
data_view = og.AttributeValueHelper(self._attributes.suffix)
return data_view.get()
@suffix.setter
def suffix(self, value):
data_view = og.AttributeValueHelper(self._attributes.suffix)
data_view.set(value)
def __init__(self, node):
super().__init__(node)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT)
self.inputs = OgnAppendPathDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
self.outputs = OgnAppendPathDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
self.state = OgnAppendPathDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
| 7,012 | Python | 44.836601 | 158 | 0.644324 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.