1. ArtEase Rule Definition
Before creating rules in Maya, you will need to create a Maya-type rule scheme in your group's rule schemes, then click New Rule to create a rule in Maya.
2. Fields used for Maya Rules
Field | Description |
---|---|
Applicable Version | Range of recorded rules applicable |
Object | Classification of objects to which the rule applies |
Severity | Error level when a rule does not pass |
desc | Rule description |
type | Rule classification - currently only supports function, tool_function, and global_function. Core field |
condition | function name for rule execution. Core field |
func_str | Body of the function of rule execution. Core field |
enable_para | Whether custom parameters are enabled |
rule_para | Custom parameter, obtained in the function body usingrule=argv.get(‘rule’),rule_para = rule.get(‘rule_para’) |
enable_batch | Whether batch inspection is supported. Not currently supported. |
changable | Whether it is possible to change setting values. Not currently supported. |
3. Executing Rules in Maya When using the ArtEase plug-in in Maya, defined rules will be pulled locally and finally run in Maya, so the key content is still the operation process within Maya. In general, function content is split into three parts. Here we will use a function that obtains unknown dependencies as an example.
def CheckUnknownPlugin(**kargv):
from maya import cmds
lUnknown = cmds.unknownPlugin(q=True, l=True)
state = True
msg = str()
if lUnknown:
state = False
msg = u"has unknown Plug dependency:{}".format("\n".join(lUnknown))
return state, msg, False
4. Function and Tool_Function Rule Examples
function represents an ordinary rule, and is well-suited to rules that require frequent testing, for instance whether or not a resource meets design standards.
tool_function represents a function rule, presented as a button, and which will not be triggered by a one-click check. The button must be pushed separately in order to trigger it. It is well-suited for rules that are not checked as frequently or for rules which change resources when carried out.
global_function represents global rules, in which there is no need to select any objects. Suitable for global inspection rules.
These three types of rule all support custom-selected objects and are not require an object to be selected.
1.Function Rules
def CheckUnits(**kargv):
from maya import cmds
units = cmds.currentUnit(q=True, linear=True)
state = True
msg = str()
if units != "cm":
state = False
msg = u"the unit installed must be centimeters"
return state, msg, False
2.Tool_function Rule
def Check_Name(**argv):
from maya import cmds
rule=argv.get("rule")
rule_para = rule.get("rule_para")
obj_list = cmds.ls(sl=True)
name_list = []
for obj in obj_list:
obj_name = str(obj)
if obj_name.startswith(rule_para):
continue
else:
name_list.append(obj_name)
if name_list:
return False, name_list, False
else:
return True,[],False
The tool_function rule is carried out by pushing a button in the plug-in.