def test_get_node_option(self): node = 'my_option_node' node = maya.cmds.createNode('script', name=node) name = 'my_int_attr' value = configmaya.get_node_option(node, name) self.assertIsNone(value) value = 42 regex = 'setAttr: No object matches name: .+' with self.assertRaisesRegexp(RuntimeError, regex): configmaya.set_node_option(node, name, value) configmaya.set_node_option(node, name, value, add_attr=True) new_value = configmaya.get_node_option(node, name) self.assertEqual(new_value, value) name = 'my_float_attr' value = 3.0 configmaya.set_node_option(node, name, value, add_attr=True) new_value = configmaya.get_node_option(node, name) self.assertEqual(new_value, value) name = 'my_bool_attr' value = True configmaya.set_node_option(node, name, value, add_attr=True) new_value = configmaya.get_node_option(node, name) self.assertEqual(new_value, value) name = 'my_string_attr' value = 'hello world' configmaya.set_node_option(node, name, value, add_attr=True) new_value = configmaya.get_node_option(node, name) self.assertEqual(new_value, value) return
def get_object_toggle_bundle_from_collection(col): """ Get the value of 'Objects Toggle Bundle', from a Collection. :param col: The Collection to query. :type col: Collection :returns: True or False. :rtype: bool """ node = col.get_node() ensure_object_toggle_bundle_attr_exists(col) value = configmaya.get_node_option(node, const.OBJECT_TOGGLE_BUNDLE_ATTR) assert isinstance(value, bool) return value
def get_override_current_frame_from_collection(col): """ Get the value of 'Override Current Frame', from a Collection. :param col: The Collection to query. :type col: Collection :returns: True or False. :rtype: bool """ node = col.get_node() ensure_override_current_frame_attr_exists(col) value = configmaya.get_node_option(node, const.OVERRIDE_CURRENT_FRAME_ATTR) assert isinstance(value, bool) return value
def get_attribute_toggle_locked_from_collection(col): """ Get the value of 'Attributes Toggle Locked', from a Collection. :param col: The Collection to query. :type col: Collection :returns: True or False. :rtype: bool """ node = col.get_node() ensure_attribute_toggle_locked_attr_exists(col) value = configmaya.get_node_option(node, const.ATTRIBUTE_TOGGLE_LOCKED_ATTR) assert isinstance(value, bool) return value
def get_value_on_node_attr(node_name, attr_name): """ Get numeric value from an node attribute. :param node_name: Node to get value from. :type node_name: str :param attr_name: The name of the attribute to get value from. :type attr_name: str :return: A numeric value. :rtype: bool or float or int """ msg = 'Use `mmSolver.utils.configmaya` module' warnings.warn(msg, DeprecationWarning) value = configmaya.get_node_option(node_name, attr_name) return value