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. 10.png
11.png

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
1.Introduce the Maya functions needed for the rules. We recommend using cmds and pyxms libraries for developement. 2.The content of the function to be carried out,the rule here is to select the unknown dependencies in the scene. In cmds, there are already encapsulated functions, so this can be done directly. 3.The three return values' definitions are fixed in writing. The state is bool, indicating whether or not the rule has passed the inspection. Msg is the information displayed when the rule is not passed. The last value is whether to skip the check; if it is skipped, it will no longer be shown in the results.

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
Function and global_function rules can usualy be used as a kind of body in a scene or standard of judgement; the above is to judge whether the current scene has set cm as the unit of measurement. If the test is not satisfied, it will return 'False'. The function rule is carried out in the plug-in by checking boxes. Obtain dynamic transmission parameters through rule and rule_para.
12.png
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
Tool_function rules can usually be carried out as a kind of function or modify attributes, and suppports custom parameters. If an object in the current scene is selected, the naming prefix must satisfy certain criteria. Obtain dynamic transmission parameters through rule and rule_para, implement Maya's corresponding commmands.
The tool_function rule is carried out by pushing a button in the plug-in.
13.png