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:
authorGreg Zaal <gregzzmail@gmail.com>2015-01-29 16:26:35 +0300
committerGreg Zaal <gregzzmail@gmail.com>2015-01-29 16:26:35 +0300
commit06e88a87815f9e275e525885f8b1ad1a30557eef (patch)
treef2d9056c3092515bb20e3a5d8701451d126141b1 /node_wrangler.py
parent18ca36be7f5803c1a20ea5d65e4ee631eb53dd3d (diff)
Node Wrangler: Minor update...
- Fix: Errors shown when using emission viewer without material output present - When creating material output for emission viewer, position it in the middle of nodes (issue was that it first created the new node at `0, 0` and then calculated average Y loc) - Remove unused var
Diffstat (limited to 'node_wrangler.py')
-rw-r--r--node_wrangler.py30
1 files changed, 18 insertions, 12 deletions
diff --git a/node_wrangler.py b/node_wrangler.py
index 0cf3c6c7..ce8cfb9a 100644
--- a/node_wrangler.py
+++ b/node_wrangler.py
@@ -19,7 +19,7 @@
bl_info = {
"name": "Node Wrangler",
"author": "Bartek Skorupa, Greg Zaal, Sebastian Koenig",
- "version": (3, 21),
+ "version": (3, 22),
"blender": (2, 72, 0),
"location": "Node Editor Toolbar or Ctrl-Space",
"description": "Various tools to enhance and speed up node-based workflow",
@@ -1491,13 +1491,15 @@ class NWEmissionViewer(Operator, NWBase):
@classmethod
def poll(cls, context):
is_cycles = context.scene.render.engine == 'CYCLES'
- valid = False
if nw_check(context):
space = context.space_data
- if space.tree_type == 'ShaderNodeTree' and is_cycles and\
- (context.active_node.type != "OUTPUT_MATERIAL" or context.active_node.type != "OUTPUT_WORLD"):
- valid = True
- return valid
+ if space.tree_type == 'ShaderNodeTree' and is_cycles:
+ if context.active_node:
+ if context.active_node.type != "OUTPUT_MATERIAL" or context.active_node.type != "OUTPUT_WORLD":
+ return True
+ else:
+ return True
+ return False
def invoke(self, context, event):
shader_type = context.space_data.shader_type
@@ -1527,28 +1529,32 @@ class NWEmissionViewer(Operator, NWBase):
break
if valid:
# get material_output node, store selection, deselect all
- materialout_exists = False
materialout = None # placeholder node
selection = []
for node in nodes:
if node.type == shader_output_type:
- materialout_exists = True
materialout = node
if node.select:
selection.append(node.name)
node.select = False
if not materialout:
- materialout = nodes.new(shader_output_ident)
+ # get right-most location
sorted_by_xloc = (sorted(nodes, key=lambda x: x.location.x))
max_xloc_node = sorted_by_xloc[-1]
if max_xloc_node.name == 'Emission Viewer':
max_xloc_node = sorted_by_xloc[-2]
- materialout.location.x = max_xloc_node.location.x + max_xloc_node.dimensions.x + 80
+
+ # get average y location
sum_yloc = 0
for node in nodes:
sum_yloc += node.location.y
- # put material output at average y location
- materialout.location.y = sum_yloc / len(nodes)
+
+ new_locx = max_xloc_node.location.x + max_xloc_node.dimensions.x + 80
+ new_locy = sum_yloc / len(nodes)
+
+ materialout = nodes.new(shader_output_ident)
+ materialout.location.x = new_locx
+ materialout.location.y = new_locy
materialout.select = False
# Analyze outputs, add "Emission Viewer" if needed, make links
out_i = None