Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-07-12 16:09:15 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-07-12 16:09:15 +0300
commit9dc19735c32dcec30d03516365c2cee8a4b4ddc6 (patch)
tree9ed6cd54c1f9e234618fbdc6b36e541b8bb3985d /node_wrangler.py
parent8a9cc98ff1328910b70f09bba196954c87738fb2 (diff)
Python: use fields
Diffstat (limited to 'node_wrangler.py')
-rw-r--r--node_wrangler.py96
1 files changed, 52 insertions, 44 deletions
diff --git a/node_wrangler.py b/node_wrangler.py
index 81566ed4..4f81b6ed 100644
--- a/node_wrangler.py
+++ b/node_wrangler.py
@@ -31,7 +31,15 @@ bl_info = {
import bpy, blf, bgl
from bpy.types import Operator, Panel, Menu
-from bpy.props import FloatProperty, EnumProperty, BoolProperty, IntProperty, StringProperty, FloatVectorProperty, CollectionProperty
+from bpy.props import (
+ FloatProperty,
+ EnumProperty,
+ BoolProperty,
+ IntProperty,
+ StringProperty,
+ FloatVectorProperty,
+ CollectionProperty,
+)
from bpy_extras.io_utils import ImportHelper, ExportHelper
from mathutils import Vector
from math import cos, sin, pi, hypot
@@ -996,39 +1004,39 @@ def get_nodes_links(context):
# Principled prefs
class NWPrincipledPreferences(bpy.types.PropertyGroup):
- base_color = StringProperty(
+ base_color: StringProperty(
name='Base Color',
default='diffuse diff albedo base col color',
description='Naming Components for Base Color maps')
- sss_color = StringProperty(
+ sss_color: StringProperty(
name='Subsurface Color',
default='sss subsurface',
description='Naming Components for Subsurface Color maps')
- metallic = StringProperty(
+ metallic: StringProperty(
name='Metallic',
default='metallic metalness metal mtl',
description='Naming Components for metallness maps')
- specular = StringProperty(
+ specular: StringProperty(
name='Specular',
default='specularity specular spec spc',
description='Naming Components for Specular maps')
- normal = StringProperty(
+ normal: StringProperty(
name='Normal',
default='normal nor nrm nrml norm',
description='Naming Components for Normal maps')
- bump = StringProperty(
+ bump: StringProperty(
name='Bump',
default='bump bmp',
description='Naming Components for bump maps')
- rough = StringProperty(
+ rough: StringProperty(
name='Roughness',
default='roughness rough rgh',
description='Naming Components for roughness maps')
- gloss = StringProperty(
+ gloss: StringProperty(
name='Gloss',
default='gloss glossy glossyness',
description='Naming Components for glossy maps')
- displacement = StringProperty(
+ displacement: StringProperty(
name='Displacement',
default='displacement displace disp dsp height heightmap',
description='Naming Components for displacement maps')
@@ -1037,7 +1045,7 @@ class NWPrincipledPreferences(bpy.types.PropertyGroup):
class NWNodeWrangler(bpy.types.AddonPreferences):
bl_idname = __name__
- merge_hide = EnumProperty(
+ merge_hide: EnumProperty(
name="Hide Mix nodes",
items=(
("ALWAYS", "Always", "Always collapse the new merge nodes"),
@@ -1046,7 +1054,7 @@ class NWNodeWrangler(bpy.types.AddonPreferences):
),
default='NON_SHADER',
description="When merging nodes with the Ctrl+Numpad0 hotkey (and similar) specifiy whether to collapse them or show the full node with options expanded")
- merge_position = EnumProperty(
+ merge_position: EnumProperty(
name="Mix Node Position",
items=(
("CENTER", "Center", "Place the Mix node between the two nodes"),
@@ -1055,22 +1063,22 @@ class NWNodeWrangler(bpy.types.AddonPreferences):
default='CENTER',
description="When merging nodes with the Ctrl+Numpad0 hotkey (and similar) specifiy the position of the new nodes")
- show_hotkey_list = BoolProperty(
+ show_hotkey_list: BoolProperty(
name="Show Hotkey List",
default=False,
description="Expand this box into a list of all the hotkeys for functions in this addon"
)
- hotkey_list_filter = StringProperty(
+ hotkey_list_filter: StringProperty(
name=" Filter by Name",
default="",
description="Show only hotkeys that have this text in their name"
)
- show_principled_lists = BoolProperty(
+ show_principled_lists: BoolProperty(
name="Show Principled naming tags",
default=False,
description="Expand this box into a list of all naming tags for principled texture setup"
)
- principled_tags = bpy.props.PointerProperty(type=NWPrincipledPreferences)
+ principled_tags: bpy.props.PointerProperty(type=NWPrincipledPreferences)
def draw(self, context):
layout = self.layout
@@ -1219,7 +1227,7 @@ class NWLazyConnect(Operator, NWBase):
bl_idname = "node.nw_lazy_connect"
bl_label = "Lazy Connect"
bl_options = {'REGISTER', 'UNDO'}
- with_menu = BoolProperty()
+ with_menu: BoolProperty()
def modal(self, context, event):
context.area.tag_redraw()
@@ -1325,8 +1333,8 @@ class NWDeleteUnused(Operator, NWBase):
bl_label = 'Delete Unused Nodes'
bl_options = {'REGISTER', 'UNDO'}
- delete_muted = BoolProperty(name="Delete Muted", description="Delete (but reconnect, like Ctrl-X) all muted nodes", default=True)
- delete_frames = BoolProperty(name="Delete Empty Frames", description="Delete all frames that have no nodes inside them", default=True)
+ delete_muted: BoolProperty(name="Delete Muted", description="Delete (but reconnect, like Ctrl-X) all muted nodes", default=True)
+ delete_frames: BoolProperty(name="Delete Empty Frames", description="Delete all frames that have no nodes inside them", default=True)
def is_unused_node(self, node):
end_types = ['OUTPUT_MATERIAL', 'OUTPUT', 'VIEWER', 'COMPOSITE', \
@@ -1791,7 +1799,7 @@ class NWSwitchNodeType(Operator, NWBase):
bl_label = "Switch Node Type"
bl_options = {'REGISTER', 'UNDO'}
- to_type = EnumProperty(
+ to_type: EnumProperty(
name="Switch to type",
items=list(shaders_input_nodes_props) +
list(shaders_output_nodes_props) +
@@ -2005,12 +2013,12 @@ class NWMergeNodes(Operator, NWBase):
bl_description = "Merge Selected Nodes"
bl_options = {'REGISTER', 'UNDO'}
- mode = EnumProperty(
+ mode: EnumProperty(
name="mode",
description="All possible blend types and math operations",
items=blend_types + [op for op in operations if op not in blend_types],
)
- merge_type = EnumProperty(
+ merge_type: EnumProperty(
name="merge type",
description="Type of Merge to be used",
items=(
@@ -2256,11 +2264,11 @@ class NWBatchChangeNodes(Operator, NWBase):
bl_description = "Batch Change Blend Type and Math Operation"
bl_options = {'REGISTER', 'UNDO'}
- blend_type = EnumProperty(
+ blend_type: EnumProperty(
name="Blend Type",
items=blend_types + navs,
)
- operation = EnumProperty(
+ operation: EnumProperty(
name="Operation",
items=operations + navs,
)
@@ -2322,7 +2330,7 @@ class NWChangeMixFactor(Operator, NWBase):
# option: Change factor.
# If option is 1.0 or 0.0 - set to 1.0 or 0.0
# Else - change factor by option value.
- option = FloatProperty()
+ option: FloatProperty()
def execute(self, context):
nodes, links = get_nodes_links(context)
@@ -2458,7 +2466,7 @@ class NWCopyLabel(Operator, NWBase):
bl_label = "Copy Label"
bl_options = {'REGISTER', 'UNDO'}
- option = EnumProperty(
+ option: EnumProperty(
name="option",
description="Source of name of label",
items=(
@@ -2502,7 +2510,7 @@ class NWClearLabel(Operator, NWBase):
bl_label = "Clear Label"
bl_options = {'REGISTER', 'UNDO'}
- option = BoolProperty()
+ option: BoolProperty()
def execute(self, context):
nodes, links = get_nodes_links(context)
@@ -2557,7 +2565,7 @@ class NWAddTextureSetup(Operator, NWBase):
bl_description = "Add Texture Node Setup to Selected Shaders"
bl_options = {'REGISTER', 'UNDO'}
- add_mapping = BoolProperty(name="Add Mapping Nodes", description="Create coordinate and mapping nodes for the texture (ignored for selected texture nodes)", default=True)
+ add_mapping: BoolProperty(name="Add Mapping Nodes", description="Create coordinate and mapping nodes for the texture (ignored for selected texture nodes)", default=True)
@classmethod
def poll(cls, context):
@@ -2888,7 +2896,7 @@ class NWAddReroutes(Operator, NWBase):
bl_description = "Add Reroutes to Outputs"
bl_options = {'REGISTER', 'UNDO'}
- option = EnumProperty(
+ option: EnumProperty(
name="option",
items=[
('ALL', 'to all', 'Add to all outputs'),
@@ -2988,9 +2996,9 @@ class NWLinkActiveToSelected(Operator, NWBase):
bl_label = "Link Active Node to Selected"
bl_options = {'REGISTER', 'UNDO'}
- replace = BoolProperty()
- use_node_name = BoolProperty()
- use_outputs_names = BoolProperty()
+ replace: BoolProperty()
+ use_node_name: BoolProperty()
+ use_outputs_names: BoolProperty()
@classmethod
def poll(cls, context):
@@ -3068,7 +3076,7 @@ class NWAlignNodes(Operator, NWBase):
bl_idname = "node.nw_align_nodes"
bl_label = "Align Nodes"
bl_options = {'REGISTER', 'UNDO'}
- margin = IntProperty(name='Margin', default=50, description='The amount of space between nodes')
+ margin: IntProperty(name='Margin', default=50, description='The amount of space between nodes')
def execute(self, context):
nodes, links = get_nodes_links(context)
@@ -3138,7 +3146,7 @@ class NWSelectParentChildren(Operator, NWBase):
bl_label = "Select Parent or Children"
bl_options = {'REGISTER', 'UNDO'}
- option = EnumProperty(
+ option: EnumProperty(
name="option",
items=(
('PARENT', 'Select Parent', 'Select Parent Frame'),
@@ -3259,8 +3267,8 @@ class NWMakeLink(Operator, NWBase):
bl_idname = 'node.nw_make_link'
bl_label = 'Make Link'
bl_options = {'REGISTER', 'UNDO'}
- from_socket = IntProperty()
- to_socket = IntProperty()
+ from_socket: IntProperty()
+ to_socket: IntProperty()
def execute(self, context):
nodes, links = get_nodes_links(context)
@@ -3280,7 +3288,7 @@ class NWCallInputsMenu(Operator, NWBase):
bl_idname = 'node.nw_call_inputs_menu'
bl_label = 'Make Link'
bl_options = {'REGISTER', 'UNDO'}
- from_socket = IntProperty()
+ from_socket: IntProperty()
def execute(self, context):
nodes, links = get_nodes_links(context)
@@ -3443,8 +3451,8 @@ class NWViewerFocus(bpy.types.Operator):
bl_idname = "node.nw_viewer_focus"
bl_label = "Viewer Focus"
- x = bpy.props.IntProperty()
- y = bpy.props.IntProperty()
+ x: bpy.props.IntProperty()
+ y: bpy.props.IntProperty()
@classmethod
def poll(cls, context):
@@ -3498,8 +3506,8 @@ class NWSaveViewer(bpy.types.Operator, ExportHelper):
"""Save the current viewer node to an image file"""
bl_idname = "node.nw_save_viewer"
bl_label = "Save This Image"
- filepath = StringProperty(subtype="FILE_PATH")
- filename_ext = EnumProperty(
+ filepath: StringProperty(subtype="FILE_PATH")
+ filename_ext: EnumProperty(
name="Format",
description="Choose the file format to save to",
items=(('.bmp', "PNG", ""),
@@ -3733,11 +3741,11 @@ class NodeWranglerPanel(Panel, NWBase):
bl_region_type = "TOOLS"
bl_category = "Node Wrangler"
- prepend = StringProperty(
+ prepend: StringProperty(
name='prepend',
)
- append = StringProperty()
- remove = StringProperty()
+ append: StringProperty()
+ remove: StringProperty()
def draw(self, context):
self.layout.label(text="(Quick access: Ctrl+Space)")