diff --git a/node_wrangler.py b/node_wrangler.py index ce8cfb9a1cdd14654534e4b24949ce0fcfb153c6..e4409d3fcb6800d0f2f21c3edc75442eb1bdc886 100644 --- a/node_wrangler.py +++ b/node_wrangler.py @@ -1502,11 +1502,18 @@ class NWEmissionViewer(Operator, NWBase): return False def invoke(self, context, event): - shader_type = context.space_data.shader_type + space = context.space_data + shader_type = space.shader_type if shader_type == 'OBJECT': - shader_output_type = "OUTPUT_MATERIAL" - shader_output_ident = "ShaderNodeOutputMaterial" - shader_viewer_ident = "ShaderNodeEmission" + if space.id not in [lamp for lamp in bpy.data.lamps]: # cannot use bpy.data.lamps directly as iterable + shader_output_type = "OUTPUT_MATERIAL" + shader_output_ident = "ShaderNodeOutputMaterial" + shader_viewer_ident = "ShaderNodeEmission" + else: + shader_output_type = "OUTPUT_LAMP" + shader_output_ident = "ShaderNodeOutputLamp" + shader_viewer_ident = "ShaderNodeEmission" + elif shader_type == 'WORLD': shader_output_type = "OUTPUT_WORLD" shader_output_ident = "ShaderNodeOutputWorld" @@ -1517,7 +1524,7 @@ class NWEmissionViewer(Operator, NWBase): select_node = bpy.ops.node.select(mouse_x=mlocx, mouse_y=mlocy, extend=False) if 'FINISHED' in select_node: # only run if mouse click is on a node nodes, links = get_nodes_links(context) - in_group = context.active_node != context.space_data.node_tree.nodes.active + in_group = context.active_node != space.node_tree.nodes.active active = nodes.active output_types = [x[1] for x in shaders_output_nodes_props] valid = False