forked from pitiwazou/Scripts-Blender
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWazou_RMB_Pie_Menu
1458 lines (1213 loc) · 61.9 KB
/
Wazou_RMB_Pie_Menu
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
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
bl_info = {
"name": "Wazou Right clic Pie Menu",
"author": "Cédric Lepiller",
"version": (0, 2, 0),
"blender": (2, 75, 0),
"location": "View3D > RMB",
"description": "Right Click Pie Menu",
"category": "3D View"}
"""
Right Click Pie Menu
This adds a the Right Click Pie Menu in the View3D.
Left mouse is SELECTION.
Left Alt + Double click sets the 3D cursor.
"""
import bpy
import bmesh
from bpy.types import Menu
from bpy.props import IntProperty, FloatProperty, BoolProperty
from bl_ui.properties_paint_common import (
UnifiedPaintPanel,
brush_texture_settings,
brush_texpaint_common,
brush_mask_texture_settings,
)
########################
# Properties #
########################
class WazouRightMenuPiePrefs(bpy.types.AddonPreferences):
"""Creates the tools in a Panel, in the scene context of the properties editor"""
bl_idname = __name__
bpy.types.Scene.Enable_Tab_RMB_01 = bpy.props.BoolProperty(default=False)
bpy.types.Scene.Enable_Tab_RMB_02 = bpy.props.BoolProperty(default=False)
def draw(self, context):
layout = self.layout
layout.prop(context.scene, "Enable_Tab_RMB_01", text="Shortcuts", icon="QUESTION")
if context.scene.Enable_Tab_RMB_01:
row = layout.row()
layout.label(text="– Object/Edit mode > RMB")
layout.label(text="– Cusor > Alt + double clic")
layout.prop(context.scene, "Enable_Tab_RMB_02", text="URL's", icon="URL")
if context.scene.Enable_Tab_RMB_02:
row = layout.row()
row.operator("wm.url_open", text="Pitiwazou.com").url = "http://www.pitiwazou.com/"
row.operator("wm.url_open", text="Wazou's Ghitub").url = "https://github.com/pitiwazou/Scripts-Blender"
row.operator("wm.url_open", text="BlenderLounge Forum ").url = "http://blenderlounge.fr/forum/"
#######################
# Classes #
#######################
# Add Mesh #
class AddMenu(bpy.types.Menu):
bl_label = "Add Mesh"
def draw(self, context):
layout = self.layout
layout.operator("mesh.primitive_cube_add", text="Cube", icon='MESH_CUBE')
layout.operator("mesh.primitive_plane_add", text="Plane", icon='MESH_PLANE')
layout.operator("mesh.primitive_uv_sphere_add", text="UV Sphere", icon='MESH_UVSPHERE')
layout.operator("mesh.primitive_cylinder_add", text="Cylinder", icon='MESH_CYLINDER')
layout.operator("mesh.primitive_grid_add", text="Grid", icon='MESH_GRID')
layout.operator("mesh.primitive_ico_sphere_add", text="Ico Sphere", icon='MESH_ICOSPHERE')
layout.operator("mesh.primitive_circle_add", text="Circle", icon='MESH_CIRCLE')
layout.operator("mesh.primitive_cone_add", text="Cone", icon='MESH_CONE')
layout.operator("mesh.primitive_torus_add", text="Torus", icon='MESH_TORUS')
layout.operator("mesh.primitive_monkey_add", text="Monkey", icon='MESH_MONKEY')
layout.separator()
layout.operator("object.camera_add", icon='OUTLINER_OB_CAMERA')
layout.separator()
layout.operator("object.lamp_add", text="Area", icon='LAMP_AREA').type = 'AREA'
layout.operator("object.lamp_add", text="Sun", icon='LAMP_SUN').type = 'SUN'
layout.operator("object.lamp_add", text="Hemi", icon='LAMP_HEMI').type = 'HEMI'
layout.operator("object.lamp_add", text="Point", icon='LAMP_POINT').type = 'POINT'
layout.operator("object.lamp_add", text="Spot", icon='LAMP_SPOT').type = 'SPOT'
layout.separator()
layout.operator("curve.primitive_bezier_circle_add", icon='CURVE_BEZCIRCLE')
layout.operator("curve.primitive_bezier_curve_add", icon='CURVE_BEZCURVE')
layout.operator("curve.primitive_nurbs_path_add", icon='CURVE_PATH')
layout.separator()
layout.operator("object.empty_add", text="Empty AXE", icon='OUTLINER_OB_EMPTY').type = 'PLAIN_AXES'
layout.operator("object.empty_add", text="Empty CUBE", icon='OUTLINER_OB_EMPTY').type = 'CUBE'
layout.operator("object.add", text="Lattice", icon='OUTLINER_OB_LATTICE').type = 'LATTICE'
layout.operator("object.text_add", text="Text", icon='OUTLINER_OB_FONT')
layout.operator("object.armature_add", text="Armature", icon='OUTLINER_OB_ARMATURE')
#Subsurf 2
class SubSurf2(bpy.types.Operator):
bl_idname = "object.subsurf2"
bl_label = "SubSurf 2"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
bpy.ops.object.subdivision_set(level=2)
bpy.context.object.modifiers["Subsurf"].show_only_control_edges = True
if bpy.context.object.mode == "EDIT":
bpy.ops.object.subdivision_set(level=2)
bpy.context.object.modifiers["Subsurf"].show_on_cage = True
bpy.ops.object.mode_set(mode = 'EDIT')
return {'FINISHED'}
#Remove Subsurf
class RemoveSubsurf(bpy.types.Operator):
bl_idname = "remove.subsurf"
bl_label = "Remove Subsurf"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
bpy.ops.object.modifier_remove(modifier="Subsurf")
return {'FINISHED'}
#Add Mirror Object
class AddMirrorObject(bpy.types.Operator):
bl_idname = "add.mirrorobject"
bl_label = "Add Mirror Object"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
bpy.ops.object.modifier_add(type='MIRROR')
bpy.context.object.modifiers["Mirror"].use_clip = True
return {'FINISHED'}
#Add Mirror Edit
class AddMirrorEdit(bpy.types.Operator):
bl_idname = "add.mirroredit"
bl_label = "Add Mirror Edit"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
bpy.ops.object.modifier_add(type='MIRROR')
bpy.context.object.modifiers["Mirror"].use_clip = True
bpy.context.object.modifiers["Mirror"].show_on_cage = True
return {'FINISHED'}
#Apply Mirror Edit
class ApplyMirrorEdit(bpy.types.Operator):
bl_idname = "apply.mirroredit"
bl_label = "Apply Mirror Edit"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
bpy.ops.object.mode_set(mode = 'OBJECT')
bpy.ops.object.modifier_apply(modifier="Mirror")
bpy.ops.object.mode_set(mode = 'EDIT')
return {'FINISHED'}
#Apply Subsurf Edit
class ApplySubsurfEdit(bpy.types.Operator):
bl_idname = "apply.subsurfedit"
bl_label = "Apply Subsurf Edit"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
bpy.ops.object.mode_set(mode = 'OBJECT')
bpy.ops.object.modifier_apply(modifier="Subsurf")
bpy.ops.object.mode_set(mode = 'EDIT')
return {'FINISHED'}
#wazou Symetrize
class WazouSymetrize(bpy.types.Operator):
bl_idname = "wazou.symetrize"
bl_label = "Wazou Symetrize"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
bpy.ops.mesh.select_all(action='TOGGLE')
bpy.ops.mesh.select_all(action='TOGGLE')
bpy.ops.mesh.symmetrize(direction='POSITIVE_X')
bpy.ops.mesh.select_all(action='TOGGLE')
return {'FINISHED'}
#Looptools
class VIEW3D_MT_edit_mesh_looptools(bpy.types.Menu):
bl_idname = "loop.tools"
bl_label = "LoopTools"
def draw(self, context):
layout = self.layout
layout.operator("mesh.looptools_bridge", text="Bridge").loft = False
layout.operator("mesh.looptools_circle")
layout.operator("mesh.looptools_curve")
layout.operator("mesh.looptools_flatten")
layout.operator("mesh.looptools_gstretch")
layout.operator("mesh.looptools_bridge", text="Loft").loft = True
layout.operator("mesh.looptools_relax")
layout.operator("mesh.looptools_space")
#Apply Transforms
class ApplyTransformAll(bpy.types.Operator):
bl_idname = "apply.transformall"
bl_label = "Apply Transform All"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
bpy.ops.object.transform_apply(location=True, rotation=True, scale=True)
return {'FINISHED'}
#Delete modifiers
class DeleteModifiers(bpy.types.Operator):
bl_idname = "delete.modifiers"
bl_label = "Delete modifiers"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
selection = bpy.context.selected_objects
if not(selection):
for obj in bpy.data.objects:
for mod in obj.modifiers:
bpy.context.scene.objects.active = obj
bpy.ops.object.modifier_remove(modifier = mod.name)
else:
for obj in selection:
for mod in obj.modifiers:
bpy.context.scene.objects.active = obj
bpy.ops.object.modifier_remove(modifier = mod.name)
return {'FINISHED'}
#Clear All
class ClearAll(bpy.types.Operator):
bl_idname = "clear.all"
bl_label = "Clear All"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
selection = bpy.context.selected_objects
bpy.ops.object.location_clear()
bpy.ops.object.rotation_clear()
bpy.ops.object.scale_clear()
return {'FINISHED'}
#Separate Loose Parts
class SeparateLooseParts(bpy.types.Operator):
bl_idname = "separate.looseparts"
bl_label = "Separate Loose Parts"
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
return context.active_object is not None
def execute(self, context):
bpy.ops.object.mode_set(mode = 'EDIT')
bpy.ops.mesh.separate(type='LOOSE')
bpy.ops.object.mode_set(mode = 'OBJECT')
bpy.ops.object.select_all(action='TOGGLE')
return {'FINISHED'}
#Create Hole
class CreateHole(bpy.types.Operator):
"""This Operator create a hole on a selection"""
bl_idname = "object.createhole"
bl_label = "Create Hole on a Selection"
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
return context.active_object is not None
def execute(self, context):
bpy.ops.mesh.extrude_region_move()
bpy.ops.transform.resize(value=(0.6, 0.6, 0.6))
bpy.ops.mesh.looptools_circle()
bpy.ops.mesh.extrude_region_move()
bpy.ops.transform.resize(value=(0.8, 0.8, 0.8))
bpy.ops.mesh.delete(type='FACE')
return {'FINISHED'}
#Symetry Lock X
class SymetryLockX(bpy.types.Operator):
bl_idname = "object.symetrylockx"
bl_label = "Symetry Lock X"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
if bpy.context.scene.tool_settings.sculpt.use_symmetry_x == True:
bpy.context.scene.tool_settings.sculpt.use_symmetry_x = False
elif bpy.context.scene.tool_settings.sculpt.use_symmetry_x == False:
bpy.context.scene.tool_settings.sculpt.use_symmetry_x = True
return {'FINISHED'}
#Symetry Lock Y
class SymetryLockY(bpy.types.Operator):
bl_idname = "object.symetrylocky"
bl_label = "Symetry Lock Y"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
if bpy.context.scene.tool_settings.sculpt.use_symmetry_y == True:
bpy.context.scene.tool_settings.sculpt.use_symmetry_y = False
elif bpy.context.scene.tool_settings.sculpt.use_symmetry_y == False:
bpy.context.scene.tool_settings.sculpt.use_symmetry_y = True
return {'FINISHED'}
#Symetry Lock Z
class SymetryLockZ(bpy.types.Operator):
bl_idname = "object.symetrylockz"
bl_label = "Symetry Lock Z"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
if bpy.context.scene.tool_settings.sculpt.use_symmetry_z == True:
bpy.context.scene.tool_settings.sculpt.use_symmetry_z = False
elif bpy.context.scene.tool_settings.sculpt.use_symmetry_z == False:
bpy.context.scene.tool_settings.sculpt.use_symmetry_z = True
return {'FINISHED'}
#Dyntopo Shading
class DyntopoSmoothShading(bpy.types.Operator):
bl_idname = "object.dtpsmoothshading"
bl_label = "Dyntopo Smooth Shading"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
if bpy.context.scene.tool_settings.sculpt.use_smooth_shading == True:
bpy.context.scene.tool_settings.sculpt.use_smooth_shading = False
elif bpy.context.scene.tool_settings.sculpt.use_smooth_shading == False:
bpy.context.scene.tool_settings.sculpt.use_smooth_shading = True
return {'FINISHED'}
#detail Variable Constant
class DetailSizevariable(bpy.types.Operator):
bl_idname = "object.detailsizevariable"
bl_label = "Detail Size Variable"
bl_options = {'REGISTER', 'UNDO'}
variable = bpy.props.FloatProperty()
def execute(self, context):
bpy.context.scene.tool_settings.sculpt.constant_detail = self.variable
return {'FINISHED'}
#Detail Variable Relative
class DetailSizevariableRelative(bpy.types.Operator):
bl_idname = "object.detailsizevariablerelative"
bl_label = "Detail Size Variable Relative"
bl_options = {'REGISTER', 'UNDO'}
variable = bpy.props.FloatProperty()
def execute(self, context):
bpy.context.scene.tool_settings.sculpt.detail_size = self.variable
return {'FINISHED'}
#Detail Type
class DTPDetailType(bpy.types.Operator):
bl_idname = "object.detailtype"
bl_label = "Detail Type"
bl_options = {'REGISTER', 'UNDO'}
variable = bpy.props.StringProperty()
def execute(self, context):
bpy.context.scene.tool_settings.sculpt.detail_type_method = self.variable
return {'FINISHED'}
#Detail Refine
class DTPDetailRefine(bpy.types.Operator):
bl_idname = "object.detailrefine"
bl_label = "Detail Refine"
bl_options = {'REGISTER', 'UNDO'}
variable = bpy.props.StringProperty()
def execute(self, context):
bpy.context.scene.tool_settings.sculpt.detail_refine_method = self.variable
return {'FINISHED'}
#Enable Dyntopo
class EnableDyntopo(bpy.types.Operator):
bl_idname = "enable.dyntopo"
bl_label = "Enable Dyntopo"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
bpy.ops.sculpt.dynamic_topology_toggle()
bpy.context.scene.tool_settings.sculpt.detail_refine_method = 'SUBDIVIDE_COLLAPSE'
bpy.context.scene.tool_settings.sculpt.detail_type_method = 'CONSTANT'
bpy.context.scene.tool_settings.sculpt.use_smooth_shading = True
return {'FINISHED'}
#Sculpt Symmetrize +X to -X
class SculptSymmetrizePlusX(bpy.types.Operator):
bl_idname = "sculpt.symmetrizeplusx"
bl_label = "Sculpt Symmetrize +X to -X"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
bpy.ops.sculpt.symmetrize()
if bpy.context.scene.tool_settings.sculpt.symmetrize_direction == 'NEGATIVE_X' :
bpy.context.scene.tool_settings.sculpt.symmetrize_direction = 'POSITIVE_X'
return {'FINISHED'}
#Sculpt Symmetrize -X to +X
class SculptSymmetrizeMoinsX(bpy.types.Operator):
bl_idname = "sculpt.symmetrizemoinsx"
bl_label = "Sculpt Symmetrize - X to + X"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
bpy.ops.sculpt.symmetrize()
if bpy.context.scene.tool_settings.sculpt.symmetrize_direction == 'POSITIVE_X' :
bpy.context.scene.tool_settings.sculpt.symmetrize_direction = 'NEGATIVE_X'
return {'FINISHED'}
#Sculpt Use symetry X
class SculptUseSymmetryX(bpy.types.Operator):
bl_idname = "sculpt.sculptusesymmetryx"
bl_label = "Sculpt Use symetry X"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
if bpy.context.scene.tool_settings.sculpt.use_symmetry_x == (True):
bpy.context.scene.tool_settings.sculpt.use_symmetry_x = False
elif bpy.context.scene.tool_settings.sculpt.use_symmetry_x == (False) :
bpy.context.scene.tool_settings.sculpt.use_symmetry_x = True
return {'FINISHED'}
#Sculpt Use symetry Y
class SculptUseSymmetryY(bpy.types.Operator):
bl_idname = "sculpt.sculptusesymmetryy"
bl_label = "Sculpt Use symetry Y"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
if bpy.context.scene.tool_settings.sculpt.use_symmetry_y == (True):
bpy.context.scene.tool_settings.sculpt.use_symmetry_y = False
elif bpy.context.scene.tool_settings.sculpt.use_symmetry_y == (False) :
bpy.context.scene.tool_settings.sculpt.use_symmetry_y = True
return {'FINISHED'}
#Sculpt Use symetry Z
class SculptUseSymmetryZ(bpy.types.Operator):
bl_idname = "sculpt.sculptusesymmetryz"
bl_label = "Sculpt Use symetry Z"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
if bpy.context.scene.tool_settings.sculpt.use_symmetry_z == (True):
bpy.context.scene.tool_settings.sculpt.use_symmetry_z = False
elif bpy.context.scene.tool_settings.sculpt.use_symmetry_z == (False) :
bpy.context.scene.tool_settings.sculpt.use_symmetry_z = True
return {'FINISHED'}
#Pivot to selection
class PivotToSelection(bpy.types.Operator):
bl_idname = "object.pivot2selection"
bl_label = "Pivot To Selection"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
saved_location = bpy.context.scene.cursor_location.copy()
bpy.ops.view3d.snap_cursor_to_selected()
bpy.ops.object.mode_set(mode = 'OBJECT')
bpy.ops.object.origin_set(type='ORIGIN_CURSOR')
bpy.context.scene.cursor_location = saved_location
return {'FINISHED'}
#Pivot to Bottom
class PivotBottom(bpy.types.Operator):
bl_idname = "object.pivotobottom"
bl_label = "Pivot To Bottom"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
bpy.ops.object.mode_set(mode = 'OBJECT')
bpy.ops.object.transform_apply(location=True, rotation=True, scale=True)
bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY')
o=bpy.context.active_object
init=0
for x in o.data.vertices:
if init==0:
a=x.co.z
init=1
elif x.co.z<a:
a=x.co.z
for x in o.data.vertices:
x.co.z-=a
o.location.z+=a
bpy.ops.object.mode_set(mode = 'EDIT')
return {'FINISHED'}
#Space
class RetopoSpace(bpy.types.Operator):
bl_idname = "retopo.space"
bl_label = "Retopo Space"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
bpy.ops.mesh.looptools_space(influence=100, input='selected', interpolation='cubic', lock_x=False, lock_y=False, lock_z=False)
return {'FINISHED'}
#Freeze and keep pivot
class FreezeAndKeepPivot(bpy.types.Operator):
bl_idname = "object.freezeandkeeppivot"
bl_label = "Freeze And Keep Pivot"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
#Save the cursor first position
saved_location_0 = bpy.context.scene.cursor_location.copy()
#Move the cursor to the active origin object
bpy.ops.view3d.snap_cursor_to_active()
#Save the cursor position 2
saved_location = bpy.context.scene.cursor_location.copy()
#apply all transforms, that move the origin of the object to 0,0,0
bpy.ops.apply.transformall()
#Move the cursor to the second location saved
bpy.context.scene.cursor_location = saved_location
#Move the origin to the cursor
bpy.ops.object.origin_set(type='ORIGIN_CURSOR')
#Move the cursor to his first location
bpy.context.scene.cursor_location = saved_location_0
return {'FINISHED'}
#--------------------------------------------------------------------------
#Particles
#--------------------------------------------------------------------------
#Particle Path Steps
class ParticlePathSteps(bpy.types.Operator):
bl_idname = "object.particlepathsteps"
bl_label = "Particle Path Steps"
bl_options = {'REGISTER', 'UNDO'}
variable = bpy.props.IntProperty()
def execute(self, context):
bpy.context.scene.tool_settings.particle_edit.draw_step = self.variable
return {'FINISHED'}
#Particle Childrens
class ParticleChildrens(bpy.types.Operator):
bl_idname = "object.particlechildren"
bl_label = "Particle Childrens"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
if bpy.context.scene.tool_settings.particle_edit.show_particles == True:
bpy.context.scene.tool_settings.particle_edit.show_particles = False
bpy.context.area.type = 'VIEW_3D'
elif bpy.context.scene.tool_settings.particle_edit.show_particles == False:
bpy.context.scene.tool_settings.particle_edit.show_particles = True
bpy.context.area.type = 'VIEW_3D'
return {'FINISHED'}
#Particle Length
class ParticleLength(bpy.types.Operator):
bl_idname = "object.particlelength"
bl_label = "Particle Length"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
if bpy.context.scene.tool_settings.particle_edit.use_preserve_length == True:
bpy.context.scene.tool_settings.particle_edit.use_preserve_length = False
bpy.context.area.type = 'VIEW_3D'
elif bpy.context.scene.tool_settings.particle_edit.use_preserve_length == False:
bpy.context.scene.tool_settings.particle_edit.use_preserve_length = True
bpy.context.area.type = 'VIEW_3D'
return {'FINISHED'}
#Particle X Mirror
class ParticleXMirror(bpy.types.Operator):
bl_idname = "object.particlexmirror"
bl_label = "Particle X Mirror"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
if bpy.context.object.data.use_mirror_x == True:
bpy.context.object.data.use_mirror_x = False
bpy.context.area.type = 'VIEW_3D'
elif bpy.context.object.data.use_mirror_x == False:
bpy.context.object.data.use_mirror_x = True
bpy.context.area.type = 'VIEW_3D'
return {'FINISHED'}
#Particle Root
class ParticleRoot(bpy.types.Operator):
bl_idname = "object.particleroot"
bl_label = "Particle Root"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
if bpy.context.scene.tool_settings.particle_edit.use_preserve_root == True:
bpy.context.scene.tool_settings.particle_edit.use_preserve_root = False
bpy.context.area.type = 'VIEW_3D'
elif bpy.context.scene.tool_settings.particle_edit.use_preserve_root == False:
bpy.context.scene.tool_settings.particle_edit.use_preserve_root = True
bpy.context.area.type = 'VIEW_3D'
return {'FINISHED'}
#Selection Particles Mode
class SelectionParticlesMode(bpy.types.Operator):
bl_idname = "object.spm"
bl_label = "Selection Particles Mode"
bl_options = {'REGISTER', 'UNDO'}
variable = bpy.props.StringProperty()
def execute(self, context):
bpy.context.scene.tool_settings.particle_edit.select_mode = self.variable
return {'FINISHED'}
#Selection Particles Brushes
class SelectionParticlesBrushes(bpy.types.Operator):
bl_idname = "object.spb"
bl_label = "Selection Particles Brushes"
bl_options = {'REGISTER', 'UNDO'}
variable = bpy.props.StringProperty()
def execute(self, context):
bpy.context.scene.tool_settings.particle_edit.tool = self.variable
bpy.context.area.type = 'VIEW_3D'
return {'FINISHED'}
#Particles Interpolate
class ParticlesInterpolate(bpy.types.Operator):
bl_idname = "object.particleinterpolate"
bl_label = "Particles Interpolate"
bl_options = {'REGISTER', 'UNDO'}
variable = bpy.props.IntProperty()
def execute(self, context):
if bpy.context.scene.tool_settings.particle_edit.use_default_interpolate == True:
bpy.context.scene.tool_settings.particle_edit.use_default_interpolate = False
bpy.context.area.type = 'VIEW_3D'
elif bpy.context.scene.tool_settings.particle_edit.use_default_interpolate == False:
bpy.context.scene.tool_settings.particle_edit.use_default_interpolate = True
bpy.context.area.type = 'VIEW_3D'
return {'FINISHED'}
#Make Object An Empty
class MakeObjectAnEmpty(bpy.types.Operator):
bl_idname = "object.makeempty"
bl_label = "Make Object An Empty"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
if bpy.context.object.hide_render == False:
bpy.context.object.hide_render = True
bpy.context.object.draw_type = 'WIRE'
bpy.context.object.cycles_visibility.camera = False
bpy.context.object.cycles_visibility.diffuse = False
bpy.context.object.cycles_visibility.glossy = False
bpy.context.object.cycles_visibility.scatter = False
bpy.context.object.cycles_visibility.transmission = False
bpy.context.object.cycles_visibility.shadow = False
elif bpy.context.object.hide_render == True:
bpy.context.object.hide_render = False
bpy.context.object.draw_type = 'SOLID'
bpy.context.object.cycles_visibility.camera = True
bpy.context.object.cycles_visibility.diffuse = True
bpy.context.object.cycles_visibility.glossy = True
bpy.context.object.cycles_visibility.scatter = True
bpy.context.object.cycles_visibility.transmission = True
bpy.context.object.cycles_visibility.shadow = True
return {'FINISHED'}
#Clear Empty
class ClearEmpty(bpy.types.Operator):
bl_idname = "object.clearempty"
bl_label = "Clear Empty"
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
return context.active_object is not None
def execute(self, context):
C = bpy.context
for obj in C.object.children:
obj.select = True
bpy.ops.object.parent_clear(type='CLEAR_KEEP_TRANSFORM')
bpy.ops.object.select_all(action='TOGGLE')
return {'FINISHED'}
#Mark Seam
class MarkSeam(bpy.types.Operator):
bl_idname = "mark.seam"
bl_label = "Mark Seam"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
bpy.ops.mesh.mark_seam()
return {'FINISHED'}
#Clear Seam
class ClearSeam(bpy.types.Operator):
bl_idname = "clear.seam"
bl_label = "Clear Seam"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
bpy.ops.mesh.mark_seam(clear=True)
return {'FINISHED'}
######################
# Pies #
######################
#Pie Sculpt Mirror
class PieSculptMirror(Menu):
bl_idname = "pie.sculptmirror"
bl_label = "Pie Sculpt Mirror"
def draw(self, context):
layout = self.layout
pie = layout.menu_pie()
sculpt = context.tool_settings.sculpt
#4 - LEFT
pie.operator("sculpt.symmetrizemoinsx", text="-X to +X", icon='TRIA_RIGHT')
#6 - RIGHT
pie.operator("sculpt.symmetrizeplusx", text="+X to -X", icon='TRIA_LEFT')
#2 - BOTTOM
if bpy.context.scene.tool_settings.sculpt.use_symmetry_y == (True):
pie.operator("sculpt.sculptusesymmetryy", text="Unlock Y", icon='LOCKED')
else:
pie.operator("sculpt.sculptusesymmetryy", text="Lock Y", icon='UNLOCKED')
#8 - TOP
pie.operator("object.symetrylocky", text="Symmetrize Y", icon='MOD_MIRROR')
#7 - TOP - LEFT
pie.operator("object.symetrylockx", text="Symmetrize X", icon='MOD_MIRROR')
#9 - TOP - RIGHT
pie.operator("object.symetrylockz", text="Symmetrize Z", icon='MOD_MIRROR')
#1 - BOTTOM - LEFT
if bpy.context.scene.tool_settings.sculpt.use_symmetry_x == (True):
pie.operator("sculpt.sculptusesymmetryx", text="Unlock X", icon='LOCKED')
else:
pie.operator("sculpt.sculptusesymmetryx", text="Lock X", icon='UNLOCKED')
#3 - BOTTOM - RIGHT
if bpy.context.scene.tool_settings.sculpt.use_symmetry_z == (True):
pie.operator("sculpt.sculptusesymmetryz", text="Unlock Z", icon='LOCKED')
else:
pie.operator("sculpt.sculptusesymmetryz", text="Lock Z", icon='UNLOCKED')
#Pie Particle Brushes
class PieParticleBrushes(Menu):
bl_idname = "pie.particleparameters"
bl_label = "Pie Particle Parameters"
def draw(self, context):
layout = self.layout
pie = layout.menu_pie()
#4 - LEFT
pie.operator("object.spm", text="Path", icon='PARTICLE_PATH').variable = 'PATH'
#6 - RIGHT
pie.operator("object.spm", text="Point", icon='PARTICLE_POINT').variable = 'POINT'
#2 - BOTTOM
pie.operator("object.spm", text="Tip", icon='PARTICLE_TIP').variable = 'TIP'
#8 - TOP
pie.operator("wm.call_menu_pie", text="Brushes", icon='BRUSH_DATA').name="pie.particlebrushes"
#7 - TOP - LEFT
pie.operator("wm.call_menu_pie", text="Options", icon='SCRIPTWIN').name="pie.particleoptions"
#9 - TOP - RIGHT
if bpy.context.scene.tool_settings.particle_edit.show_particles == (True):
pie.operator("object.particlechildren", text="Chidren OFF", icon='HAIR')
else:
pie.operator("object.particlechildren", text="Chidren ON", icon='HAIR')
#1 - BOTTOM - LEFT
if bpy.context.scene.tool_settings.particle_edit.use_default_interpolate == (True):
pie.operator("object.particleinterpolate", text="Interpolate OFF", icon='HAIR')
else:
pie.operator("object.particleinterpolate", text="Interpolate ON", icon='HAIR')
#3 - BOTTOM - RIGHT
if bpy.context.space_data.use_occlude_geometry == (True):
pie.operator("wm.context_toggle", text="Occlude Geo ON", icon="ORTHO").data_path = "space_data.use_occlude_geometry"
else:
pie.operator("wm.context_toggle", text="Occlude Geo OFF", icon="ORTHO").data_path = "space_data.use_occlude_geometry"
#Pie Particle Options
class PieParticleOptions(Menu):
bl_idname = "pie.particleoptions"
bl_label = "Pie Particle Options"
def draw(self, context):
layout = self.layout
pie = layout.menu_pie()
#4 - LEFT
pie.operator("object.particlepathsteps", text="Path Steps = 6", icon='PARTICLE_POINT').variable = 6
#6 - RIGHT
pie.operator("object.particlepathsteps", text="Path Steps = 2", icon='PARTICLE_POINT').variable = 2
#2 - BOTTOM
pie.operator("object.particlepathsteps", text="Path Steps = 4", icon='PARTICLE_POINT').variable = 4
#8 - TOP
if bpy.context.scene.tool_settings.particle_edit.use_preserve_length == (True):
pie.operator("object.particlelength", text="Keep Lengths OFF", icon='RNDCURVE')
else :
pie.operator("object.particlelength", text="Keep Lengths ON", icon='RNDCURVE')
#7 - TOP - LEFT
if bpy.context.object.data.use_mirror_x == (True):
pie.operator("object.particlexmirror", text="X Mirror OFF", icon='MOD_MIRROR')
else :
pie.operator("object.particlexmirror", text="X Mirror ON", icon='MOD_MIRROR')
#9 - TOP - RIGHT
if bpy.context.scene.tool_settings.particle_edit.use_preserve_root == (True):
pie.operator("object.particleroot", text="Keep Root OFF", icon='LAYER_ACTIVE')
else :
pie.operator("object.particleroot", text="Keep Root ON", icon='LAYER_ACTIVE')
#1 - BOTTOM - LEFT
pie.operator("object.particlepathsteps", text="Path Steps = 5", icon='PARTICLE_POINT').variable = 5
#3 - BOTTOM - RIGHT
pie.operator("object.particlepathsteps", text="Path Steps = 3", icon='PARTICLE_POINT').variable = 3
########################################################################
########################################################################
#RMB
class View3dRightClicMenu(Menu):
bl_idname = "pie.rightclicmenu"
bl_label = "Right Clic Menu"
def draw(self, context):
layout = self.layout
pie = layout.menu_pie()
################################################
# No Objects #
################################################
if bpy.context.area.type == 'VIEW_3D' and not bpy.context.object:
#4 - LEFT
pie.operator("wm.read_homefile", text="New", icon='NEW')
#6 - RIGHT
box = pie.split().column()
row = box.split(align=True)
box.operator("wm.recover_last_session", text="Recover Last Session", icon='RECOVER_LAST')
box.operator("wm.recover_auto_save", text="Recover auto Save", icon='RECOVER_AUTO')
#2 - BOTTOM
box = pie.split().column()
row = box.split(align=True)
row.operator("mesh.primitive_cube_add", text="", icon='MESH_CUBE')
row.operator("mesh.primitive_plane_add", text="", icon='MESH_PLANE')
row.operator("mesh.primitive_uv_sphere_add", text="", icon='MESH_UVSPHERE')
row.operator("mesh.primitive_cylinder_add", text="", icon='MESH_CYLINDER')
row = box.row(align=True)
row = box.split(align=True)
row.operator("mesh.primitive_grid_add", text=" ", icon='MESH_GRID')
row.operator("mesh.primitive_circle_add", text=" ", icon='MESH_CIRCLE')
row.operator("mesh.primitive_cone_add", text=" ", icon='MESH_CONE')
row.operator("mesh.primitive_torus_add", text=" ", icon='MESH_TORUS')
row = box.row(align=True)
row = box.split(align=True)
row.operator("object.camera_add", text="", icon='OUTLINER_OB_CAMERA')
row.operator("object.lamp_add", text="", icon='LAMP_AREA').type = 'AREA'
row.operator("object.lamp_add", text="", icon='LAMP_SUN').type = 'SUN'
row.operator("object.lamp_add", text="", icon='LAMP_HEMI').type = 'HEMI'
box.menu("AddMenu", text="Objects", icon="OBJECT_DATA")
#8 - TOP
pie.operator("wm.save_mainfile", text="Save", icon='FILE_TICK')
#7 - TOP - LEFT
pie.operator("wm.open_mainfile", text="Open file", icon='FILE_FOLDER')
#9 - TOP - RIGHT
pie.operator("wm.save_as_mainfile", text="Save As...", icon='SAVE_AS')
#1 - BOTTOM - LEFT
box = pie.split().column()
row = box.split(align=True)
row.operator("import_scene.obj", text="Imp OBJ", icon='IMPORT')
row.operator("export_scene.obj", text="Exp OBJ", icon='EXPORT')
row = box.row(align=True)
row = box.split(align=True)
row.operator("import_scene.fbx", text="Imp FBX", icon='IMPORT')
row.operator("export_scene.fbx", text="Exp FBX", icon='EXPORT')
#3 - BOTTOM - RIGHT
box = pie.split().column()
row = box.split(align=True)
row.operator("wm.link", text="Link", icon='LINK_BLEND')
row.operator("wm.append", text="Append", icon='APPEND_BLEND')
################################################
# Object Mode #
################################################
elif bpy.context.area.type == 'VIEW_3D' and bpy.context.object.mode == 'OBJECT':
#4 - LEFT
box = pie.split().column()
row = box.split(percentage=0.4)
row.operator("Object.join", text="Join", icon='FULLSCREEN_EXIT')
row.operator("separate.looseparts", text="Separate", icon='FULLSCREEN_ENTER')
#6 - RIGHT
is_subsurf = False
for mode in bpy.context.object.modifiers :
if mode.type == 'SUBSURF' :
is_subsurf = True
if is_subsurf == True :
pie.operator("remove.subsurf", text="Remove Subsurf", icon='X')
else :
pie.operator("object.subsurf2", text="Add Subsurf", icon='MOD_SUBSURF')
#2 - BOTTOM
box = pie.split().column()
row = box.split(align=True)
row.operator("mesh.primitive_cube_add", text="", icon='MESH_CUBE')
row.operator("mesh.primitive_plane_add", text="", icon='MESH_PLANE')
row.operator("mesh.primitive_uv_sphere_add", text="", icon='MESH_UVSPHERE')
row.operator("mesh.primitive_cylinder_add", text="", icon='MESH_CYLINDER')
row = box.row(align=True)
row = box.split(align=True)
row.operator("mesh.primitive_grid_add", text=" ", icon='MESH_GRID')
row.operator("mesh.primitive_circle_add", text=" ", icon='MESH_CIRCLE')
row.operator("mesh.primitive_cone_add", text=" ", icon='MESH_CONE')
row.operator("mesh.primitive_torus_add", text=" ", icon='MESH_TORUS')
row = box.row(align=True)
row = box.split(align=True)
row.operator("object.camera_add", text="", icon='OUTLINER_OB_CAMERA')
row.operator("object.lamp_add", text="", icon='LAMP_AREA').type = 'AREA'
row.operator("object.lamp_add", text="", icon='LAMP_SUN').type = 'SUN'
row.operator("object.lamp_add", text="", icon='LAMP_HEMI').type = 'HEMI'
box.menu("AddMenu", text="Objects", icon="OBJECT_DATA")
#8 - TOP
pie.operator("screen.redo_last", text="F6", icon='SCRIPTWIN')
#7 - TOP - LEFT
box = pie.split().column()
row = box.split(align=True)
is_mirror = False
for mode in bpy.context.object.modifiers :
if mode.type == 'MIRROR' :
is_mirror = True
if is_mirror == True :
row.operator("object.modifier_remove", text="Del Mirror",icon='X').modifier="Mirror"
else:
row.operator("add.mirrorobject", text="Add Mirror", icon='MOD_MIRROR')
row.operator("object.automirror", icon = 'MOD_MIRROR')
row = box.row(align=True)
row = box.split(align=True)
row.operator("object.modifier_apply", text="Apply Mirror", icon='FILE_TICK').modifier="Mirror"
row = box.row(align=True)
row.operator_menu_enum("object.modifier_add", "type")
row.operator("delete.modifiers", text="Del Modifiers", icon='X')
#9 - TOP - RIGHT
box = pie.split().column()
row = box.row(align=True)
row.operator("object.origin_set", text="O To Cursor", icon='CURSOR').type ='ORIGIN_CURSOR'
row.operator("object.origin_set", text="O To COM", icon='CLIPUV_HLT').type ='ORIGIN_CENTER_OF_MASS'
row = box.row(align=True)
row.operator("object.origin_set", text="Origin To Geo", icon='ROTATE').type ='ORIGIN_GEOMETRY'
row.operator("object.origin_set", text="Geo To Origin", icon='BBOX').type ='GEOMETRY_ORIGIN'
row = box.row(align=True)
row.operator("view3d.snap_selected_to_cursor", text="Sel to Cursor", icon='CLIPUV_HLT').use_offset = False
row.operator("view3d.snap_cursor_to_selected", text="Cursor to Sel", icon='ROTACTIVE')
row = box.row(align=True)
row.operator("object.pivot2selection", text="Origin To Sel", icon='SNAP_INCREMENT')
row.operator("object.pivotobottom", text="Origin To Bottom", icon='TRIA_DOWN')
#1 - BOTTOM - LEFT
box = pie.split().column()
row = box.row(align=True)
row.operator("object.freezeandkeeppivot", text="Apply T Keep Origin", icon='FILE_TICK')
row = box.row(align=True)
row.operator("apply.transformall", text="Apply T", icon='FILE_TICK')
row.operator("clear.all", text="Clear All", icon='MANIPUL')
#3 - BOTTOM - RIGHT
box = pie.split().column()
row = box.row(align=True)
row.operator("object.modifier_apply", text="Apply Subsurf", icon='FILE_TICK').modifier="Subsurf"
row = box.row(align=True)
if bpy.context.object.hide_render == False:
row.operator("object.makeempty", text="Make Empty", icon='OUTLINER_OB_EMPTY')
row.operator("object.clearempty", text="Clear Empty", icon='MESH_DATA')
else :
row.operator("object.makeempty", text="Make Normal", icon='MESH_CUBE')