1 # SPDX-FileCopyrightText: 2016-2022 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
7 "description": "Sculpt Brush Menu",
8 "author": "pitiwazou, meta-androcto",
10 "blender": (2, 80, 0),
14 "category": "Sculpt Pie"
19 from bpy
.types
import (
26 class PIE_OT_SculptSculptDraw(Operator
):
27 bl_idname
= "sculpt.sculptraw"
28 bl_label
= "Sculpt SculptDraw"
29 bl_options
= {'REGISTER', 'UNDO'}
31 def execute(self
, context
):
32 context
.tool_settings
.sculpt
.brush
= bpy
.data
.brushes
['SculptDraw']
36 # Pie Sculp Pie Menus - W
37 class PIE_MT_SculptPie(Menu
):
38 bl_idname
= "PIE_MT_sculpt"
39 bl_label
= "Pie Sculpt"
41 def draw(self
, context
):
44 pie
= layout
.menu_pie()
47 pie
.operator("paint.brush_select",
48 text
=" Crease", icon_value
=brush_icons
["crease"]).sculpt_tool
= 'CREASE'
50 pie
.operator("paint.brush_select",
51 text
=" Blob", icon_value
=brush_icons
["blob"]).sculpt_tool
= 'BLOB'
53 pie
.menu(PIE_MT_Sculpttwo
.bl_idname
, text
="More Brushes")
55 pie
.operator("sculpt.sculptraw",
56 text
=" Draw", icon_value
=brush_icons
["draw"])
58 pie
.operator("paint.brush_select",
59 text
=" Clay", icon_value
=brush_icons
["clay"]).sculpt_tool
= 'CLAY'
61 pie
.operator("paint.brush_select",
62 text
=" Clay Strips", icon_value
=brush_icons
["clay_strips"]).sculpt_tool
= 'CLAY_STRIPS'
64 pie
.operator("paint.brush_select",
65 text
=" Inflate/Deflate", icon_value
=brush_icons
["inflate"]).sculpt_tool
= 'INFLATE'
67 pie
.menu(PIE_MT_Sculptthree
.bl_idname
,
68 text
=" Grab Brushes", icon_value
=brush_icons
["grab"])
72 class PIE_MT_Sculpttwo(Menu
):
73 bl_idname
= "PIE_MT_sculpttwo"
74 bl_label
= "Pie Sculpt 2"
76 def draw(self
, context
):
81 layout
.operator("paint.brush_select", text
=' Smooth',
82 icon_value
=brush_icons
["smooth"]).sculpt_tool
= 'SMOOTH'
83 layout
.operator("paint.brush_select", text
=' Flatten',
84 icon_value
=brush_icons
["flatten"]).sculpt_tool
= 'FLATTEN'
85 layout
.operator("paint.brush_select", text
=' Scrape/Peaks',
86 icon_value
=brush_icons
["scrape"]).sculpt_tool
= 'SCRAPE'
87 layout
.operator("paint.brush_select", text
=' Fill/Deepen',
88 icon_value
=brush_icons
["fill"]).sculpt_tool
= 'FILL'
89 layout
.operator("paint.brush_select", text
=' Pinch/Magnify',
90 icon_value
=brush_icons
["pinch"]).sculpt_tool
= 'PINCH'
91 layout
.operator("paint.brush_select", text
=' Layer',
92 icon_value
=brush_icons
["layer"]).sculpt_tool
= 'LAYER'
93 layout
.operator("paint.brush_select", text
=' Mask',
94 icon_value
=brush_icons
["mask"]).sculpt_tool
= 'MASK'
98 class PIE_MT_Sculptthree(Menu
):
99 bl_idname
= "PIE_MT_sculptthree"
100 bl_label
= "Pie Sculpt 3"
102 def draw(self
, context
):
107 layout
.operator("paint.brush_select",
108 text
=' Grab', icon_value
=brush_icons
["grab"]).sculpt_tool
= 'GRAB'
109 layout
.operator("paint.brush_select",
110 text
=' Nudge', icon_value
=brush_icons
["nudge"]).sculpt_tool
= 'NUDGE'
111 layout
.operator("paint.brush_select",
112 text
=' Thumb', icon_value
=brush_icons
["thumb"]).sculpt_tool
= 'THUMB'
113 layout
.operator("paint.brush_select",
114 text
=' Snakehook', icon_value
=brush_icons
["snake_hook"]).sculpt_tool
= 'SNAKE_HOOK'
115 layout
.operator("paint.brush_select",
116 text
=' Rotate', icon_value
=brush_icons
["rotate"]).sculpt_tool
= 'ROTATE'
124 icons_directory
= bpy
.utils
.system_resource('DATAFILES', path
="icons")
126 "crease", "blob", "smooth", "draw", "clay", "clay_strips", "inflate", "grab",
127 "nudge", "thumb", "snake_hook", "rotate", "flatten", "scrape", "fill", "pinch",
130 for brush
in brushes
:
131 filename
= os
.path
.join(icons_directory
, f
"brush.sculpt.{brush}.dat")
132 icon_value
= bpy
.app
.icons
.new_triangles_from_file(filename
)
133 brush_icons
[brush
] = icon_value
138 for value
in brush_icons
.values():
139 bpy
.app
.icons
.release(value
)
146 PIE_OT_SculptSculptDraw
,
156 bpy
.utils
.register_class(cls
)
158 wm
= bpy
.context
.window_manager
159 if wm
.keyconfigs
.addon
:
161 km
= wm
.keyconfigs
.addon
.keymaps
.new(name
='Sculpt')
162 kmi
= km
.keymap_items
.new('wm.call_menu_pie', 'W', 'PRESS')
163 kmi
.properties
.name
= "PIE_MT_sculpt"
164 addon_keymaps
.append((km
, kmi
))
171 bpy
.utils
.unregister_class(cls
)
173 wm
= bpy
.context
.window_manager
174 kc
= wm
.keyconfigs
.addon
176 for km
, kmi
in addon_keymaps
:
177 km
.keymap_items
.remove(kmi
)
178 addon_keymaps
.clear()
181 if __name__
== "__main__":