@@ -27,52 +27,51 @@ def abspath(path):
27
27
'generatePiston' : abspath ('icons/generatePiston.png' ),
28
28
'deleteNodes' : abspath ('icons/deleteNodes.png' ),
29
29
'pistonSolverNode' : abspath ('icons/pistonSolverNode.png' ),
30
- 'pistonVectorLength' : abspath ('icons/pistonVectorLengthNode.png' )
30
+ 'pistonVectorLength' : abspath ('icons/pistonVectorLengthNode.png' ),
31
+ 'flushUndo' :abspath ('icons/flushUndo.png' )
31
32
}
32
33
33
34
# Buttons commands for the shelf
34
35
35
- def generateCommand ():
36
- cmds .generatePiston ()
36
+ def generateCommand () :
37
+ pm .generatePiston ()
37
38
38
39
39
40
def deletePluginNodes ():
40
- """
41
- Delete all the custom nodetypes created by the plugin
42
- :return:
43
- """
44
41
plugin_nodetypes = [
45
42
'pistonVectorLength' ,
46
43
'pistonNode'
47
44
]
48
-
49
45
for type in plugin_nodetypes :
50
46
nodes = pm .ls (type = type )
51
47
if nodes :
52
48
for i in range (len (nodes ) - 1 , - 1 , - 1 ):
53
49
if pm .objExists (nodes [i ]):
54
50
pm .delete (nodes [i ])
55
51
print (type , ' : {} nodes deleted' .format (len (nodes )))
52
+ pm .flushUndo ()
53
+
56
54
55
+ def createSolver ():
56
+ pm .createNode ('pistonNode' )
57
57
58
- def createSolver () :
59
- cmds . createNode ( 'pistonNode' )
58
+ def flushUndo () :
59
+ pm . flushUndo ( )
60
60
61
61
def createVectorLength ():
62
- cmds .createNode ('pistonVectorLength' )
62
+ pm .createNode ('pistonVectorLength' )
63
63
64
64
# Generate the plugin Shelf
65
65
66
66
def generate_shelf ():
67
-
68
67
# If the shelf exists delete it
69
68
if pm .shelfLayout ('Piston plugin' , exists = True ):
70
69
print ('Refreshing old shelf' )
71
70
if pm .shelfLayout ('Piston plugin' , query = True , ca = True ):
72
71
for each in pm .shelfLayout ('Piston plugin' , query = True , ca = True ):
73
72
print (each )
74
73
pm .deleteUI (each )
75
- pm .deleteUI ('Piston plugin ' )
74
+ pm .deleteUI ('Piston_plugin ' )
76
75
77
76
# Create the shelf
78
77
plugin_shelf = pm .shelfLayout ('Piston plugin' , parent = 'ShelfLayout' )
@@ -93,6 +92,13 @@ def generate_shelf():
93
92
iol = 'CLEAN' ,
94
93
parent = plugin_shelf )
95
94
95
+ pm .shelfButton (annotation = 'flushUndo() command shortcut,\n '
96
+ 'in order to avoid crash when reloading plugin' ,
97
+ command = flushUndo ,
98
+ image = icons ['flushUndo' ],
99
+ iol = 'FLUSH' ,
100
+ parent = plugin_shelf )
101
+
96
102
pm .shelfButton (annotation = 'Create pistonSolver in node editor' ,
97
103
command = createSolver ,
98
104
image = icons ['pistonSolverNode' ],
@@ -106,5 +112,3 @@ def generate_shelf():
106
112
# button that create the rig
107
113
108
114
# button that delete all plugin-type nodes
109
- generate_shelf ()
110
-
0 commit comments