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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
|
"""
Author: Jeremy Ernst
This is the base class from which all modules are created. When creating a new module,
your module class should inherit from this base class. Example:
| class ART_Head(ART_RigModule)
In the __init__ of your module class, you will want to also run the base class __init__
at the end of your module class __init__:
| ART_RigModule.__init__(self, "ART_Head_Module", "ART_Head", moduleUserName)
This module has two file attributes set by default. Your module class will need many more
file attributes set. Please see another module as an example.
########
Contents
########
| **Module Creation Functions:**
| :func:`addAttributes <System.ART_RigModule.ART_RigModule.addAttributes>`
| :func:`buildNetwork <System.ART_RigModule.ART_RigModule.buildNetwork>`
| :func:`createMirrorModule <System.ART_RigModule.ART_RigModule.createMirrorModule>`
| :func:`jointMover_Build <System.ART_RigModule.ART_RigModule.jointMover_Build>`
| :func:`skeletonSettings_UI <System.ART_RigModule.ART_RigModule.skeletonSettings_UI>`
|
| **Module Update Functions:**
| :func:`applyModuleChanges <System.ART_RigModule.ART_RigModule.applyModuleChanges>`
| :func:`checkForDependencies <System.ART_RigModule.ART_RigModule.checkForDependencies>`
| :func:`deleteModule <System.ART_RigModule.ART_RigModule.deleteModule>`
|
| **Module Settings and Interface Functions:**
| :func:`changeModuleName <System.ART_RigModule.ART_RigModule.changeModuleName>`
| :func:`changeModuleParent <System.ART_RigModule.ART_RigModule.changeModuleParent>`
| :func:`copySettings <System.ART_RigModule.ART_RigModule.copySettings>`
| :func:`pasteSettings <System.ART_RigModule.ART_RigModule.pasteSettings>`
| :func:`resetSettings <System.ART_RigModule.ART_RigModule.resetSettings>`
| :func:`createContextMenu <System.ART_RigModule.ART_RigModule.createContextMenu>`
| :func:`createMirrorOfModule_UI <System.ART_RigModule.ART_RigModule.createMirrorOfModule_UI>`
| :func:`createScriptJob <System.ART_RigModule.ART_RigModule.createScriptJob>`
| :func:`mirrorTransformations <System.ART_RigModule.ART_RigModule.mirrorTransformations>`
| :func:`mirrorTransformations_Custom <System.ART_RigModule.ART_RigModule.mirrorTransformations_Custom>`
| :func:`resetTransforms <System.ART_RigModule.ART_RigModule.resetTransforms>`
| :func:`setMirrorModule <System.ART_RigModule.ART_RigModule.setMirrorModule>`
| :func:`updateBoneCount <System.ART_RigModule.ART_RigModule.updateBoneCount>`
| :func:`updatePreview <System.ART_RigModule.ART_RigModule.updatePreview>`
| :func:`updateSettingsUI <System.ART_RigModule.ART_RigModule.updateSettingsUI>`
|
| **Module Joint Mover Functions:**
| :func:`addJointMoverToOutliner <System.ART_RigModule.ART_RigModule.addJointMoverToOutliner>`
| :func:`aimMode <System.ART_RigModule.ART_RigModule.aimMode>`
| :func:`aimMode_Setup <System.ART_RigModule.ART_RigModule.aimMode_Setup>`
| :func:`bakeOffsets <System.ART_RigModule.ART_RigModule.bakeOffsets>`
| :func:`createGlobalMoverButton <System.ART_RigModule.ART_RigModule.createGlobalMoverButton>`
| :func:`createMeshMoverButton <System.ART_RigModule.ART_RigModule.createMeshMoverButton>`
| :func:`createOffsetMoverButton <System.ART_RigModule.ART_RigModule.createOffsetMoverButton>`
| :func:`pinModule <System.ART_RigModule.ART_RigModule.pinModule>`
| :func:`selectMover <System.ART_RigModule.ART_RigModule.selectMover>`
| :func:`selectScriptJob <System.ART_RigModule.ART_RigModule.selectScriptJob>`
| :func:`toggleShapeVis <System.ART_RigModule.ART_RigModule.toggleShapeVis>`
| :func:`updateOutliner <System.ART_RigModule.ART_RigModule.updateOutliner>`
|
| **Module Publish Functions:**
| :func:`cleanUpRigPose <System.ART_RigModule.ART_RigModule.cleanUpRigPose>`
| :func:`createRigPoseSliderForJoint <System.ART_RigModule.ART_RigModule.createRigPoseSliderForJoint>`
| :func:`getReferencePose <System.ART_RigModule.ART_RigModule.getReferencePose>`
| :func:`matchModelPose <System.ART_RigModule.ART_RigModule.matchModelPose>`
| :func:`mirrorTransformations_RigPose <System.ART_RigModule.ART_RigModule.mirrorTransformations_RigPose>`
| :func:`resetRigPose <System.ART_RigModule.ART_RigModule.resetRigPose>`
| :func:`resetRigPose_Part <System.ART_RigModule.ART_RigModule.resetRigPose_Part>`
| :func:`rigPose_UI <System.ART_RigModule.ART_RigModule.rigPose_UI>`
| :func:`setPosePercentage <System.ART_RigModule.ART_RigModule.setPosePercentage>`
| :func:`setPosePercentage_Part <System.ART_RigModule.ART_RigModule.setPosePercentage_Part>`
| :func:`setReferencePose <System.ART_RigModule.ART_RigModule.setReferencePose>`
| :func:`setReferencePoseSlider <System.ART_RigModule.ART_RigModule.setReferencePoseSlider>`
| :func:`setSkeletonPose <System.ART_RigModule.ART_RigModule.setSkeletonPose>`
| :func:`setupForRigPose <System.ART_RigModule.ART_RigModule.setupForRigPose>`
| :func:`setupModelPoseForRig <System.ART_RigModule.ART_RigModule.setupModelPoseForRig>`
| :func:`skinProxyGeo <System.ART_RigModule.ART_RigModule.skinProxyGeo>`
| :func:`updateRigPose <System.ART_RigModule.ART_RigModule.updateRigPose>`
|
| **Module Rig Functions**
| :func:`buildRig <System.ART_RigModule.ART_RigModule.buildRig>`
| :func:`buildRigCustom <System.ART_RigModule.ART_RigModule.buildRigCustom>`
| :func:`deleteRig <System.ART_RigModule.ART_RigModule.deleteRig>`
| :func:`getControls <System.ART_RigModule.ART_RigModule.getControls>`
| :func:`importFBX <System.ART_RigModule.ART_RigModule.importFBX>`
| :func:`importFBX_pre <System.ART_RigModule.ART_RigModule.importFBX_pre>`
| :func:`resetRigControls <System.ART_RigModule.ART_RigModule.resetRigControls>`
| :func:`selectRigControls <System.ART_RigModule.ART_RigModule.selectRigControls>`
| :func:`selectionScriptJob_animUI <System.ART_RigModule.ART_RigModule.selectionScriptJob_animUI>`
|
| **Module Utility Functions**
| :func:`getAllModules <System.ART_RigModule.ART_RigModule.getAllModules>`
| :func:`getModules <System.ART_RigModule.ART_RigModule.getModules>`
| :func:`removeSkeletalConstraints <System.ART_RigModule.ART_RigModule.removeSkeletalConstraints>`
| :func:`returnCreatedJoints <System.ART_RigModule.ART_RigModule.returnCreatedJoints>`
| :func:`returnJointMovers <System.ART_RigModule.ART_RigModule.returnJointMovers>`
| :func:`returnMirrorModuleInst <System.ART_RigModule.ART_RigModule.returnMirrorModuleInst>`
| :func:`returnNetworkNode <System.ART_RigModule.ART_RigModule.returnNetworkNode>`
| :func:`returnPrefixSuffix <System.ART_RigModule.ART_RigModule.returnPrefixSuffix>`
| :func:`returnRigNetworkNode <System.ART_RigModule.ART_RigModule.returnRigNetworkNode>`
|
|
#########
Class
#########
"""
# file imports
import json
import os
import traceback
from functools import partial
import System.interfaceUtils as interfaceUtils
import System.riggingUtils as riggingUtils
import System.utils as utils
import System.mathUtils as mathUtils
import maya.cmds as cmds
import maya.mel as mel
from ThirdParty.Qt import QtGui, QtCore, QtWidgets
# file attributes
fbxImport = ["None", "FK"]
matchData = [False, None]
class ART_RigModule():
def __init__(self, moduleName, moduleType, userCreatedName):
"""Initiate the class, taking in the instance to the interface and the user specified name.
:param moduleName: This is the base name of the module, specified in the rig module.
:param moduleType: This is the name of the module to create (the module class).
:param userCreatedName: This is the name specified by the user on module creation.
Instantiate the following class variables as well:
* **self.modName:** Take the passed in moduleName and make it a class var
* **self.moduleType:** Take the passed in moduleType and make it a class var
* **self.rootMod:** The network node of the entire character asset
* **self.name:** The user created name (prefix + baseName + suffix) passed in
* **self.originalName:** Also the user created name, but we want to store what the original name
was on creation, as the user can rename the module later. This will allow us to make the link between
what the module's original name was and what the new name is.
* **self.outlinerControls:** A list of the outliner controls created when adding module joint movers to
the outliner.
Also, read the QSettings to find out where needed paths are.
"""
# set class variables
self.modName = moduleName
self.moduleType = moduleType
self.rootMod = None
self.name = userCreatedName
self.originalName = userCreatedName
self.outlinerControls = []
self.controlTypes = []
# get the directory path of the tools
settings = QtCore.QSettings("Epic Games", "ARTv2")
self.toolsPath = settings.value("toolsPath")
self.iconsPath = settings.value("iconPath")
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def buildNetwork(self):
"""
Build the network node for the module which will store all information needed by the module.
Then, call on addAttributes to add the required module attributes to the network node.
"""
# create the network node for our module
self.networkNode = cmds.createNode("network", name=self.modName)
# create attributes
self.addAttributes()
return self.networkNode
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def addAttributes(self):
"""
Add attributes to the network node that all modules need.
"""
if self.moduleType == None:
# add attributes specific to this module
cmds.addAttr(self.networkNode, sn="rigModules", at="message")
else:
# add a rigging message attribute
cmds.addAttr(self.networkNode, sn="parent", at="message")
# add a module type attribute
cmds.addAttr(self.networkNode, sn="moduleType", dt="string", keyable=False)
cmds.setAttr(self.networkNode + ".moduleType", self.moduleType, type="string", lock=True)
# and a module name attribute (used for skeleton settings UI groupbox label)
cmds.addAttr(self.networkNode, sn="moduleName", dt="string", keyable=False)
cmds.setAttr(self.networkNode + ".moduleName", self.name, type="string", lock=True)
# add attr for parent module that user specfies
cmds.addAttr(self.networkNode, sn="parentModuleBone", dt="string", keyable=False)
# add attr for mirror module that user specfies
cmds.addAttr(self.networkNode, sn="mirrorModule", dt="string", keyable=False)
cmds.addAttr(self.networkNode, sn="pinned", at="bool", keyable=False)
cmds.setAttr(self.networkNode + ".pinned", False, lock=True)
# connect rigModule to root module node
self.rootMod = self.getModules
if self.rootMod != None:
cmds.connectAttr(self.rootMod + ".rigModules", self.networkNode + ".parent")
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def skeletonSettings_UI(self, name, width, height, checkable):
"""
Build the framework for the skeleton settings that all modules need.
:param name: user given name of module (prefix + base_name + suffix)
:param width: width of the skeleton settings groupBox. 335 usually
:param height: height of the skeleton settings groupBox.
:param checkable: Whether or not the groupBox can be collapsed.
"""
# add the groupbox for this module with the module name and module settings
self.groupBox = QtWidgets.QGroupBox(name)
self.groupBox.setGeometry(QtCore.QRect(0, 0, width, height))
self.groupBox.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed))
if not checkable:
self.groupBox.setMinimumSize(QtCore.QSize(width, height))
if checkable:
self.groupBox.setMinimumSize(QtCore.QSize(width, 0))
self.groupBox.setMaximumSize(QtCore.QSize(width, height))
self.groupBox.setFlat(True)
self.groupBox.setCheckable(checkable)
self.lockButton = QtWidgets.QPushButton()
self.lockButton.setMinimumSize(QtCore.QSize(20, 20))
self.lockButton.setMaximumSize(QtCore.QSize(20, 20))
# load style sheet file
styleSheetFile = utils.returnNicePath(self.toolsPath,
"Core/Scripts/Interfaces/StyleSheets/skeletonSettings.qss")
f = open(styleSheetFile, "r")
style = f.read()
f.close()
self.groupBox.setStyleSheet(style)
# set properties for filtering later
self.groupBox.setObjectName(name)
self.groupBox.setProperty("name", name)
# set context menu policy on groupbox
self.groupBox.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.groupBox.customContextMenuRequested.connect(self.createContextMenu)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def changeModuleName(self, baseName, moduleInst, rigUiInst):
"""
Launch the interface that allows users to change the module name.
:param baseName: The module base name (head, torso, leg, etc)
:param moduleInst: The specific instance of the module
:param rigUiInst: The instance of the rig creator interface.
This will call on a separate class in Core/Interfaces called ART_ChangeModuleNameUI.py
"""
# get prefix/suffix
name = self.groupBox.title()
prefix = name.partition(baseName)[0]
suffix = name.partition(baseName)[2]
# when pressing the change name button on the skeleton settings UI (if it exists):
# delete the UI if it already exists
mayaWindow = interfaceUtils.getMainWindow()
mayaWindow = mayaWindow.objectName()
if cmds.window(mayaWindow + "|pyArtChangeModuleNameUi", q=True, exists=True):
cmds.deleteUI(mayaWindow + "|pyArtChangeModuleNameUi")
# launch a UI for prefix/suffix/preview again
import Interfaces.ART_ChangeModuleNameUI as ART_ChangeModuleNameUI
reload(ART_ChangeModuleNameUI)
inst = ART_ChangeModuleNameUI.ART_ChangeModuleName_UI(baseName, moduleInst, rigUiInst, prefix, suffix,
interfaceUtils.getMainWindow())
inst.show()
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def changeModuleParent(self, moduleInst, rigUiInst):
"""
Launch the interface that allows users to change the module's parent bone.
:param moduleInst: The specific instance of the module
:param rigUiInst: The instance of the rig creator interface.
This will call on a separate class in Core/Interfaces called ART_ChangeModuleParentUI.py
"""
# get current parent value
currentParent = self.currentParent.text()
# when pressing the change parent button on the skeleton settings UI (if it exists):
# delete the UI if it already exists
mayaWindow = interfaceUtils.getMainWindow()
mayaWindow = mayaWindow.objectName()
if cmds.window(mayaWindow + "|pyArtChangeModuleParentUi", q=True, exists=True):
cmds.deleteUI(mayaWindow + "|pyArtChangeModuleParentUi")
# launch a UI for prefix/suffix/preview again
import Interfaces.ART_ChangeModuleParentUI as ART_ChangeModuleParentUI
reload(ART_ChangeModuleParentUI)
inst = ART_ChangeModuleParentUI.ART_ChangeModuleParent_UI(currentParent, moduleInst, rigUiInst,
interfaceUtils.getMainWindow())
inst.show()
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def setMirrorModule(self, moduleInst, rigUiInst):
"""
Launch the interface that allows users to change the module's mirror module.
Meaning, the module that is linked as a mirror of this module. Only modules of the same
type can be linked as mirrors.
:param moduleInst: The specific instance of the module
:param rigUiInst: The instance of the rig creator interface.
This will call on a separate class in Core/Interfaces called ART_SetMirrorModuleUI.py
"""
# delete the UI if it already exists
mayaWindow = interfaceUtils.getMainWindow()
mayaWindow = mayaWindow.objectName()
if cmds.window(mayaWindow + "|pyArtSetMirrorModuleUi", q=True, exists=True):
cmds.deleteUI(mayaWindow + "|pyArtSetMirrorModuleUi")
# launch a UI for prefix/suffix/preview again
import Interfaces.ART_SetMirrorModuleUI as ART_SetMirrorModuleUI
reload(ART_SetMirrorModuleUI)
inst = ART_SetMirrorModuleUI.ART_SetMirrorModule_UI(moduleInst, rigUiInst, interfaceUtils.getMainWindow())
inst.show()
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def jointMover_Build(self, path):
"""
Import the joint mover file with the given path.
After importing the module's joint mover file, rename imported nodes to use module name.
Then, assign existing matching materials to joint mover proxy geometry, deleting the imported
materials if they were duplicates. Then parent into the main JointMover group. Lastly, hook up
global scaling on the joint movers.
:param path: Path of joint mover file to import
"""
# get the full path for the joint mover file
fullPath = os.path.join(self.toolsPath, path)
# import the file
if os.path.exists(fullPath):
nodes = cmds.file(fullPath, i=True, iv=True, type="mayaAscii", rnn=True)
validTypes = ["transform", "joint", "ikHandle"]
# loop through returned nodes from import, and find the mover_grp, renaming it and all
# children to have user specified name as prefix
for node in nodes:
if node.find("|mover_grp") == 0:
children = cmds.listRelatives(node, allDescendents=True, type="transform")
moverGrp = node.partition("|")[2]
movers = [moverGrp]
for child in children:
try:
if cmds.nodeType(child) in validTypes:
movers.append(child)
except Exception, e:
print e
for mover in movers:
try:
cmds.rename(mover, self.name + "_" + mover)
except Exception, e:
print mover, self.name + "_" + mover
print str(e)
# exit loop
break
# assign materials if they exist, removing duplicate materials
materials = [["*_blue_m", "blue_m"], ["*_green_m", "green_m"], ["*_red_m", "red_m"],
["*_white_m", "white_m"], ["*_proxy_shader_tan", "proxy_shader_tan"],
["*_proxy_shader_black", "proxy_shader_black"]]
deleteMaterials = []
for material in materials:
try:
# select materials for the joint mover
cmds.select(material[0])
foundMaterials = cmds.ls(sl=True)
# loop through each color material (dupes)
for mat in foundMaterials:
cmds.hyperShade(objects=mat)
assignedGeo = cmds.ls(sl=True)
# select the geo and the original material, and assign
originalMaterial = material[1]
for geo in assignedGeo:
cmds.select([geo, originalMaterial])
cmds.hyperShade(assign=originalMaterial)
# delete the material no longer needed
deleteMaterials.append(mat)
except:
pass
# delete all deleteMaterials
for mat in deleteMaterials:
cmds.delete(mat)
# add to JointMover grp
cmds.refresh(force=True)
if not cmds.objExists("JointMover"):
cmds.group(empty=True, name="JointMover")
try:
cmds.parent("|" + self.name + "_mover_grp", "JointMover")
except Exception, e:
print str(e)
globalMover = utils.findGlobalMoverFromName(self.name)
cmds.select(globalMover)
cmds.setToolTo("moveSuperContext")
# obey visibility toggles
self.rigUiInst.setMoverVisibility()
# 1/13/16 Change # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# hook up global scale on joint movers
try:
movers = self.returnJointMovers
for each in [movers[0], movers[1]]:
for mover in each:
if not cmds.objExists(mover + ".globalScale"):
try:
cmds.aliasAttr("globalScale", mover + ".scaleZ")
cmds.connectAttr(mover + ".globalScale", mover + ".scaleX")
cmds.connectAttr(mover + ".globalScale", mover + ".scaleY")
cmds.setAttr(mover + ".scaleX", keyable=False)
cmds.setAttr(mover + ".scaleY", keyable=False)
except:
pass
# lock movers
for each in movers:
for mover in each:
cmds.lockNode(mover, lock=True)
except:
pass
# 1/13/16 Change # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
else:
cmds.confirmDialog(title="Joint Mover", message="Could not find associated joint mover file.",
icon="critical")
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def selectScriptJob(self, info):
"""
Change icon color of the given joint mover's button in the outliner to show selection status.
:param info: This list contains the button object, the joint mover control, and the original color icon.
If the control given is selected, the icon is switched to a white icon. If it is not selected, the icon
is set back to the original passed in icon.
"""
pixmap = QtGui.QPixmap(20, 15)
pixmap.fill(QtGui.QColor(255, 255, 255))
whiteIcon = QtGui.QIcon(pixmap)
# for each item in the passed in info [outliner button, mover control, unselected stylesheet],check if
# the control is in the selection, and color the button appropriately
for item in info:
button = item[0]
control = item[1]
icon = item[2]
selected = cmds.ls(selection=True)
if control not in selected:
self.outlinerWidgets[button].setIcon(icon)
if control in selected:
self.outlinerWidgets[button].setIcon(whiteIcon)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def createGlobalMoverButton(self, name, parent, uiInstance):
"""
Create the button in the outliner for the global mover control of a joint mover.
:param name: The name of the joint mover control.
:param parent: The outliner widget the created button will be parented to.
:param uiInstance: The Rig Creator interface instance.
"""
part = name.partition(self.name)[2]
# create the icon
pixmap = QtGui.QPixmap(20, 15)
pixmap.fill(QtGui.QColor("yellow"))
icon = QtGui.QIcon(pixmap)
# create the button
self.outlinerWidgets[name + "_globalMoverBtn"] = QtWidgets.QPushButton(icon, "")
self.outlinerWidgets[name + "_globalMoverBtn"].setMinimumSize(QtCore.QSize(20, 15))
self.outlinerWidgets[name + "_globalMoverBtn"].setMaximumSize(QtCore.QSize(20, 15))
uiInstance.treeWidget.setItemWidget(parent, 1, self.outlinerWidgets[name + "_globalMoverBtn"])
# connect and add to list
self.outlinerWidgets[name + "_globalMoverBtn"].clicked.connect(
partial(self.selectMover, part, True, False, False, self.outlinerWidgets[name + "_globalMoverBtn"]))
self.outlinerControls.append([name + "_globalMoverBtn", name + "_mover", icon])
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def createOffsetMoverButton(self, name, parent, uiInstance):
"""
Create the button in the outliner for the offset mover control of a joint mover.
:param name: The name of the joint mover control.
:param parent: The outliner widget the created button will be parented to.
:param uiInstance: The Rig Creator interface instance.
"""
part = name.partition(self.name)[2]
# create the icon
pixmap = QtGui.QPixmap(20, 15)
pixmap.fill(QtGui.QColor(100, 200, 255))
icon = QtGui.QIcon(pixmap)
# create the button
self.outlinerWidgets[name + "_offsetMoverBtn"] = QtWidgets.QPushButton(icon, "")
self.outlinerWidgets[name + "_offsetMoverBtn"].setMinimumSize(QtCore.QSize(20, 15))
self.outlinerWidgets[name + "_offsetMoverBtn"].setMaximumSize(QtCore.QSize(20, 15))
uiInstance.treeWidget.setItemWidget(parent, 2, self.outlinerWidgets[name + "_offsetMoverBtn"])
# connect and add to list
self.outlinerWidgets[name + "_offsetMoverBtn"].clicked.connect(
partial(self.selectMover, part, False, True, False, self.outlinerWidgets[name + "_offsetMoverBtn"]))
self.outlinerControls.append([name + "_offsetMoverBtn", name + "_mover_offset", icon])
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def createMeshMoverButton(self, name, parent, uiInstance):
"""
Create the button in the outliner for the geometry mover control of a joint mover.
:param name: The name of the joint mover control.
:param parent: The outliner widget the created button will be parented to.
:param uiInstance: The Rig Creator interface instance.
Note: The geometry mover is purely for aesthetics and does not affect the rigging.
"""
part = name.partition(self.name)[2]
# create the icon
pixmap = QtGui.QPixmap(20, 15)
pixmap.fill(QtGui.QColor(255, 176, 176))
icon = QtGui.QIcon(pixmap)
# create the button
self.outlinerWidgets[name + "_geoMoverBtn"] = QtWidgets.QPushButton(icon, "")
self.outlinerWidgets[name + "_geoMoverBtn"].setMinimumSize(QtCore.QSize(20, 15))
self.outlinerWidgets[name + "_geoMoverBtn"].setMaximumSize(QtCore.QSize(20, 15))
uiInstance.treeWidget.setItemWidget(parent, 3, self.outlinerWidgets[name + "_geoMoverBtn"])
# connect and add to list
self.outlinerWidgets[name + "_geoMoverBtn"].clicked.connect(
partial(self.selectMover, part, False, False, True, self.outlinerWidgets[name + "_geoMoverBtn"]))
self.outlinerControls.append([name + "_geoMoverBtn", name + "_mover_geo", icon])
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def createScriptJob(self):
"""
Create the selection script job for the outliner buttons and their associated joint mover controls.
This function purely creates the script job. The script job function that is run is called self.selectScriptJob.
"""
self.scriptJob = cmds.scriptJob(
event=["SelectionChanged", partial(self.selectScriptJob, self.outlinerControls)], runOnce=False,
parent="pyArtRigCreatorUi", kws=True, per=False)
self.rigUiInst.scriptJobs.append(self.scriptJob)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def selectMover(self, part, globalMover, offsetMover, geoMover, button):
"""
Select the appropriate joint mover control based on the args passed in. Color the associated button white
to show selection status.
:param part: The name of the joint mover control.
:param globalMover: Boolean of whether or not given control is a global mover.
:param offsetMover: Boolean of whether or not given control is an offset mover.
:param geoMover: Boolean of whether or not given control is a mesh mover.
:param button: The button in the outliner associated with the given mover.
"""
# select mover and color button
name = self.name + part
# get modifiers
toggle = False
mods = cmds.getModifiers()
if (mods & 1) > 0:
toggle = True
if globalMover:
cmds.select(name + "_mover", tgl=toggle)
selected = cmds.ls(sl=True)
if name + "_mover" in selected:
button.setStyleSheet('background-color: rgb(255, 255, 255);')
else:
button.setStyleSheet('background-color: rgb(255, 255, 0);')
if offsetMover:
cmds.select(name + "_mover_offset", tgl=toggle)
selected = cmds.ls(sl=True)
if name + "_mover_offset" in selected:
self.outlinerWidgets[name + "_offsetMoverBtn"].setStyleSheet('background-color: rgb(255, 255, 255);')
else:
self.outlinerWidgets[name + "_offsetMoverBtn"].setStyleSheet('background-color: rgb(100, 220, 255);')
if geoMover:
cmds.select(name + "_mover_geo", tgl=toggle)
selected = cmds.ls(sl=True)
if name + "_mover_geo" in selected:
self.outlinerWidgets[name + "_geoMoverBtn"].setStyleSheet('background-color: rgb(255, 255, 255);')
else:
self.outlinerWidgets[name + "_geoMoverBtn"].setStyleSheet('background-color: rgb(255, 176, 176);')
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def createContextMenu(self, point):
"""
Create the right-click menu for the module.
:param point: Point on monitor to spawn the right-click menu.
Default menu actions created:
* Copy Settings
* Paste Settings
* Reset Settings
* Delete Module
* Create Mirror of this Module
* Mirror Transformations (only if a mirror is linked)
"""
networkNode = self.returnNetworkNode
mirror = cmds.getAttr(networkNode + ".mirrorModule")
# icons
icon_copy = QtGui.QIcon(os.path.join(self.iconsPath, "System/copy.png"))
icon_paste = QtGui.QIcon(os.path.join(self.iconsPath, "System/paste.png"))
icon_reset = QtGui.QIcon(os.path.join(self.iconsPath, "System/reset.png"))
icon_delete = QtGui.QIcon(os.path.join(self.iconsPath, "System/delete.png"))
icon_mirror = QtGui.QIcon(os.path.join(self.iconsPath, "System/mirrorXforms.png"))
icon_createMirror = QtGui.QIcon(os.path.join(self.iconsPath, "System/createMirror.png"))
# create the context menu
if networkNode != "ART_Root_Module":
self.contextMenu = QtWidgets.QMenu()
self.contextMenu.addAction(icon_copy, "Copy Settings", self.copySettings)
self.contextMenu.addAction(icon_paste, "Paste Settings", self.pasteSettings)
self.contextMenu.addAction(icon_reset, "Reset Settings", self.resetSettings)
self.contextMenu.addSeparator()
if mirror != None:
self.contextMenu.addAction(icon_mirror, "Mirror Transformations to " + mirror,
self.mirrorTransformations)
self.contextMenu.addAction(icon_createMirror, "Create Mirror of this Module", self.createMirrorOfModule_UI)
self.contextMenu.addSeparator()
self.contextMenu.addAction(icon_delete, "Delete Module", self.deleteModule)
self.contextMenu.exec_(self.groupBox.mapToGlobal(point))
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def copySettings(self):
"""
Copy the values from the network node of the module and store them in a temp file on disk.
This function is used in the right-click menu of the module on the skeleton settings interface.
Occasionally, it is called outside of the menu. For example, when creating a mirror of the module,
the settings are copied for the source module to then be later pasted on the mirror.
"""
networkNode = self.returnNetworkNode
attrs = cmds.listAttr(networkNode, ud=True, hd=True)
attrData = []
for attr in attrs:
value = cmds.getAttr(networkNode + "." + attr)
attrData.append([attr, value])
# write out attrData to a temp file
tempDir = cmds.internalVar(userTmpDir=True)
clipboardFile = os.path.normcase(os.path.join(tempDir, "ART_clipboard.txt"))
f = open(clipboardFile, 'w')
# dump the data with json
json.dump(attrData, f)
f.close()
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def pasteSettings(self):
"""
Paste the settings from the temp file on disk to the module's network node.
This function is used in the right-click menu of the module on the skeleton settings interface.
Occasionally, it is called outside of the menu. For example, when creating a mirror of the module,
the settings are copied for the source module to then be later pasted on the mirror.
After settings are pasted, applyModuleChanges is called to update the joint mover in the scene with
the latest values. updateSettingsUI is also called to update the outliner.
"""
# it does this 4 times because for some reason it would not grab everything one time through. Investigate
for i in range(4):
tempDir = cmds.internalVar(userTmpDir=True)
clipboardFile = os.path.normcase(os.path.join(tempDir, "ART_clipboard.txt"))
if os.path.exists(clipboardFile):
# load the data
json_file = open(clipboardFile)
data = json.load(json_file)
json_file.close()
# attempt to paste data if module type is the same
networkNode = self.returnNetworkNode
moduleType = cmds.getAttr(networkNode + ".moduleType")
if moduleType == data[0][1]:
for each in data:
attr = each[0]
value = each[1]
try:
attrType = str(cmds.getAttr(networkNode + "." + attr, type=True))
if attrType != "string":
cmds.setAttr(networkNode + "." + attr, lock=False)
cmds.setAttr(networkNode + "." + attr, value, lock=True)
except:
pass
else:
cmds.warning("No data in clipboard")
# relaunch the UI
self.updateSettingsUI()
self.applyModuleChanges(self)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def resetSettings(self):
"""
Reset the settings of the module's network node.
This function is used in the right-click menu of the module on the skeleton settings interface.
Occasionally, it is called outside of the menu.
After settings are reset, applyModuleChanges is called to update the joint mover in the scene with
the latest values. updateSettingsUI is also called to update the outliner.
"""
# it does this 4 times because for some reason it would not grab everything one time through. Investigate
for i in range(4):
networkNode = self.returnNetworkNode
attrs = cmds.listAttr(networkNode, ud=True)
for attr in attrs:
attrType = str(cmds.getAttr(networkNode + "." + attr, type=True))
if attrType == "double":
cmds.setAttr(networkNode + "." + attr, lock=False)
cmds.setAttr(networkNode + "." + attr, 0, lock=True)
if attrType == "bool":
cmds.setAttr(networkNode + "." + attr, lock=False)
cmds.setAttr(networkNode + "." + attr, True, lock=True)
if attrType == "enum":
cmds.setAttr(networkNode + "." + attr, lock=False)
cmds.setAttr(networkNode + "." + attr, 0, lock=True)
# relaunch the UI
self.updateSettingsUI()
self.applyModuleChanges(self)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def resetTransforms(self, translate, rotate, scale, name):
"""
Reset the given attributes of all movers in the module.
:param translate: Boolean of whether or not to reset translation values.
:param rotate: Boolean of whether or not to reset the rotation values.
:param scale: Boolean of whether or not to reset the scale values.
:param name: The module name. (prefix + basename + suffix)
This function is mainly called from ART_ResetModeUI.
"""
cmds.select(name + "_mover_grp", hi=True)
selection = cmds.ls(sl=True)
globalMovers = []
offsetMovers = []
geoMovers = []
for each in selection:
if each.find("_mover") != -1:
if each.partition("_mover")[2] == "":
globalMovers.append(each)
if each.find("_mover_offset") != -1:
if each.partition("_mover_offset")[2] == "":
offsetMovers.append(each)
if each.find("_mover_geo") != -1:
if each.partition("_mover_geo")[2] == "":
geoMovers.append(each)
cmds.select(clear=True)
for moverList in [globalMovers, offsetMovers, geoMovers]:
for each in moverList:
if translate:
for attr in [".tx", ".ty", ".tz"]:
try:
cmds.setAttr(each + attr, 0)
except:
pass
if rotate:
for attr in [".rx", ".ry", ".rz"]:
try:
cmds.setAttr(each + attr, 0)
except:
pass
if scale:
for attr in [".sx", ".sy", ".sz"]:
try:
cmds.setAttr(each + attr, 1)
except:
pass
if cmds.window("ART_ResetXformsModeWin", exists=True):
cmds.deleteUI("ART_ResetXformsModeWin", wnd=True)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def deleteModule(self):
"""
Delete the module and all associated nodes and interfaces.
First, this will delete the joint mover, remove the entry from the outliner and the skeleton settings UI.
Then, it has to deal with any connected modules or mirror modules and resolve any issues there.
"""
# delete the joint mover
movers = self.returnJointMovers
for moverGrp in movers:
for mover in moverGrp:
cmds.lockNode(mover, lock=False)
cmds.delete(self.name + "_mover_grp")
# remove the entry from the outliner
index = self.rigUiInst.treeWidget.indexOfTopLevelItem(self.outlinerWidgets[self.name + "_treeModule"])
self.rigUiInst.treeWidget.takeTopLevelItem(index)
# remove the groupbox
self.groupBox.setParent(None)
# deal with mirror module
networkNode = self.returnNetworkNode
mirrorModule = cmds.getAttr(networkNode + ".mirrorModule")
if mirrorModule != None:
if mirrorModule != "None":
modules = utils.returnRigModules()
for mod in modules:
modName = cmds.getAttr(mod + ".moduleName")
if modName == mirrorModule:
# set the mirrored version
cmds.setAttr(mod + ".mirrorModule", lock=False)
cmds.setAttr(mod + ".mirrorModule", "None", type="string", lock=True)
# get instance of mirror module's class
modType = cmds.getAttr(mod + ".moduleType")
modName = cmds.getAttr(mod + ".moduleName")
module = __import__("RigModules." + modType, {}, {}, [modType])
# get the class name from that module file (returns Modules.ART_Root.ART_Root for example)
moduleClass = getattr(module, module.className)
# find the instance of that module and call on the skeletonSettings_UI function
moduleInst = moduleClass(self.rigUiInst, modName)
# find the current groupBox for this module
for i in range(self.rigUiInst.moduleSettingsLayout.count()):
if type(self.rigUiInst.moduleSettingsLayout.itemAt(i).widget()) == QtWidgets.QGroupBox:
if self.rigUiInst.moduleSettingsLayout.itemAt(i).widget().title() == modName:
self.rigUiInst.moduleSettingsLayout.itemAt(i).widget().setParent(None)
# relaunch the skeleton settings UI with new info
moduleInst.skeletonSettings_UI(modName)
# check for any attached modules
attachedModules = self.checkForDependencies()
elementList = []
if len(attachedModules) > 0:
for each in attachedModules:
elementList.append([each[2], " -> parent changed from: ", each[1], " to: ", "root\n"])
cmds.parent(each[2] + "_mover_grp", "root_mover")
cmds.setAttr(each[0] + ".parentModuleBone", lock=False)
cmds.setAttr(each[0] + ".parentModuleBone", "root", type="string", lock=True)
each[3].currentParent.setText("root")
mover = "root_mover"
# create the connection geo between the two
childMover = utils.findOffsetMoverFromName(each[2])
riggingUtils.createBoneConnection(mover, childMover, each[2])
each[3].applyModuleChanges(each[3])
cmds.select(clear=True)
# remove the network node
cmds.delete(networkNode)
# delete scriptJob
cmds.scriptJob(kill=self.scriptJob, force=True)
self.updateBoneCount()
self.rigUiInst.moduleInstances.remove(self)
# warn user about changes
if len(attachedModules) > 0:
winParent = interfaceUtils.getMainWindow()
win = interfaceUtils.DialogMessage("Attention!",
"The following modules have had their parent changed\
due to the change in this module's structure:",
elementList, 5, winParent)
win.show()
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def checkForDependencies(self):
"""
This method will check modules for any attached modules or children modules.
This method is generally called when deleting a module or when changing a module name
so that any connected modules are updated accordingly.
:return: attached modules
"""
# This method will check our module for any attached modules
modules = self.getAllModules
joints = self.returnCreatedJoints
attachedMods = []
instances = {}
for inst in self.rigUiInst.moduleInstances:
networkNode = inst.returnNetworkNode
instances[networkNode] = inst
for module in modules:
parentJoint = cmds.getAttr(module + ".parentModuleBone")
moduleName = cmds.getAttr(module + ".moduleName")
if parentJoint in joints:
instance = instances.get(module)
attachedMods.append([module, parentJoint, moduleName, instance])
return attachedMods
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def createMirrorOfModule_UI(self):
"""
This method builds the interface for creating a mirror of a module.
.. image:: /images/mirrorModule.png
"""
# copy the settings of the module
self.copySettings()
# get basename and classname
networkNode = self.returnNetworkNode
baseName = cmds.getAttr(networkNode + ".baseName")
className = cmds.getAttr(networkNode + ".moduleType")
# launch a UI to get the name information
self.mirrorWindow = QtWidgets.QMainWindow()
# load stylesheet
styleSheetFile = utils.returnNicePath(self.toolsPath, "Core/Scripts/Interfaces/StyleSheets/mainScheme.qss")
f = open(styleSheetFile, "r")
style = f.read()
f.close()
self.mirrorWindow.setStyleSheet(style)
# size policies
mainSizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
# create the main widget
self.mainWidget = QtWidgets.QWidget()
self.mirrorWindow.setCentralWidget(self.mainWidget)
# set qt object name
self.mirrorWindow.setObjectName("ART_createMirrorModuleUI")
self.mirrorWindow.setWindowTitle("Create Mirror Module")
# create the mainLayout for the rig creator UI
self.mainLayout = QtWidgets.QVBoxLayout(self.mainWidget)
self.mainLayout.setContentsMargins(0, 0, 0, 0)
self.mirrorWindow.resize(300, 150)
self.mirrorWindow.setSizePolicy(mainSizePolicy)
self.mirrorWindow.setMinimumSize(QtCore.QSize(300, 150))
self.mirrorWindow.setMaximumSize(QtCore.QSize(300, 150))
# create the background image
self.frame = QtWidgets.QFrame()
self.mainLayout.addWidget(self.frame)
# create the layout for the widgets
self.widgetLayout = QtWidgets.QVBoxLayout(self.frame)
# create the prefix pair of fields
self.prefixForm = QtWidgets.QFormLayout()
self.widgetLayout.addLayout(self.prefixForm)
self.prefixLabel = QtWidgets.QLabel("Prefix: ")
self.prefixForm.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.prefixLabel)
self.prefix = QtWidgets.QLineEdit()
self.prefixForm.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.prefix)
# hookup signal/slot connection
self.prefix.textChanged.connect(partial(self.updatePreview, baseName))
# create the suffix pair of fields
self.suffixForm = QtWidgets.QFormLayout()
self.widgetLayout.addLayout(self.suffixForm)
self.suffixLabel = QtWidgets.QLabel("Suffix: ")
self.suffixForm.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.suffixLabel)
self.suffix = QtWidgets.QLineEdit()
self.suffixForm.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.suffix)
# hookup signal/slot connection
self.suffix.textChanged.connect(partial(self.updatePreview, baseName))
# spacer
spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.widgetLayout.addItem(spacerItem)
# realtime preview of final module name
self.previewForm = QtWidgets.QFormLayout()
self.widgetLayout.addLayout(self.previewForm)
self.previewLabel = QtWidgets.QLabel("Preview: ")
self.previewName = QtWidgets.QLabel(baseName)
self.previewName.setMinimumSize(QtCore.QSize(200, 20))
self.previewName.setMaximumSize(QtCore.QSize(200, 20))
self.previewName.setAlignment(QtCore.Qt.AlignHCenter)
self.previewForm.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.previewLabel)
self.previewForm.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.previewName)
# set preview font
font = QtGui.QFont()
font.setPointSize(12)
self.previewName.setFont(font)
spacerItem1 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.widgetLayout.addItem(spacerItem1)
# create button
self.createButton = QtWidgets.QPushButton("CREATE")
self.createButton.setObjectName("blueButton")
self.widgetLayout.addWidget(self.createButton)
self.createButton.setMinimumSize(QtCore.QSize(285, 40))
self.createButton.setMaximumSize(QtCore.QSize(285, 40))
self.createButton.setSizePolicy(mainSizePolicy)
font = QtGui.QFont()
font.setPointSize(12)
self.createButton.setFont(font)
# hookup signal/slot on create button
self.createButton.clicked.connect(self.createMirrorModule)
# show the window
self.mirrorWindow.show()
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def updatePreview(self, baseName, *args):
"""
This simple method updates the module preview field(QLineEdit) with the entered prefix and suffix.
:param baseName: base name of the module (example: arm)
"""
prefix = str(self.prefix.text())
suffix = str(self.suffix.text())
string = ""
if len(prefix) > 0:
string += prefix + "_"
string += baseName
if len(suffix) > 0:
string += "_" + suffix
self.previewName.setText(string)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def createMirrorModule(self):
"""
This method creates the mirror of a module and is called from createMirrorOfModule_UI.
To create the mirror of a module, after a few checks are done, a module of the same type is created first.
If that module type has a left/right version of a joint mover file, the opposite version is brought in.
All the normal steps of module creation are then gone through and lastly, mirrorTransformations is called.
"""
userSpecName = str(self.previewName.text())
networkNode = self.returnNetworkNode
parent = cmds.getAttr(networkNode + ".parentModuleBone")
className = cmds.getAttr(networkNode + ".moduleType")
# check to see if a module already has that name
modules = utils.returnRigModules()
mirrorModule = None
moduleName = None
for module in modules:
name = cmds.getAttr(module + ".moduleName")
if name == userSpecName:
cmds.confirmDialog(title="Name Exists",
message="A module with that name already exists. Please enter a unique name \
for the module",
icon="critical")
return
# now check the modules that contain the parent bone
for module in modules:
bones = cmds.getAttr(module + ".Created_Bones")
splitJoints = bones.split("::")
createdJoints = []
# create a list of the created bones
for bone in splitJoints:
if bone != "":
createdJoints.append(bone)
# see if the parent bone is in that list
if parent in createdJoints:
mirrorModule = cmds.getAttr(module + ".mirrorModule")
moduleName = cmds.getAttr(module + ".moduleName")
# if our parent bone's module, has a mirror module, we need to create this new mirror module under that
# parent instead (if parent = l_thigh, mirror parent should be r_thigh)
if mirrorModule is not None:
for module in modules:
modName = cmds.getAttr(module + ".moduleName")
if modName == mirrorModule:
# find the parent's mover (if parent is l_thigh, mover would be l_leg_thigh_mover)
networkNodes = utils.returnRigModules()
mover = utils.findMoverNodeFromJointName(networkNodes, parent, False, True)
# find mirror mover
mirrorMover = mover.replace(moduleName, mirrorModule)
baseName = cmds.getAttr(module + ".baseName")
boneList = cmds.getAttr(module + ".Created_Bones")
# now, we need to find the joint from the mirror mover, and once there is a match, the parent\
# var now becomes that joint
if mirrorMover.find("_mover") != -1:
jointName = mirrorMover.partition("_mover")[0]
if jointName in boneList:
parent = jointName
else:
# if removing _mover didn't yield a matching joint name, take out the baseName from\
# the mover name, and then remove the _mover
jointName = jointName.replace(baseName + "_", "")
if jointName in boneList:
parent = jointName
# arms and leg exception
mirrorSide = None
specialCaseModules = ["ART_Leg_Standard", "ART_Arm_Standard"]
if className in specialCaseModules:
side = cmds.getAttr(networkNode + ".side")
if side == "Left":
mirrorSide = "Right"
if side == "Right":
mirrorSide = "Left"
# create an instance of the module
mod = __import__("RigModules." + className, {}, {}, [className])
# get the class name from that module file (returns Modules.ART_Root.ART_Root for example)
moduleClass = getattr(mod, mod.className)
jmPath = mod.jointMover
# call functions to create network node, skeleton settings UI
moduleInst = moduleClass(self.rigUiInst, userSpecName)
self.rigUiInst.moduleInstances.append(moduleInst)
networkNodeInst = moduleInst.buildNetwork()
# if mirrorSide exists
if mirrorSide is not None:
jmPath = jmPath.partition(".ma")[0] + "_" + mirrorSide + ".ma"
if mirrorSide == "Left":
cmds.setAttr(networkNodeInst + ".side", lock=False)
cmds.setAttr(networkNodeInst + ".side", "Left", type="string", lock=True)
if mirrorSide == "Right":
cmds.setAttr(networkNodeInst + ".side", lock=False)
cmds.setAttr(networkNodeInst + ".side", "Right", type="string", lock=True)
# build the settings UI/joint mover/add to outliner
moduleInst.skeletonSettings_UI(userSpecName)
moduleInst.jointMover_Build(jmPath)
moduleInst.addJointMoverToOutliner()
# update the created joints attribute on the network node with the new names
prefix = str(self.prefix.text())
suffix = str(self.suffix.text())
if len(prefix) > 0:
if prefix.find("_") == -1:
prefix = prefix + "_"
if len(suffix) > 0:
if suffix.find("_") == -1:
suffix = "_" + suffix
createdBones = cmds.getAttr(networkNodeInst + ".Created_Bones")
createdBones = createdBones.split("::")
attrString = ""
for bone in createdBones:
if len(bone) > 1:
attrString += prefix + bone + suffix + "::"
cmds.setAttr(networkNodeInst + ".Created_Bones", lock=False)
cmds.setAttr(networkNodeInst + ".Created_Bones", attrString, type="string", lock=True)
# update the self.currentParent label and the parentModuleBone attr on the network node
moduleInst.currentParent.setText(parent)
cmds.setAttr(networkNodeInst + ".parentModuleBone", lock=False)
cmds.setAttr(networkNodeInst + ".parentModuleBone", parent, type="string", lock=True)
# find the current parent mover and its scale
if parent == "root":
mover = "root_mover"
offsetMover = "root_mover"
else:
# find the parent mover name to parent to
networkNodes = utils.returnRigModules()
mover = utils.findMoverNodeFromJointName(networkNodes, parent, False, True)
offsetMover = utils.findMoverNodeFromJointName(networkNodes, parent)
if mover is not None:
cmds.parentConstraint(mover, userSpecName + "_mover_grp", mo=True)
cmds.scaleConstraint(mover, userSpecName + "_mover_grp")
# create the connection geo between the two
childMover = utils.findOffsetMoverFromName(userSpecName)
riggingUtils.createBoneConnection(offsetMover, childMover, userSpecName)
globalMover = utils.findGlobalMoverFromName(userSpecName)
cmds.select(globalMover)
cmds.setToolTo("moveSuperContext")
utils.fitViewAndShade()
cmds.refresh(force=True)
moduleInst.pasteSettings()
moduleInst.aimMode(True)
# delete UI
cmds.deleteUI("ART_createMirrorModuleUI", wnd=True)
# update the mirrorModule setting
self.mirrorMod.setText(userSpecName)
name = cmds.getAttr(networkNode + ".moduleName")
moduleInst.mirrorMod.setText(name)
cmds.setAttr(networkNode + ".mirrorModule", lock=False)
cmds.setAttr(networkNode + ".mirrorModule", userSpecName, type="string", lock=True)
cmds.setAttr(networkNodeInst + ".mirrorModule", lock=False)
cmds.setAttr(networkNodeInst + ".mirrorModule", name, type="string", lock=True)
# mirror transformations
self.mirrorTransformations()
self.rigUiInst.populateNetworkList()
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def mirrorTransformations_RigPose(self):
"""
This method is used when creating rig poses for modules. If a module has a mirror, this method will mirror the
rig pose transformations to that mirror module.
"""
# reset mirror module's rig pose
mirrorModInst = self.returnMirrorModuleInst
# ensure the mirrorModInst has a UI and is setup for rig pose creation
mirrorModInst.setupForRigPose()
# if not cmds.objExists(mirrorModInst.name + "_rigPose"):
# mirrorModInst.getReferencePose("rigPose")
# call on base mirror transformations method
self.mirrorTransformations()
mirrorModInst.getReferencePose("rigPose")
# update the rig pose of the mirrorModInst
mirrorModInst.updateRigPose(mirrorModInst.overallSlider)
mirrorModInst.cleanUpRigPose()
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def mirrorTransformations(self):
"""
This method mirrors transformations for the module's mirror module.
"""
currentSelection = cmds.ls(sl=True)
# get the mirror module
networkNode = self.returnNetworkNode
mirrorModule = cmds.getAttr(networkNode + ".mirrorModule")
moduleName = cmds.getAttr(networkNode + ".moduleName")
parent = cmds.getAttr(networkNode + ".parentModuleBone")
# get mirror module instance and information
mirrorInst = self.returnMirrorModuleInst
# turn off aim mode
mirrorInst.aimMode_Setup(False)
# turn off coplanar mode IF it exists on the module
try:
state = mirrorInst.coplanarBtn.isChecked()
if state:
mirrorInst.coplanarBtn.setChecked(False)
mirrorInst.coplanarMode()
except:
pass
moverTypes = self.returnJointMovers
for moverType in moverTypes:
for jointMover in moverType:
attrs = cmds.listAttr(jointMover, keyable=True)
for attr in attrs:
value = cmds.getAttr(jointMover + "." + attr)
mirrorMover = jointMover.partition(moduleName)[2]
mirrorMover = mirrorModule + mirrorMover
mirrorAttrs = ["translateX", "translateY", "translateZ"]
if attr in mirrorAttrs:
cmds.setAttr(mirrorMover + "." + attr, value * -1)
else:
cmds.setAttr(mirrorMover + "." + attr, value)
cmds.select(clear=True)
if len(currentSelection) > 0:
cmds.select(currentSelection)
# turn aim mode on
mirrorInst.aimMode_Setup(True)
# extend functionality
self.mirrorTransformations_Custom()
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def rigPose_UI(self, parentWidget):
"""
This method creates the UI widget that gets parented into the publish UI that handles rig pose creation.
A slider gets created for the overall module that goes from current pose to ideal rig pose. Then a slider
gets created for each joint in the module to allow for finer control over the rig pose creation.
:param parentWidget: the widget the rig pose UI (QFrame) will get parented to
"""
# Add a QFrame for the widget
self.rigPoseFrame = QtWidgets.QFrame()
self.rigPoseFrame.setAttribute(QtCore.Qt.WA_DeleteOnClose, True)
self.rigPoseFrame.setMinimumWidth(310)
self.rigPoseFrame.setMaximumWidth(310)
# load stylesheet
styleSheetFile = utils.returnNicePath(self.toolsPath, "Core/Scripts/Interfaces/StyleSheets/mainScheme.qss")
f = open(styleSheetFile, "r")
self.style = f.read()
f.close()
# add the rig pose frame to the stackWidget
parentWidget.addWidget(self.rigPoseFrame)
numWidgetsInStack = parentWidget.count()
parentWidget.setCurrentIndex(numWidgetsInStack - 1)
# frame styling
backgroundImg = utils.returnFriendlyPath(os.path.join(self.iconsPath, "System/field_background.png"))
self.rigPoseFrame.setStyleSheet("background-image: url(" + backgroundImg + ");")
# create an overall layout
self.rigPoseLayout = QtWidgets.QVBoxLayout(self.rigPoseFrame)
label = QtWidgets.QLabel(self.name)
self.rigPoseLayout.addWidget(label)
# create a slider for the overall module rig pose
hboxLayout = QtWidgets.QHBoxLayout()
self.rigPoseLayout.addLayout(hboxLayout)
image1 = QtWidgets.QFrame()
image1.setMinimumSize(30, 30)
image1.setMaximumSize(30, 30)
modelPoseImg = utils.returnFriendlyPath(os.path.join(self.iconsPath, "System/modelPose.png"))
image1.setStyleSheet("background-image: url(" + modelPoseImg + ");")
hboxLayout.addWidget(image1)
image1.setToolTip("Model Pose")
self.overallSlider = QtWidgets.QSlider()
self.overallSlider.setProperty("name", self.name)
hboxLayout.addWidget(self.overallSlider)
self.overallSlider.setOrientation(QtCore.Qt.Horizontal)
self.overallSlider.setRange(0, 100)
self.overallSlider.setSingleStep(1)
self.overallSlider.setTracking(False)
image2 = QtWidgets.QFrame()
image2.setMinimumSize(30, 30)
image2.setMaximumSize(30, 30)
rigPoseImg = utils.returnFriendlyPath(os.path.join(self.iconsPath, "System/rigPose.png"))
image2.setStyleSheet("background-image: url(" + rigPoseImg + ");")
hboxLayout.addWidget(image2)
image2.setToolTip("Rig Pose")
# create hboxlayout for resetAll and update Rig Pose buttons
buttonLayout = QtWidgets.QHBoxLayout()
self.rigPoseLayout.addLayout(buttonLayout)
self.rigPoseResetAllBtn = QtWidgets.QPushButton("Reset Rig Pose")
buttonLayout.addWidget(self.rigPoseResetAllBtn)
self.rigPoseResetAllBtn.clicked.connect(self.resetRigPose)
self.rigPoseResetAllBtn.setToolTip("Reset the module to it's initial ideal rig pose.")
self.rigPoseResetAllBtn.setObjectName("blueButton")
self.rigPoseResetAllBtn.setStyleSheet(self.style)
self.rigPoseUpdateAllBtn = QtWidgets.QPushButton("Update Rig Pose")
self.rigPoseUpdateAllBtn.setStyleSheet(self.style)
buttonLayout.addWidget(self.rigPoseUpdateAllBtn)
self.rigPoseUpdateAllBtn.clicked.connect(partial(self.updateRigPose, self.overallSlider))
self.rigPoseUpdateAllBtn.setToolTip(
"Update the rig pose if you've done any custom manipulations to the controls.")
self.rigPoseUpdateAllBtn.setObjectName("blueButton")
# create a frame for the advanced controls
self.rigPose_advancedGroup = QtWidgets.QGroupBox("Advanced")
self.rigPoseLayout.addWidget(self.rigPose_advancedGroup)
self.rigPose_advancedLayout = QtWidgets.QVBoxLayout(self.rigPose_advancedGroup)
# create a slider for each created joint
joints = self.returnCreatedJoints
networkNode = self.returnNetworkNode
baseName = cmds.getAttr(networkNode + ".baseName")
for joint in joints:
if cmds.objExists(joint):
self.createRigPoseSliderForJoint(joint)
else:
jointBaseName = joint
if self.name != baseName:
nameData = self.name.split(baseName)
if nameData[0] != "":
jointBaseName = jointBaseName.partition(nameData[0])[2]
if nameData[1] != "":
jointBaseName = jointBaseName.partition(nameData[1])[0]
if cmds.objExists(self.name + "_" + jointBaseName + "_mover"):
self.createRigPoseSliderForJoint(joint)
# create mirror button if applicable
if cmds.getAttr(networkNode + ".mirrorModule") != "":
mirrorMod = cmds.getAttr(networkNode + ".mirrorModule")
if mirrorMod != None:
self.rigPoseMirrorBtn = QtWidgets.QPushButton("Mirror to: " + mirrorMod)
self.rigPoseLayout.addWidget(self.rigPoseMirrorBtn)
self.rigPoseMirrorBtn.clicked.connect(self.mirrorTransformations_RigPose)
self.rigPoseMirrorBtn.setObjectName("blueButton")
self.rigPoseMirrorBtn.setStyleSheet(self.style)
self.rigPoseLayout.addSpacerItem(
QtWidgets.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Expanding))
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def buildRig(self, textEdit, uiInst):
"""
This method starts building the rig for a module. It will then call on buildRigCustom, which is implemented
in each derived module class as an override function.
:param textEdit: The text edit in the buildProgressUI that we output information to.
:param uiInst: passed in instance of the buildProgressUI
"""
# get current nodes in scene
currentNodes = cmds.ls("*", long=True)
successfulBuild = True
errorMessage = ""
# run the instance build function
try:
self.buildRigCustom(textEdit, uiInst)
except Exception, e:
successfulBuild = False
errorMessage = str(traceback.format_exc())
# get all nodes in scene and compare to original list
allNodes = cmds.ls("*", long=True)
newNodes = list(set(allNodes).difference(currentNodes))
for node in newNodes:
if not cmds.objExists(node + ".sourceModule"):
cmds.addAttr(node, ln="sourceModule", dt="string")
try:
cmds.setAttr(node + ".sourceModule", self.name, type="string")
except:
print node
if not successfulBuild:
print "Build Rig Failed: " + str(e)
print errorMessage
# self.deleteRig()
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def buildRigCustom(self, textEdit, uiInst):
"""
This method is what truly builds the rig for each module. It is implemented in the derived module class.
:param textEdit: The text edit in the buildProgressUI that we output information to.
:param uiInst: passed in instance of the buildProgressUI
"""
pass
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def deleteRig(self):
"""
This method deletes all rigging for the module.
"""
allNodes = cmds.ls("*")
for node in allNodes:
if cmds.objExists(node + ".sourceModule"):
cmds.lockNode(node, lock=False)
source = cmds.getAttr(node + ".sourceModule")
if source == self.name:
try:
cmds.delete(node)
except:
pass
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def mirrorTransformations_Custom(self):
"""
This method is implemented in the derived module class.
"""
pass
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def updateSettingsUI(self):
"""
This method is implemented in the derived module class.
"""
pass
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def applyModuleChanges(self, moduleInst):
"""
This method is implemented in the derived module class.
"""
pass
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def addJointMoverToOutliner(self):
"""
This method is implemented in the derived module class.
"""
pass
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def updateOutliner(self):
"""
This method is implemented in the derived module class.
"""
pass
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def skinProxyGeo(self):
"""
This method is implemented in the derived module class.
"""
pass
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def aimMode(self, state):
"""
This method toggles the aim mode state if the module can have aim mode.
It then calls on each derived module's aimMode_Setup which defines how to setup aim mode for the module.
"""
networkNode = self.returnNetworkNode
cmds.setAttr(networkNode + ".aimMode", lock=False)
cmds.setAttr(networkNode + ".aimMode", state, lock=True)
self.aimMode_Setup(state)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def aimMode_Setup(self, state):
"""
This method is implemented in the derived module class.
"""
pass
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def setupModelPoseForRig(self):
"""
This method is implemented in the derived module class.
"""
pass
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def matchModelPose(self):
"""
This method is implemented in the derived module class.
"""
pass
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def pinModule(self, state):
"""
This method is implemented in the derived module class.
"""
pass
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def bakeOffsets(self):
"""
This method bakes any transforms on the offset movers up to the global movers, and then zeroes out the offset
movers.
"""
# get movers
jointMovers = self.returnJointMovers
# separate mover lists
globalMovers = jointMovers[0]
offsetMovers = jointMovers[1]
constraints = []
locators = []
# create locators for the offsetMovers, then zero out offset mover
for mover in offsetMovers:
locatorName = mover.partition("_offset")[0] + "_loc"
loc = cmds.spaceLocator(name=locatorName)[0]
# constrain locator
constraint = cmds.parentConstraint(mover, loc)[0]
cmds.delete(constraint)
# parent locator under a copy of the locatorName
parentLoc = cmds.duplicate(loc)[0]
cmds.parent(loc, parentLoc)
locators.append(parentLoc)
for mover in offsetMovers:
for attr in [".tx", ".ty", ".tz", ".rx", ".ry", ".rz"]:
try:
cmds.setAttr(mover + attr, 0)
except:
pass
# snap global movers to locators
for mover in globalMovers:
if cmds.objExists(mover + "_loc"):
constraint = cmds.parentConstraint(mover + "_loc", mover)[0]
constraints.append(constraint)
# remove locs
for const in constraints:
cmds.delete(const)
for loc in locators:
cmds.delete(loc)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def setupForRigPose(self):
"""
This method unhides the movers and constrains the joints to the movers for creating the rig pose.
If the user wants to create a custom rig pose (instead of using the sliders), this method sets the module
up for that functionality.
"""
# unlock joint movers
cmds.select("JointMover", hi=True)
jmNodes = cmds.ls(sl=True)
for node in jmNodes:
cmds.lockNode(node, lock=False)
# find the mover shapes and set their visibility
movers = self.returnJointMovers
globalMovers = movers[0]
shapes = []
for each in movers:
for mover in each:
child = cmds.listRelatives(mover, children=True, shapes=True)
if len(child) > 0:
shapes.append(mover + "|" + child[0])
for shape in shapes:
cmds.setAttr(shape + ".v", lock=False)
cmds.setAttr(shape + ".v", 0, lock=True)
# show global movers
shapes = []
for mover in globalMovers:
child = cmds.listRelatives(mover, children=True, shapes=True)
if len(child) > 0:
shapes.append(mover + "|" + child[0])
for shape in shapes:
cmds.setAttr(shape + ".v", lock=False)
cmds.setAttr(shape + ".v", 1, lock=True)
# unlock mover group for this module and make visible
cmds.lockNode(self.name + "_mover_grp", lock=False)
cmds.setAttr(self.name + "_mover_grp.v", lock=False)
cmds.setAttr(self.name + "_mover_grp.v", 1)
# hide the proxy geo
cmds.select(self.name + "_mover_grp", hi=True)
allNodes = cmds.ls(sl=True)
for node in allNodes:
if node.find("_proxy_geo") != -1:
if cmds.nodeType(node) == "mesh":
parent = cmds.listRelatives(node, parent=True)[0]
cmds.lockNode(parent, lock=False)
cmds.setAttr(parent + ".v", lock=False)
cmds.setAttr(parent + ".v", 0)
cmds.lockNode(parent, lock=True)
# get the joints created by this module
joints = self.returnCreatedJoints
# create mover name
networkNode = self.returnNetworkNode
baseName = cmds.getAttr(networkNode + ".baseName")
for joint in joints:
if cmds.objExists(joint + "_mover_offset"):
cmds.parentConstraint(joint + "_mover_offset", joint)
else:
jointBaseName = joint
if self.name != baseName:
nameData = self.name.split(baseName)
if nameData[0] != "":
jointBaseName = jointBaseName.partition(nameData[0])[2]
if nameData[1] != "":
jointBaseName = jointBaseName.partition(nameData[1])[0]
if cmds.objExists(self.name + "_" + jointBaseName + "_mover_offset"):
cmds.parentConstraint(self.name + "_" + jointBaseName + "_mover_offset", joint)
# lock joint movers
cmds.select("JointMover", hi=True)
jmNodes = cmds.ls(sl=True)
for node in jmNodes:
cmds.lockNode(node, lock=True)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def setSkeletonPose(self, poseType):
"""
This method constrains the joints to the movers and then stores that pose data for those joints.
This could be the model pose or the rig pose.
:param poseType: whether to set the model pose or rig pose for the joints.
"""
# get the joints created by this module
joints = self.returnCreatedJoints
# create mover name
networkNode = self.returnNetworkNode
baseName = cmds.getAttr(networkNode + ".baseName")
for joint in joints:
if cmds.objExists(joint + "_mover_offset"):
cmds.parentConstraint(joint + "_mover_offset", joint)
else:
jointBaseName = joint
if self.name != baseName:
nameData = self.name.split(baseName)
if nameData[0] != "":
jointBaseName = jointBaseName.partition(nameData[0])[2]
if nameData[1] != "":
jointBaseName = jointBaseName.partition(nameData[1])[0]
if cmds.objExists(self.name + "_" + jointBaseName + "_mover_offset"):
cmds.parentConstraint(self.name + "_" + jointBaseName + "_mover_offset", joint)
# set pose
self.setReferencePose(poseType)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def removeSkeletalConstraints(self):
"""
This method removes any constraints on the joints. This tends to get called by removing rigging.
"""
# get the joints created by this module and remove the constraints
joints = self.returnCreatedJoints
# create mover name
networkNode = self.returnNetworkNode
baseName = cmds.getAttr(networkNode + ".baseName")
for joint in joints:
if cmds.objExists(joint + "_mover_offset"):
cmds.select(joint)
cmds.delete(constraints=True)
else:
jointBaseName = joint
if self.name != baseName:
nameData = self.name.split(baseName)
if nameData[0] != "":
jointBaseName = jointBaseName.partition(nameData[0])[2]
if nameData[1] != "":
jointBaseName = jointBaseName.partition(nameData[1])[0]
if cmds.objExists(self.name + "_" + jointBaseName + "_mover_offset"):
cmds.select(joint)
cmds.delete(constraints=True)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def cleanUpRigPose(self):
"""
This method hides the joint movers and unconstrains the joints from the movers after setting a rig pose.
"""
# show the proxy geo
cmds.select(self.name + "_mover_grp", hi=True)
allNodes = cmds.ls(sl=True)
for node in allNodes:
if node.find("_proxy_geo") != -1:
if cmds.nodeType(node) == "mesh":
parent = cmds.listRelatives(node, parent=True)[0]
cmds.lockNode(parent, lock=False)
cmds.setAttr(parent + ".v", lock=False)
cmds.setAttr(parent + ".v", 1)
cmds.lockNode(parent, lock=True)
# unlock mover group for this module and make invisible
cmds.lockNode(self.name + "_mover_grp", lock=False)
cmds.setAttr(self.name + "_mover_grp.v", lock=False)
cmds.setAttr(self.name + "_mover_grp.v", 0)
cmds.setAttr(self.name + "_mover_grp.v", lock=True)
cmds.lockNode(self.name + "_mover_grp", lock=True)
# get the joints created by this module and remove the constraints
joints = self.returnCreatedJoints
# create mover name
networkNode = self.returnNetworkNode
baseName = cmds.getAttr(networkNode + ".baseName")
for joint in joints:
if cmds.objExists(joint + "_mover_offset"):
cmds.select(joint)
cmds.delete(constraints=True)
else:
jointBaseName = joint
if self.name != baseName:
nameData = self.name.split(baseName)
if nameData[0] != "":
jointBaseName = jointBaseName.partition(nameData[0])[2]
if nameData[1] != "":
jointBaseName = jointBaseName.partition(nameData[1])[0]
if cmds.objExists(self.name + "_" + jointBaseName + "_mover_offset"):
cmds.select(joint)
cmds.delete(constraints=True)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def updateRigPose(self, slider):
"""
This method updates what the stored rig pose is for a module. The default rig pose tends to be zeroed out
rotations, but this function can essentially update what the max value on the rig pose slider sets the pose to.
:param slider: The rig pose slider where the min is the current model pose and the max is the rig pose.
"""
# get network node
networkNode = self.returnNetworkNode
# get pose data off networkNode
originalData = json.loads(cmds.getAttr(networkNode + ".rigPose"))
newPose = []
for data in originalData:
moverData = {}
mover = data.get("mover")
moverData["mover"] = mover
if cmds.objExists(mover):
translate = cmds.getAttr(mover + ".translate")[0]
rotate = cmds.getAttr(mover + ".rotate")[0]
moverData["translate"] = translate
moverData["rotate"] = rotate
newPose.append(moverData)
jsonString = json.dumps(newPose)
cmds.setAttr(networkNode + ".rigPose", jsonString, type="string")
slider.setValue(0)
slider.setValue(100)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def resetRigPose(self):
"""
This method resets the module rig pose to be the default (zeroed rotations).
"""
# get the network node
networkNode = self.returnNetworkNode
# remove the rigPose attribute on the networkNode
cmds.deleteAttr(networkNode, at="rigPose")
# recreate rig pose node with defaults
self.getReferencePose("rigPose")
# set slider
self.overallSlider.setValue(0)
self.overallSlider.setValue(100)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def resetRigPose_Part(self, part):
"""
This method resets the given joint (part) rig pose to be zeroed rotations. This is for the part slider on
the rig pose UI in the advanced section.
:param part: The given joint name slider.
"""
# get the networkNode
networkNode = self.returnNetworkNode
# get the poseData
poseData = json.loads(cmds.getAttr(networkNode + ".rigPose"))
# find our part in the pose data
for data in poseData:
mover = data.get("mover")
if mover == part:
rotate = data.get("rotate")
try:
cmds.setAttr(mover + ".rotate", 0, 0, 0, type="double3")
data["rotate"] = (0.0, 0.0, 0.0)
except:
pass
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def getReferencePose(self, poseType, zeroPose=True):
"""
This method gets the model pose or the rig pose (depending on poseType) and stores that data for the movers.
:param poseType: Whether or not to get the model pose or rig pose.
:param zeroPose: Whether or not the default rig pose should be set to zeroed rotations.
"""
# get movers
jointMovers = self.returnJointMovers
# separate mover lists
globalMovers = jointMovers[0]
offsetMovers = jointMovers[1]
# get the network node
networkNode = self.returnNetworkNode
# if rigPose already exists, then do not set values
if poseType == "rigPose":
if cmds.objExists(networkNode + "." + poseType):
return
# create the pose data attr if needed
if not cmds.objExists(networkNode + "." + poseType):
cmds.addAttr(networkNode, sn=poseType, dt="string")
# create reference pose data dict
poseData = []
# loop through each mover, getting the translate and rotate values, creating an attribute on the network node
# to store those values
for moverList in [globalMovers, offsetMovers]:
for mover in moverList:
moverData = {}
moverData["mover"] = mover
for attr in ["translate", "rotate"]:
value = cmds.getAttr(mover + "." + attr)[0]
if zeroPose:
if poseType == "rigPose":
if attr == "rotate":
value = (0.0, 0.0, 0.0)
# add the data to the list
moverData[attr] = value
# add mover data to the pose data list
poseData.append(moverData)
# dump the pose data list onto the poseType attribute
jsonString = json.dumps(poseData)
cmds.setAttr(networkNode + "." + poseType, jsonString, type="string")
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def setReferencePose(self, poseType):
"""
This method gets the data for the given pose type (rig or model) and sets the movers with those values.
:param poseType: Whether to set the model pose or the rig pose on the movers.
"""
# get the network node
networkNode = self.returnNetworkNode
# get the pose data from the attribute
if cmds.objExists(networkNode + "." + poseType):
poseData = json.loads(cmds.getAttr(networkNode + "." + poseType))
for data in poseData:
mover = data.get("mover")
translate = data.get("translate")
rotate = data.get("rotate")
# if the mover exists, set the values
if cmds.objExists(mover):
# set translations
for i in range(len(translate)):
if i == 0:
try:
cmds.setAttr(mover + ".translateX", translate[i])
except:
pass
if i == 1:
try:
cmds.setAttr(mover + ".translateY", translate[i])
except:
pass
if i == 2:
try:
cmds.setAttr(mover + ".translateZ", translate[i])
except:
pass
# set rotations
for i in range(len(rotate)):
if i == 0:
try:
cmds.setAttr(mover + ".rotateX", rotate[i])
except:
pass
if i == 1:
try:
cmds.setAttr(mover + ".rotateY", rotate[i])
except:
pass
if i == 2:
try:
cmds.setAttr(mover + ".rotateZ", rotate[i])
except:
pass
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def setReferencePoseSlider(self, part, *args):
"""
This method takes the slider value of a given part and then calls on setPosePercentage, which will then find
the values of the model pose and the rig pose and figure out based on the slider percentage what values to
set on the mover.
:param part: the joint mover which the slider is controlling.
:param args: the values from the slider
"""
percent = float(args[0]) * .01
self.setPosePercentage(percent, part)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def setPosePercentage(self, percent, part):
"""
This method takes the percent from setReferencePoseSlider, gets the values of the model pose and rig pose
for the given part, then calls on setPosePercentage_Part to find and set the values on the mover that is
the percentage between model and rig pose.
Example: If the model pose is a value of 10 and the rig pose is a value of 0, and the slider is at .5, then
the value to set is 5. (But this is done and found per attribute)
:param percent: What percent of model and rig pose to set.
:param part: What joint mover to set the values on.
"""
# get network node
networkNode = self.returnNetworkNode
# get reference pose attributes
modelPoseData = json.loads(cmds.getAttr(networkNode + ".modelPose"))
rigPoseData = json.loads(cmds.getAttr(networkNode + ".rigPose"))
# get the data for each mover
for poseData in modelPoseData:
mover = poseData.get("mover")
translate = poseData.get("translate")
rotate = poseData.get("rotate")
if part != None:
if part == mover:
self.setPosePercentage_Part(percent, mover, modelPoseData, rigPoseData, poseData, translate, rotate)
else:
self.setPosePercentage_Part(percent, mover, modelPoseData, rigPoseData, poseData, translate, rotate)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def setPosePercentage_Part(self, percent, mover, modelPoseData, rigPoseData, poseData, translate, rotate):
"""
This method takes the data from setPosePercentage and figures out what values to set on the given part (mover).
Example: If the model pose is a value of 10 and the rig pose is a value of 0, and the slider is at .5, then
the value to set is 5. (But this is done and found per attribute)
:param percent: the percent value of the slider. What percentage of the model and rig pose to use.
:param mover: the mover to set the values on.
:param modelPoseData: all of the data for the model pose for this mover.
:param rigPoseData: all of the data for the rig pose for this mover.
:param poseData: a list which includes the mover and its translate and rotate values.
:param translate: the translate values for the model pose
:param rotate: the rotate values for the model pose
"""
# get the index of this entry in the rigPoseData list
index = modelPoseData.index(poseData)
# get the corresponding rig pose data
rigData = rigPoseData[index]
rigTranslate = rigData.get("translate")
rigRotate = rigData.get("rotate")
# find percentile between model and rig pose to set on each attribute
for i in range(len(translate)):
valueToSet = mathUtils.returnPercentile([translate[i], rigTranslate[i]], percent)
if i == 0:
cmds.setAttr(mover + ".translateX", valueToSet)
if i == 1:
cmds.setAttr(mover + ".translateY", valueToSet)
if i == 2:
cmds.setAttr(mover + ".translateZ", valueToSet)
for i in range(len(rotate)):
valueToSet = mathUtils.returnPercentile([rotate[i], rigRotate[i]], percent)
if i == 0:
cmds.setAttr(mover + ".rotateX", valueToSet)
if i == 1:
cmds.setAttr(mover + ".rotateY", valueToSet)
if i == 2:
cmds.setAttr(mover + ".rotateZ", valueToSet)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def createRigPoseSliderForJoint(self, joint):
"""
This method creates the rig pose slider widget for the given joint. (This shows up in the advanced section of
the rig pose UI)
:param joint: The joint that the slider will control.
"""
# load stylesheet
styleSheetFile = utils.returnNicePath(self.toolsPath, "Core/Scripts/Interfaces/StyleSheets/mainScheme.qss")
f = open(styleSheetFile, "r")
self.style = f.read()
f.close()
# create mover name
networkNode = self.returnNetworkNode
baseName = cmds.getAttr(networkNode + ".baseName")
jointName = joint
if cmds.objExists(joint + "_mover"):
jointName = joint
else:
jointBaseName = joint
if self.name != baseName:
nameData = self.name.split(baseName)
if nameData[0] != "":
jointName = jointBaseName.partition(nameData[0])[2]
if nameData[1] != "":
jointName = jointName.partition(nameData[1])[0]
jointName = self.name + "_" + jointName
else:
jointName = self.name + "_" + jointName
# create a master vertical layout
mainLayout = QtWidgets.QVBoxLayout()
self.rigPose_advancedLayout.addLayout(mainLayout)
# create a label for the joint
font = QtGui.QFont()
font.setPointSize(10)
font.setBold(True)
jointLabel = QtWidgets.QLabel(joint + ":")
jointLabel.setFont(font)
mainLayout.addWidget(jointLabel)
# create layout for slider/button
layout = QtWidgets.QHBoxLayout()
mainLayout.addLayout(layout)
# create slider for joint
slider = QtWidgets.QSlider()
layout.addWidget(slider)
slider.setProperty("name", joint)
slider.setOrientation(QtCore.Qt.Horizontal)
slider.setRange(0, 100)
slider.setSingleStep(1)
slider.valueChanged.connect(partial(self.setReferencePoseSlider, jointName + "_mover"))
slider.setTracking(False)
self.overallSlider.valueChanged.connect(slider.setValue)
# create reset button
button = QtWidgets.QPushButton("Reset")
button.setMinimumWidth(70)
button.setMaximumWidth(70)
layout.addWidget(button)
button.setObjectName("blueButton")
button.setStyleSheet(self.style)
button.clicked.connect(partial(self.resetRigPose_Part, jointName + "_mover"))
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def updateBoneCount(self):
"""
This method looks at the create bones attribute of the module and gets the number of bones in that list
and appends it onto the total bone count for the bone counter interface.
"""
if cmds.window("ART_BoneCounterWin", exists=True):
if self.rigUiInst.boneCounterInst is not None:
self.rigUiInst.boneCounterInst.updateBoneCount()
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def toggleShapeVis(self, transform, value):
"""
This method finds the shapes for the passed in transform and toggles the visibility based on the value.
:param transform: the transform to get the shape nodes from.
:param value: whether to show or hide the shape nodes.
"""
if cmds.objExists(transform):
shape = cmds.listRelatives(transform, shapes=True)
if shape is not None:
cmds.setAttr(shape[0] + ".v", lock=False)
cmds.setAttr(shape[0] + ".v", value)
cmds.setAttr(shape[0] + ".v", lock=True)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def selectionScriptJob_animUI(self, buttonData):
"""
This method is called from a scriptjob anytime a selection is changed. It's sole purpose it to update the button
color on the anim picker to show if a control is selected or not.
:param buttonData: pairings of button/control/brush. brush is the original color of the button.
"""
selection = mel.eval("ls -sl;")
if selection is None:
selection = []
for data in buttonData:
control = data[1]
button = data[0]
brushColor = data[2]
if control in selection:
button.brush.setColor(QtCore.Qt.white)
button.update()
else:
button.brush.setColor(brushColor)
button.update()
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def importFBX_pre(self, importMethod, character):
"""
This method runs before an fbx is imported onto the control rig. It cuts any keys on the controls and zeroes
the controls out before importing the fbx (which is called in the derived module class)
:param importMethod: Whether or not the FBX is getting imported as FK, IK, Both, or None
:param character: The namespace of the rig.
"""
if importMethod != "None":
controls = self.getControls()
for control in controls:
cmds.cutKey(character + ":" + control)
self.resetRigControls(True)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def importFBX(self, importMethod, character):
"""
This method is implemented in the derived module class and defines how mocap is imported onto the rig controls.
:param importMethod: Whether or not the FBX is getting imported as FK, IK, Both, or None
:param character: The namespace of the rig.
"""
pass
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def resetRigControls(self, resetAll):
"""
This method zeroes out control attributes. If resetAll is true, then it will zero out all rig controls for
the module. Otherwise, it will only zero out the selected controls of the module.
:param resetAll: Whether or not to reset only the selected controls or all controls of the module.
"""
# get namespace
networkNode = self.returnRigNetworkNode
characterNode = cmds.listConnections(networkNode + ".parent")[0]
namespace = cmds.getAttr(characterNode + ".namespace")
if resetAll:
# list any attributes on the network node that contain "controls"
controls = cmds.listAttr(networkNode, st="*Controls")
# get that data on that attr
for control in controls:
data = json.loads(cmds.getAttr(networkNode + "." + control))
# reset the attr on each control
nonZeroAttrs = ["scale", "globalScale", "scaleX", "scaleY", "scaleZ"]
try:
for each in data:
attrs = cmds.listAttr(namespace + ":" + each, keyable=True)
for attr in attrs:
if attr not in nonZeroAttrs:
cmds.setAttr(namespace + ":" + each + "." + attr, 0)
else:
cmds.setAttr(namespace + ":" + each + "." + attr, 1)
except:
cmds.warning("skipped " + str(control) + ". No valid controls found to reset.")
if not resetAll:
nonZeroAttrs = ["scale", "globalScale", "scaleX", "scaleY", "scaleZ"]
selection = cmds.ls(sl=True)
for each in selection:
attrs = cmds.listAttr(each, keyable=True)
for attr in attrs:
if attr not in nonZeroAttrs:
cmds.setAttr(each + "." + attr, 0)
else:
cmds.setAttr(each + "." + attr, 1)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def getControls(self):
"""
This method returns a list of all the rig controls of the module.
:return: List of all rig controls in the module.
"""
# get namespace
networkNode = self.returnRigNetworkNode
if networkNode is None:
winParent = interfaceUtils.getMainWindow()
win = interfaceUtils.DialogMessage("Error", "This function does not work without a namespace.", [], 0,
winParent)
win.show()
return None
# list any attributes on the network node that contain "controls"
controls = cmds.listAttr(networkNode, st="*Controls")
returnControls = []
# get that data on that attr
for control in controls:
data = json.loads(cmds.getAttr(networkNode + "." + control))
# reset the attr on each control
if data is not None:
for each in data:
returnControls.append(each)
return returnControls
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def selectRigControls(self):
"""
This method calls on getControls to return a list of the controls and the selects them.
"""
controls = self.getControls()
# get namespace
networkNode = self.returnRigNetworkNode
characterNode = cmds.listConnections(networkNode + ".parent")[0]
namespace = cmds.getAttr(characterNode + ".namespace")
for control in controls:
cmds.select(namespace + ":" + control, add=True)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# PROPERTIES
@property
def getModules(self):
"""
This method finds the main "character" module that has connections to all of the rig modules
:return: returns the character node.
"""
modules = cmds.ls(type="network")
for module in modules:
attrs = cmds.listAttr(module)
if "rigModules" in attrs:
return module
@property
def getAllModules(self):
"""
This method finds all connected rig modules to the main character network node.
:return: returns a list of the rig modules
"""
modules = cmds.ls(type="network")
returnMods = []
for module in modules:
attrs = cmds.listAttr(module)
if "parent" in attrs:
returnMods.append(module)
return returnMods
@property
def returnNetworkNode(self):
"""
This method returns the module's own network node.
:return: the modules network node
"""
networkNodes = cmds.ls(type="network")
for node in networkNodes:
attrs = cmds.listAttr(node)
if "moduleName" in attrs:
if cmds.getAttr(node + ".moduleName") == self.name:
networkNode = node
return networkNode
@property
def returnRigNetworkNode(self):
"""
This method returns the module's own network node using the namespace on the main character
network node. This is so that if there are multiple characters in a scene, we know which
network node for which character we are trying to return.
:return: returns this module's network node in a scene with references.
"""
modules = []
networkNodes = cmds.ls(type="network")
for node in networkNodes:
attrs = cmds.listAttr(node)
if "moduleName" in attrs:
if cmds.getAttr(node + ".moduleName") == self.name:
characterNode = cmds.listConnections(node + ".parent")[0]
if cmds.objExists(characterNode + ".namespace"):
if cmds.getAttr(characterNode + ".namespace") == self.namespace.partition(":")[0]:
networkNode = node
return networkNode
else:
return None
@property
def returnClassObject(self):
return self
@property
def returnCreatedJoints(self):
"""
This method loops through the Created Bones attribute on its network node and returns a list of the
joints it will create given the current module settings.
:return: A list of the created bones of the module.
"""
networkNode = self.returnNetworkNode
joints = cmds.getAttr(networkNode + ".Created_Bones")
splitJoints = joints.split("::")
createdJoints = []
for bone in splitJoints:
if bone != "":
createdJoints.append(bone)
return createdJoints
@property
def returnJointMovers(self):
"""
This method finds and returns all joint movers for the module.
:return: a list of all global movers, offset movers, and geo movers for the module.
"""
name = self.groupBox.title()
# select global movers
cmds.select(name + "*_mover")
globalMovers = cmds.ls(sl=True)
# select offset movers
cmds.select(name + "*_mover_offset")
offsetMovers = cmds.ls(sl=True)
# mesh movers
cmds.select(name + "*_mover_geo")
geoMovers = cmds.ls(sl=True)
return [globalMovers, offsetMovers, geoMovers]
@property
def returnMirrorModuleInst(self):
"""
This method finds and returns the instance of a module's mirror module.
:return: a pointer in memory to the instance of the mirror module.
"""
# get network node
networkNode = self.returnNetworkNode
mirrorModule = cmds.getAttr(networkNode + ".mirrorModule")
# find instance through rig UI inst
for inst in self.rigUiInst.moduleInstances:
networkNode = inst.returnNetworkNode
moduleName = cmds.getAttr(networkNode + ".moduleName")
if moduleName == mirrorModule:
return inst
@property
def returnPrefixSuffix(self):
"""
This method splits our module name by the base name and returns the prefix and suffix.
:return: the user-defined prefix and suffix found by splitting the module name by the base name.
"""
prefix = None
suffix = None
networkNode = self.returnNetworkNode
baseName = cmds.getAttr(networkNode + ".baseName")
splitName = self.name.split(baseName)
if splitName[0] != '':
prefix = splitName[0]
if splitName[1] != '':
suffix = splitName[1]
return [prefix, suffix]
|