1 # SPDX-FileCopyrightText: 2023 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
6 from bpy
.props
import EnumProperty
, BoolProperty
, StringProperty
7 from nodeitems_utils
import node_categories_iter
9 from . import operators
10 from . import interface
12 from .utils
.constants
import nice_hotkey_name
16 class NWPrincipledPreferences(bpy
.types
.PropertyGroup
):
17 base_color
: StringProperty(
19 default
='diffuse diff albedo base col color basecolor',
20 description
='Naming Components for Base Color maps')
21 metallic
: StringProperty(
23 default
='metallic metalness metal mtl',
24 description
='Naming Components for metallness maps')
25 specular
: StringProperty(
27 default
='specularity specular spec spc',
28 description
='Naming Components for Specular maps')
29 normal
: StringProperty(
31 default
='normal nor nrm nrml norm',
32 description
='Naming Components for Normal maps')
36 description
='Naming Components for bump maps')
37 rough
: StringProperty(
39 default
='roughness rough rgh',
40 description
='Naming Components for roughness maps')
41 gloss
: StringProperty(
43 default
='gloss glossy glossiness',
44 description
='Naming Components for glossy maps')
45 displacement
: StringProperty(
47 default
='displacement displace disp dsp height heightmap',
48 description
='Naming Components for displacement maps')
49 transmission
: StringProperty(
51 default
='transmission transparency',
52 description
='Naming Components for transmission maps')
53 emission
: StringProperty(
55 default
='emission emissive emit',
56 description
='Naming Components for emission maps')
57 alpha
: StringProperty(
59 default
='alpha opacity',
60 description
='Naming Components for alpha maps')
61 ambient_occlusion
: StringProperty(
62 name
='Ambient Occlusion',
63 default
='ao ambient occlusion',
64 description
='Naming Components for AO maps')
68 class NWNodeWrangler(bpy
.types
.AddonPreferences
):
69 bl_idname
= __package__
71 merge_hide
: EnumProperty(
72 name
="Hide Mix nodes",
74 ("ALWAYS", "Always", "Always collapse the new merge nodes"),
75 ("NON_SHADER", "Non-Shader", "Collapse in all cases except for shaders"),
76 ("NEVER", "Never", "Never collapse the new merge nodes")
79 description
="When merging nodes with the Ctrl+Numpad0 hotkey (and similar) specify whether to collapse them or show the full node with options expanded")
80 merge_position
: EnumProperty(
81 name
="Mix Node Position",
83 ("CENTER", "Center", "Place the Mix node between the two nodes"),
84 ("BOTTOM", "Bottom", "Place the Mix node at the same height as the lowest node")
87 description
="When merging nodes with the Ctrl+Numpad0 hotkey (and similar) specify the position of the new nodes")
89 show_hotkey_list
: BoolProperty(
90 name
="Show Hotkey List",
92 description
="Expand this box into a list of all the hotkeys for functions in this addon"
94 hotkey_list_filter
: StringProperty(
95 name
=" Filter by Name",
97 description
="Show only hotkeys that have this text in their name",
98 options
={'TEXTEDIT_UPDATE'}
100 show_principled_lists
: BoolProperty(
101 name
="Show Principled naming tags",
103 description
="Expand this box into a list of all naming tags for principled texture setup"
105 principled_tags
: bpy
.props
.PointerProperty(type=NWPrincipledPreferences
)
107 def draw(self
, context
):
109 col
= layout
.column()
110 col
.prop(self
, "merge_position")
111 col
.prop(self
, "merge_hide")
114 col
= box
.column(align
=True)
117 "show_principled_lists",
118 text
='Edit tags for auto texture detection in Principled BSDF setup',
120 if self
.show_principled_lists
:
121 tags
= self
.principled_tags
123 col
.prop(tags
, "base_color")
124 col
.prop(tags
, "metallic")
125 col
.prop(tags
, "specular")
126 col
.prop(tags
, "rough")
127 col
.prop(tags
, "gloss")
128 col
.prop(tags
, "normal")
129 col
.prop(tags
, "bump")
130 col
.prop(tags
, "displacement")
131 col
.prop(tags
, "transmission")
132 col
.prop(tags
, "emission")
133 col
.prop(tags
, "alpha")
134 col
.prop(tags
, "ambient_occlusion")
137 col
= box
.column(align
=True)
138 hotkey_button_name
= "Show Hotkey List"
139 if self
.show_hotkey_list
:
140 hotkey_button_name
= "Hide Hotkey List"
141 col
.prop(self
, "show_hotkey_list", text
=hotkey_button_name
, toggle
=True)
142 if self
.show_hotkey_list
:
143 col
.prop(self
, "hotkey_list_filter", icon
="VIEWZOOM")
145 for hotkey
in kmi_defs
:
147 hotkey_name
= hotkey
[7]
149 if self
.hotkey_list_filter
.lower() in hotkey_name
.lower():
150 row
= col
.row(align
=True)
151 row
.label(text
=hotkey_name
)
152 keystr
= nice_hotkey_name(hotkey
[1])
154 keystr
= "Shift " + keystr
156 keystr
= "Alt " + keystr
158 keystr
= "Ctrl " + keystr
159 row
.label(text
=keystr
)
163 # REGISTER/UNREGISTER CLASSES AND KEYMAP ITEMS
165 switch_category_menus
= []
167 # kmi_defs entry: (identifier, key, action, CTRL, SHIFT, ALT, props, nice name)
168 # props entry: (property name, property value)
171 # NWMergeNodes with Ctrl (AUTO).
172 (operators
.NWMergeNodes
.bl_idname
, 'NUMPAD_0', 'PRESS', True, False, False,
173 (('mode', 'MIX'), ('merge_type', 'AUTO'),), "Merge Nodes (Automatic)"),
174 (operators
.NWMergeNodes
.bl_idname
, 'ZERO', 'PRESS', True, False, False,
175 (('mode', 'MIX'), ('merge_type', 'AUTO'),), "Merge Nodes (Automatic)"),
176 (operators
.NWMergeNodes
.bl_idname
, 'NUMPAD_PLUS', 'PRESS', True, False, False,
177 (('mode', 'ADD'), ('merge_type', 'AUTO'),), "Merge Nodes (Add)"),
178 (operators
.NWMergeNodes
.bl_idname
, 'EQUAL', 'PRESS', True, False, False,
179 (('mode', 'ADD'), ('merge_type', 'AUTO'),), "Merge Nodes (Add)"),
180 (operators
.NWMergeNodes
.bl_idname
, 'NUMPAD_ASTERIX', 'PRESS', True, False, False,
181 (('mode', 'MULTIPLY'), ('merge_type', 'AUTO'),), "Merge Nodes (Multiply)"),
182 (operators
.NWMergeNodes
.bl_idname
, 'EIGHT', 'PRESS', True, False, False,
183 (('mode', 'MULTIPLY'), ('merge_type', 'AUTO'),), "Merge Nodes (Multiply)"),
184 (operators
.NWMergeNodes
.bl_idname
, 'NUMPAD_MINUS', 'PRESS', True, False, False,
185 (('mode', 'SUBTRACT'), ('merge_type', 'AUTO'),), "Merge Nodes (Subtract)"),
186 (operators
.NWMergeNodes
.bl_idname
, 'MINUS', 'PRESS', True, False, False,
187 (('mode', 'SUBTRACT'), ('merge_type', 'AUTO'),), "Merge Nodes (Subtract)"),
188 (operators
.NWMergeNodes
.bl_idname
, 'NUMPAD_SLASH', 'PRESS', True, False, False,
189 (('mode', 'DIVIDE'), ('merge_type', 'AUTO'),), "Merge Nodes (Divide)"),
190 (operators
.NWMergeNodes
.bl_idname
, 'SLASH', 'PRESS', True, False, False,
191 (('mode', 'DIVIDE'), ('merge_type', 'AUTO'),), "Merge Nodes (Divide)"),
192 (operators
.NWMergeNodes
.bl_idname
, 'COMMA', 'PRESS', True, False, False,
193 (('mode', 'LESS_THAN'), ('merge_type', 'MATH'),), "Merge Nodes (Less than)"),
194 (operators
.NWMergeNodes
.bl_idname
, 'PERIOD', 'PRESS', True, False, False,
195 (('mode', 'GREATER_THAN'), ('merge_type', 'MATH'),), "Merge Nodes (Greater than)"),
196 (operators
.NWMergeNodes
.bl_idname
, 'NUMPAD_PERIOD', 'PRESS', True, False, False,
197 (('mode', 'MIX'), ('merge_type', 'ZCOMBINE'),), "Merge Nodes (Z-Combine)"),
198 # NWMergeNodes with Ctrl Alt (MIX or ALPHAOVER)
199 (operators
.NWMergeNodes
.bl_idname
, 'NUMPAD_0', 'PRESS', True, False, True,
200 (('mode', 'MIX'), ('merge_type', 'ALPHAOVER'),), "Merge Nodes (Alpha Over)"),
201 (operators
.NWMergeNodes
.bl_idname
, 'ZERO', 'PRESS', True, False, True,
202 (('mode', 'MIX'), ('merge_type', 'ALPHAOVER'),), "Merge Nodes (Alpha Over)"),
203 (operators
.NWMergeNodes
.bl_idname
, 'NUMPAD_PLUS', 'PRESS', True, False, True,
204 (('mode', 'ADD'), ('merge_type', 'MIX'),), "Merge Nodes (Color, Add)"),
205 (operators
.NWMergeNodes
.bl_idname
, 'EQUAL', 'PRESS', True, False, True,
206 (('mode', 'ADD'), ('merge_type', 'MIX'),), "Merge Nodes (Color, Add)"),
207 (operators
.NWMergeNodes
.bl_idname
, 'NUMPAD_ASTERIX', 'PRESS', True, False, True,
208 (('mode', 'MULTIPLY'), ('merge_type', 'MIX'),), "Merge Nodes (Color, Multiply)"),
209 (operators
.NWMergeNodes
.bl_idname
, 'EIGHT', 'PRESS', True, False, True,
210 (('mode', 'MULTIPLY'), ('merge_type', 'MIX'),), "Merge Nodes (Color, Multiply)"),
211 (operators
.NWMergeNodes
.bl_idname
, 'NUMPAD_MINUS', 'PRESS', True, False, True,
212 (('mode', 'SUBTRACT'), ('merge_type', 'MIX'),), "Merge Nodes (Color, Subtract)"),
213 (operators
.NWMergeNodes
.bl_idname
, 'MINUS', 'PRESS', True, False, True,
214 (('mode', 'SUBTRACT'), ('merge_type', 'MIX'),), "Merge Nodes (Color, Subtract)"),
215 (operators
.NWMergeNodes
.bl_idname
, 'NUMPAD_SLASH', 'PRESS', True, False, True,
216 (('mode', 'DIVIDE'), ('merge_type', 'MIX'),), "Merge Nodes (Color, Divide)"),
217 (operators
.NWMergeNodes
.bl_idname
, 'SLASH', 'PRESS', True, False, True,
218 (('mode', 'DIVIDE'), ('merge_type', 'MIX'),), "Merge Nodes (Color, Divide)"),
219 # NWMergeNodes with Ctrl Shift (MATH)
220 (operators
.NWMergeNodes
.bl_idname
, 'NUMPAD_PLUS', 'PRESS', True, True, False,
221 (('mode', 'ADD'), ('merge_type', 'MATH'),), "Merge Nodes (Math, Add)"),
222 (operators
.NWMergeNodes
.bl_idname
, 'EQUAL', 'PRESS', True, True, False,
223 (('mode', 'ADD'), ('merge_type', 'MATH'),), "Merge Nodes (Math, Add)"),
224 (operators
.NWMergeNodes
.bl_idname
, 'NUMPAD_ASTERIX', 'PRESS', True, True, False,
225 (('mode', 'MULTIPLY'), ('merge_type', 'MATH'),), "Merge Nodes (Math, Multiply)"),
226 (operators
.NWMergeNodes
.bl_idname
, 'EIGHT', 'PRESS', True, True, False,
227 (('mode', 'MULTIPLY'), ('merge_type', 'MATH'),), "Merge Nodes (Math, Multiply)"),
228 (operators
.NWMergeNodes
.bl_idname
, 'NUMPAD_MINUS', 'PRESS', True, True, False,
229 (('mode', 'SUBTRACT'), ('merge_type', 'MATH'),), "Merge Nodes (Math, Subtract)"),
230 (operators
.NWMergeNodes
.bl_idname
, 'MINUS', 'PRESS', True, True, False,
231 (('mode', 'SUBTRACT'), ('merge_type', 'MATH'),), "Merge Nodes (Math, Subtract)"),
232 (operators
.NWMergeNodes
.bl_idname
, 'NUMPAD_SLASH', 'PRESS', True, True, False,
233 (('mode', 'DIVIDE'), ('merge_type', 'MATH'),), "Merge Nodes (Math, Divide)"),
234 (operators
.NWMergeNodes
.bl_idname
, 'SLASH', 'PRESS', True, True, False,
235 (('mode', 'DIVIDE'), ('merge_type', 'MATH'),), "Merge Nodes (Math, Divide)"),
236 (operators
.NWMergeNodes
.bl_idname
, 'COMMA', 'PRESS', True, True, False,
237 (('mode', 'LESS_THAN'), ('merge_type', 'MATH'),), "Merge Nodes (Math, Less than)"),
238 (operators
.NWMergeNodes
.bl_idname
, 'PERIOD', 'PRESS', True, True, False,
239 (('mode', 'GREATER_THAN'), ('merge_type', 'MATH'),), "Merge Nodes (Math, Greater than)"),
241 # NWBatchChangeNodes with Alt
242 (operators
.NWBatchChangeNodes
.bl_idname
, 'NUMPAD_0', 'PRESS', False, False, True,
243 (('blend_type', 'MIX'), ('operation', 'CURRENT'),), "Batch change blend type (Mix)"),
244 (operators
.NWBatchChangeNodes
.bl_idname
, 'ZERO', 'PRESS', False, False, True,
245 (('blend_type', 'MIX'), ('operation', 'CURRENT'),), "Batch change blend type (Mix)"),
246 (operators
.NWBatchChangeNodes
.bl_idname
, 'NUMPAD_PLUS', 'PRESS', False, False, True,
247 (('blend_type', 'ADD'), ('operation', 'ADD'),), "Batch change blend type (Add)"),
248 (operators
.NWBatchChangeNodes
.bl_idname
, 'EQUAL', 'PRESS', False, False, True,
249 (('blend_type', 'ADD'), ('operation', 'ADD'),), "Batch change blend type (Add)"),
250 (operators
.NWBatchChangeNodes
.bl_idname
, 'NUMPAD_ASTERIX', 'PRESS', False, False, True,
251 (('blend_type', 'MULTIPLY'), ('operation', 'MULTIPLY'),), "Batch change blend type (Multiply)"),
252 (operators
.NWBatchChangeNodes
.bl_idname
, 'EIGHT', 'PRESS', False, False, True,
253 (('blend_type', 'MULTIPLY'), ('operation', 'MULTIPLY'),), "Batch change blend type (Multiply)"),
254 (operators
.NWBatchChangeNodes
.bl_idname
, 'NUMPAD_MINUS', 'PRESS', False, False, True,
255 (('blend_type', 'SUBTRACT'), ('operation', 'SUBTRACT'),), "Batch change blend type (Subtract)"),
256 (operators
.NWBatchChangeNodes
.bl_idname
, 'MINUS', 'PRESS', False, False, True,
257 (('blend_type', 'SUBTRACT'), ('operation', 'SUBTRACT'),), "Batch change blend type (Subtract)"),
258 (operators
.NWBatchChangeNodes
.bl_idname
, 'NUMPAD_SLASH', 'PRESS', False, False, True,
259 (('blend_type', 'DIVIDE'), ('operation', 'DIVIDE'),), "Batch change blend type (Divide)"),
260 (operators
.NWBatchChangeNodes
.bl_idname
, 'SLASH', 'PRESS', False, False, True,
261 (('blend_type', 'DIVIDE'), ('operation', 'DIVIDE'),), "Batch change blend type (Divide)"),
262 (operators
.NWBatchChangeNodes
.bl_idname
, 'COMMA', 'PRESS', False, False, True,
263 (('blend_type', 'CURRENT'), ('operation', 'LESS_THAN'),), "Batch change blend type (Current)"),
264 (operators
.NWBatchChangeNodes
.bl_idname
, 'PERIOD', 'PRESS', False, False, True,
265 (('blend_type', 'CURRENT'), ('operation', 'GREATER_THAN'),), "Batch change blend type (Current)"),
266 (operators
.NWBatchChangeNodes
.bl_idname
, 'DOWN_ARROW', 'PRESS', False, False, True,
267 (('blend_type', 'NEXT'), ('operation', 'NEXT'),), "Batch change blend type (Next)"),
268 (operators
.NWBatchChangeNodes
.bl_idname
, 'UP_ARROW', 'PRESS', False, False, True,
269 (('blend_type', 'PREV'), ('operation', 'PREV'),), "Batch change blend type (Previous)"),
270 # LINK ACTIVE TO SELECTED
271 # Don't use names, don't replace links (K)
272 (operators
.NWLinkActiveToSelected
.bl_idname
, 'K', 'PRESS', False, False, False,
273 (('replace', False), ('use_node_name', False), ('use_outputs_names', False),), "Link active to selected (Don't replace links)"),
274 # Don't use names, replace links (Shift K)
275 (operators
.NWLinkActiveToSelected
.bl_idname
, 'K', 'PRESS', False, True, False,
276 (('replace', True), ('use_node_name', False), ('use_outputs_names', False),), "Link active to selected (Replace links)"),
277 # Use node name, don't replace links (')
278 (operators
.NWLinkActiveToSelected
.bl_idname
, 'QUOTE', 'PRESS', False, False, False,
279 (('replace', False), ('use_node_name', True), ('use_outputs_names', False),), "Link active to selected (Don't replace links, node names)"),
280 # Use node name, replace links (Shift ')
281 (operators
.NWLinkActiveToSelected
.bl_idname
, 'QUOTE', 'PRESS', False, True, False,
282 (('replace', True), ('use_node_name', True), ('use_outputs_names', False),), "Link active to selected (Replace links, node names)"),
283 # Don't use names, don't replace links (;)
284 (operators
.NWLinkActiveToSelected
.bl_idname
, 'SEMI_COLON', 'PRESS', False, False, False,
285 (('replace', False), ('use_node_name', False), ('use_outputs_names', True),), "Link active to selected (Don't replace links, output names)"),
286 # Don't use names, replace links (')
287 (operators
.NWLinkActiveToSelected
.bl_idname
, 'SEMI_COLON', 'PRESS', False, True, False,
288 (('replace', True), ('use_node_name', False), ('use_outputs_names', True),), "Link active to selected (Replace links, output names)"),
290 (operators
.NWChangeMixFactor
.bl_idname
, 'LEFT_ARROW', 'PRESS', False,
291 False, True, (('option', -0.1),), "Reduce Mix Factor by 0.1"),
292 (operators
.NWChangeMixFactor
.bl_idname
, 'RIGHT_ARROW', 'PRESS', False,
293 False, True, (('option', 0.1),), "Increase Mix Factor by 0.1"),
294 (operators
.NWChangeMixFactor
.bl_idname
, 'LEFT_ARROW', 'PRESS', False,
295 True, True, (('option', -0.01),), "Reduce Mix Factor by 0.01"),
296 (operators
.NWChangeMixFactor
.bl_idname
, 'RIGHT_ARROW', 'PRESS', False,
297 True, True, (('option', 0.01),), "Increase Mix Factor by 0.01"),
298 (operators
.NWChangeMixFactor
.bl_idname
, 'LEFT_ARROW', 'PRESS',
299 True, True, True, (('option', 0.0),), "Set Mix Factor to 0.0"),
300 (operators
.NWChangeMixFactor
.bl_idname
, 'RIGHT_ARROW', 'PRESS',
301 True, True, True, (('option', 1.0),), "Set Mix Factor to 1.0"),
302 (operators
.NWChangeMixFactor
.bl_idname
, 'NUMPAD_0', 'PRESS',
303 True, True, True, (('option', 0.0),), "Set Mix Factor to 0.0"),
304 (operators
.NWChangeMixFactor
.bl_idname
, 'ZERO', 'PRESS', True, True, True, (('option', 0.0),), "Set Mix Factor to 0.0"),
305 (operators
.NWChangeMixFactor
.bl_idname
, 'NUMPAD_1', 'PRESS', True, True, True, (('option', 1.0),), "Mix Factor to 1.0"),
306 (operators
.NWChangeMixFactor
.bl_idname
, 'ONE', 'PRESS', True, True, True, (('option', 1.0),), "Set Mix Factor to 1.0"),
307 # CLEAR LABEL (Alt L)
308 (operators
.NWClearLabel
.bl_idname
, 'L', 'PRESS', False, False, True, (('option', False),), "Clear node labels"),
309 # MODIFY LABEL (Alt Shift L)
310 (operators
.NWModifyLabels
.bl_idname
, 'L', 'PRESS', False, True, True, None, "Modify node labels"),
311 # Copy Label from active to selected
312 (operators
.NWCopyLabel
.bl_idname
, 'V', 'PRESS', False, True, False,
313 (('option', 'FROM_ACTIVE'),), "Copy label from active to selected"),
314 # DETACH OUTPUTS (Alt Shift D)
315 (operators
.NWDetachOutputs
.bl_idname
, 'D', 'PRESS', False, True, True, None, "Detach outputs"),
316 # LINK TO OUTPUT NODE (O)
317 (operators
.NWLinkToOutputNode
.bl_idname
, 'O', 'PRESS', False, False, False, None, "Link to output node"),
318 # SELECT PARENT/CHILDREN
320 (operators
.NWSelectParentChildren
.bl_idname
, 'RIGHT_BRACKET', 'PRESS',
321 False, False, False, (('option', 'CHILD'),), "Select children"),
323 (operators
.NWSelectParentChildren
.bl_idname
, 'LEFT_BRACKET', 'PRESS',
324 False, False, False, (('option', 'PARENT'),), "Select Parent"),
326 (operators
.NWAddTextureSetup
.bl_idname
, 'T', 'PRESS', True, False, False, None, "Add texture setup"),
327 # Add Principled BSDF Texture Setup
328 (operators
.NWAddPrincipledSetup
.bl_idname
, 'T', 'PRESS', True, True, False, None, "Add Principled texture setup"),
330 (operators
.NWResetBG
.bl_idname
, 'Z', 'PRESS', False, False, False, None, "Reset backdrop image zoom"),
332 (operators
.NWDeleteUnused
.bl_idname
, 'X', 'PRESS', False, False, True, None, "Delete unused nodes"),
334 (operators
.NWFrameSelected
.bl_idname
, 'P', 'PRESS', False, True, False, None, "Frame selected nodes"),
336 (operators
.NWSwapLinks
.bl_idname
, 'S', 'PRESS', False, False, True, None, "Swap Links"),
338 (operators
.NWPreviewNode
.bl_idname
, 'LEFTMOUSE', 'PRESS', True, True,
339 False, (('run_in_geometry_nodes', False),), "Preview node output"),
340 (operators
.NWPreviewNode
.bl_idname
, 'LEFTMOUSE', 'PRESS', False, True,
341 True, (('run_in_geometry_nodes', True),), "Preview node output"),
343 (operators
.NWReloadImages
.bl_idname
, 'R', 'PRESS', False, False, True, None, "Reload images"),
345 (operators
.NWLazyMix
.bl_idname
, 'RIGHTMOUSE', 'PRESS', True, True, False, None, "Lazy Mix"),
347 (operators
.NWLazyConnect
.bl_idname
, 'RIGHTMOUSE', 'PRESS', False, False, True, (('with_menu', False),), "Lazy Connect"),
348 # Lazy Connect with Menu
349 (operators
.NWLazyConnect
.bl_idname
, 'RIGHTMOUSE', 'PRESS', False,
350 True, True, (('with_menu', True),), "Lazy Connect with Socket Menu"),
352 (operators
.NWViewerFocus
.bl_idname
, 'LEFTMOUSE', 'DOUBLE_CLICK', False, False, False, None, "Set Viewers Tile Center"),
354 (operators
.NWAlignNodes
.bl_idname
, 'EQUAL', 'PRESS', False, True,
355 False, None, "Align selected nodes neatly in a row/column"),
356 # Reset Nodes (Back Space)
357 (operators
.NWResetNodes
.bl_idname
, 'BACK_SPACE', 'PRESS', False, False,
358 False, None, "Revert node back to default state, but keep connections"),
360 ('wm.call_menu', 'W', 'PRESS', False, True, False, (('name', interface
.NodeWranglerMenu
.bl_idname
),), "Node Wrangler menu"),
361 ('wm.call_menu', 'SLASH', 'PRESS', False, False, False,
362 (('name', interface
.NWAddReroutesMenu
.bl_idname
),), "Add Reroutes menu"),
363 ('wm.call_menu', 'NUMPAD_SLASH', 'PRESS', False, False, False,
364 (('name', interface
.NWAddReroutesMenu
.bl_idname
),), "Add Reroutes menu"),
365 ('wm.call_menu', 'BACK_SLASH', 'PRESS', False, False, False,
366 (('name', interface
.NWLinkActiveToSelectedMenu
.bl_idname
),), "Link active to selected (menu)"),
367 ('wm.call_menu', 'C', 'PRESS', False, True, False,
368 (('name', interface
.NWCopyToSelectedMenu
.bl_idname
),), "Copy to selected (menu)"),
369 ('wm.call_menu', 'S', 'PRESS', False, True, False,
370 (('name', interface
.NWSwitchNodeTypeMenu
.bl_idname
),), "Switch node type menu"),
374 NWPrincipledPreferences
, NWNodeWrangler
379 from bpy
.utils
import register_class
384 addon_keymaps
.clear()
385 kc
= bpy
.context
.window_manager
.keyconfigs
.addon
387 km
= kc
.keymaps
.new(name
='Node Editor', space_type
="NODE_EDITOR")
388 for (identifier
, key
, action
, CTRL
, SHIFT
, ALT
, props
, nicename
) in kmi_defs
:
389 kmi
= km
.keymap_items
.new(identifier
, key
, action
, ctrl
=CTRL
, shift
=SHIFT
, alt
=ALT
)
391 for prop
, value
in props
:
392 setattr(kmi
.properties
, prop
, value
)
393 addon_keymaps
.append((km
, kmi
))
396 switch_category_menus
.clear()
397 for cat
in node_categories_iter(None):
398 if cat
.name
not in ['Group', 'Script']:
399 idname
= f
"NODE_MT_nw_switch_{cat.identifier}_submenu"
400 switch_category_type
= type(idname
, (bpy
.types
.Menu
,), {
401 "bl_space_type": 'NODE_EDITOR',
402 "bl_label": cat
.name
,
405 "draw": interface
.draw_switch_category_submenu
,
408 switch_category_menus
.append(switch_category_type
)
410 bpy
.utils
.register_class(switch_category_type
)
414 for cat_types
in switch_category_menus
:
415 bpy
.utils
.unregister_class(cat_types
)
416 switch_category_menus
.clear()
419 for km
, kmi
in addon_keymaps
:
420 km
.keymap_items
.remove(kmi
)
421 addon_keymaps
.clear()
423 from bpy
.utils
import unregister_class
425 unregister_class(cls
)