-
Notifications
You must be signed in to change notification settings - Fork 3
/
quick_checker.py
83 lines (59 loc) · 2.02 KB
/
quick_checker.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import maya.cmds as cmds
qc_selected_objects = ""
# TEST Reset the scene to the original state
def QC_TestResetScene():
cmds.select(all=True)
cmds.delete()
# TEST Reset hypeshade to the original state
def QC_TestResetHypershade():
materials = cmds.ls(type='shadingDependNode')
cmds.delete(materials)
def QC_NewCheckerMaterial():
# Creates a new lambert
myMaterial = cmds.shadingNode('lambert', asShader=True)
# Creates a shading node for the file
myChecker = cmds.shadingNode('checker', asTexture=True)
myPlaceTex = cmds.shadingNode('place2dTexture', asUtility=True)
cmds.setAttr(myPlaceTex+'.repeatU', 10)
cmds.setAttr(myPlaceTex+'.repeatV', 10)
cmds.connectAttr(myPlaceTex+'.outUV', myChecker+'.uv')
cmds.connectAttr(myPlaceTex+'.outUvFilterSize', myChecker+'.uvFilterSize')
cmds.connectAttr(myChecker+'.outColor', myMaterial+'.color')
return myMaterial
def QC_ApplyMaterialToSelectedMesh(material):
global qc_selected_objects
# Gets the selected objects and applies the new material
cmds.select(qc_selected_objects)
cmds.hyperShade(assign=material)
def QC_QuickChecker():
global qc_selected_objects
qc_selected_objects = cmds.ls(sl=True)
myMaterial = QC_NewCheckerMaterial()
QC_ApplyMaterialToSelectedMesh(myMaterial)
def QC_FunctionalTest1():
# Resets everything
QC_TestResetScene()
QC_TestResetHypershade()
# Creates a sphere
cmds.polySphere(n='Object001')
cmds.select('Object001')
# Runs the script
QC_QuickChecker()
def QC_FunctionalTest2():
# Resets everything
QC_TestResetScene()
QC_TestResetHypershade()
# Creates two spheres
cmds.polySphere(n='Object001')
cmds.polySphere(n='Object002')
# Moves the spheres
cmds.move(0, 0, 0, 'Object001')
cmds.move(2, 0, 0, 'Object002')
# Selects the spheres
cmds.select('Object001')
cmds.select('Object002', add=True)
# Runs the script
QC_QuickChecker()
# QC_FunctionalTest1()
# QC_FunctionalTest2()
QC_QuickChecker()