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 set_attribute_toggle_locked_on_collection(col, value): """ Set the value of 'Attributes Toggle Locked' on a Collection. :param col: The Collection to change. :type col: Collection :param value: Value to set to. :type value: bool """ assert isinstance(value, bool) ensure_attribute_toggle_locked_attr_exists(col) node = col.get_node() configmaya.set_node_option(node, const.ATTRIBUTE_TOGGLE_LOCKED_ATTR, value) return
def set_object_toggle_bundle_on_collection(col, value): """ Set the value of 'Objects Toggle Bundle' on a Collection. :param col: The Collection to change. :type col: Collection :param value: Value to set to. :type value: bool """ assert isinstance(value, bool) ensure_object_toggle_bundle_attr_exists(col) node = col.get_node() configmaya.set_node_option(node, const.OBJECT_TOGGLE_BUNDLE_ATTR, value) return
def set_override_current_frame_on_collection(col, value): """ Set the value of 'Override Current Frame' on a Collection. :param col: The Collection to change. :type col: Collection :param value: Value to set to. :type value: bool """ assert isinstance(value, bool) ensure_override_current_frame_attr_exists(col) node = col.get_node() configmaya.set_node_option(node, const.OVERRIDE_CURRENT_FRAME_ATTR, value) return
def set_value_on_node_attr(node_name, attr_name, data): """ Set value onto a node.attr path. :param node_name: Node to store value on. :type node_name: str :param attr_name: Attribute name to store value with. :type attr_name: str :param data: The numeric value to store. :type data: bool or float or int ;return: Nothing. :rtype: None """ msg = 'Use `mmSolver.utils.configmaya` module' warnings.warn(msg, DeprecationWarning) configmaya.set_node_option(node_name, attr_name, data) return