[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [4439] Committing Nodes Efficiency Tools to trunk.

Bartek Skorupa bartekskorupa at bartekskorupa.com
Wed Mar 27 22:37:37 CET 2013


Revision: 4439
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=4439
Author:   bartekskorupa
Date:     2013-03-27 21:37:36 +0000 (Wed, 27 Mar 2013)
Log Message:
-----------
Committing Nodes Efficiency Tools to trunk.

'Nodes Efficiency Tools' is a set of several tools that can speed up working with nodes, both compositing and Cycles shaders.
They automate several tasks that by default require many clicks, drags etc.
All of the tools can be accessed via additional panel in node editor properties toolset or by hitting Ctrl-Space keyboard shortcut.
Most of the options however have their own keyboard shortcuts and using them is much more efficient.
You can find all of the info on the wikipage: http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Nodes/Nodes_Efficiency_Tools

Available options are as follows:

Merge selected nodes:
Imagine that you want to 'add' images represented by outputs of some nodes.
Standard way of doing it is to add MIX node, change blend type to 'Add' and link outputs of the nodes accordingly.
With Nodes Efficiency Tools you can select the nodes and hit (Ctrl +) keyboard shortcut.
Proper setup of nodes will be added and links will be made.
Other shortcuts are used for other blend types, you can also use 'Math' nodes for merging and different shortcuts allow to do so.

Batch Change Blend Type or Math Operation:
Hit (Alt-UP ARROW) or (Alt-Down ARROW) to change blend types or math operations of selected nodes.
It's often much quicker than standard way of doing it.
Use additional menu to select the blend type from the list and change types of all selected nodes at once.

Change Factor of Mix Nodes or Mix Shaders:
(Alt-LEFT ARROW), (Alt-RIGHT ARROW) shortcuts allow to change factors of selected Mix nodes or Mix Shader nodes by 0.1.
More precision is gained when we add Shift to the key combination.

Align Nodes:
We can align nodes nicer than by hitting S-X-zero. Even distribution of aligned nodes can be achieved easily. (Shift =)

Copy Settings:
We can copy settings from Active Node to all selected ones.
May be helpful if you want to use exactly the same RGB Curves nodes in different places of your node tree.
This option works with all node types.

Copy Label:
We can copy labels from one node to other nodes with one click.

Swap Nodes:
It's possible to change the node to other type.
Swap easily between 'Mix' and 'Alpha Over' nodes for example or easily change 'Diffuse' Shader to 'Glossy' Shader.

Link Active to Selected:
This option allows to link active node to all selected ones basing on several criteria.
May be extremely helpful when for example re-linking image sources.
We can easily change input Render Layers node to input image (MultiLayerEXR) preserving nodes setup.

All of the options are explained in details in the video tutorial embedded on the wikipage.

Added Paths:
-----------
    trunk/py/scripts/addons/node_efficiency_tools.py

Removed Paths:
-------------
    contrib/py/scripts/addons/node_efficiency_tools.py

Deleted: contrib/py/scripts/addons/node_efficiency_tools.py
===================================================================
--- contrib/py/scripts/addons/node_efficiency_tools.py	2013-03-27 18:28:51 UTC (rev 4438)
+++ contrib/py/scripts/addons/node_efficiency_tools.py	2013-03-27 21:37:36 UTC (rev 4439)
@@ -1,1511 +0,0 @@
-# ##### BEGIN GPL LICENSE BLOCK #####
-#
-#  This program is free software; you can redistribute it and/or
-#  modify it under the terms of the GNU General Public License
-#  as published by the Free Software Foundation; either version 2
-#  of the License, or (at your option) any later version.
-#
-#  This program is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#  GNU General Public License for more details.
-#
-#  You should have received a copy of the GNU General Public License
-#  along with this program; if not, write to the Free Software Foundation,
-#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# ##### END GPL LICENSE BLOCK #####
-
-bl_info = {
-    'name': "Nodes Efficiency Tools",
-    'author': "Bartek Skorupa",
-    'version': (2, 20),
-    'blender': (2, 6, 6),
-    'location': "Node Editor Properties Panel (Ctrl-SPACE)",
-    'description': "Nodes Efficiency Tools",
-    'warning': "",
-    'wiki_url': "http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Nodes/Nodes_Efficiency_Tools",
-    'tracker_url': "http://projects.blender.org/tracker/?func=detail&atid=468&aid=33543&group_id=153",
-    'category': "Node",
-    }
-
-import bpy
-from bpy.types import Operator, Panel, Menu
-from bpy.props import FloatProperty, EnumProperty, BoolProperty
-
-#################
-# rl_outputs:
-# list of outputs of Input Render Layer
-# with attributes determinig if pass is used,
-# and MultiLayer EXR outputs names and corresponding render engines
-#
-# rl_outputs entry = (render_pass, rl_output_name, exr_output_name, in_internal, in_cycles)
-rl_outputs = (
-    ('use_pass_ambient_occlusion', 'AO', 'AO', True, True),
-    ('use_pass_color', 'Color', 'Color', True, False),
-    ('use_pass_combined', 'Image', 'Combined', True, True),
-    ('use_pass_diffuse', 'Diffuse', 'Diffuse', True, False),
-    ('use_pass_diffuse_color', 'Diffuse Color', 'DiffCol', False, True),
-    ('use_pass_diffuse_direct', 'Diffuse Direct', 'DiffDir', False, True),
-    ('use_pass_diffuse_indirect', 'Diffuse Indirect', 'DiffInd', False, True),
-    ('use_pass_emit', 'Emit', 'Emit', True, False),
-    ('use_pass_environment', 'Environment', 'Env', True, False),
-    ('use_pass_glossy_color', 'Glossy Color', 'GlossCol', False, True),
-    ('use_pass_glossy_direct', 'Glossy Direct', 'GlossDir', False, True),
-    ('use_pass_glossy_indirect', 'Glossy Indirect', 'GlossInd', False, True),
-    ('use_pass_indirect', 'Indirect', 'Indirect', True, False),
-    ('use_pass_material_index', 'IndexMA', 'IndexMA', True, True),
-    ('use_pass_mist', 'Mist', 'Mist', True, False),
-    ('use_pass_normal', 'Normal', 'Normal', True, True),
-    ('use_pass_object_index', 'IndexOB', 'IndexOB', True, True),
-    ('use_pass_reflection', 'Reflect', 'Reflect', True, False),
-    ('use_pass_refraction', 'Refract', 'Refract', True, False),
-    ('use_pass_shadow', 'Shadow', 'Shadow', True, True),
-    ('use_pass_specular', 'Specular', 'Spec', True, False),
-    ('use_pass_transmission_color', 'Transmission Color', 'TransCol', False, True),
-    ('use_pass_transmission_direct', 'Transmission Direct', 'TransDir', False, True),
-    ('use_pass_transmission_indirect', 'Transmission Indirect', 'TransInd', False, True),
-    ('use_pass_uv', 'UV', 'UV', True, True),
-    ('use_pass_vector', 'Speed', 'Vector', True, True),
-    ('use_pass_z', 'Z', 'Depth', True, True),
-    )
-# list of blend types of "Mix" nodes in a form that can be used as 'items' for EnumProperty.
-blend_types = [
-    ('MIX', 'Mix', 'Mix Mode'),
-    ('ADD', 'Add', 'Add Mode'),
-    ('MULTIPLY', 'Multiply', 'Multiply Mode'),
-    ('SUBTRACT', 'Subtract', 'Subtract Mode'),
-    ('SCREEN', 'Screen', 'Screen Mode'),
-    ('DIVIDE', 'Divide', 'Divide Mode'),
-    ('DIFFERENCE', 'Difference', 'Difference Mode'),
-    ('DARKEN', 'Darken', 'Darken Mode'),
-    ('LIGHTEN', 'Lighten', 'Lighten Mode'),
-    ('OVERLAY', 'Overlay', 'Overlay Mode'),
-    ('DODGE', 'Dodge', 'Dodge Mode'),
-    ('BURN', 'Burn', 'Burn Mode'),
-    ('HUE', 'Hue', 'Hue Mode'),
-    ('SATURATION', 'Saturation', 'Saturation Mode'),
-    ('VALUE', 'Value', 'Value Mode'),
-    ('COLOR', 'Color', 'Color Mode'),
-    ('SOFT_LIGHT', 'Soft Light', 'Soft Light Mode'),
-    ('LINEAR_LIGHT', 'Linear Light', 'Linear Light Mode'),
-    ]
-# list of operations of "Math" nodes in a form that can be used as 'items' for EnumProperty.
-operations = [
-    ('ADD', 'Add', 'Add Mode'),
-    ('MULTIPLY', 'Multiply', 'Multiply Mode'),
-    ('SUBTRACT', 'Subtract', 'Subtract Mode'),
-    ('DIVIDE', 'Divide', 'Divide Mode'),
-    ('SINE', 'Sine', 'Sine Mode'),
-    ('COSINE', 'Cosine', 'Cosine Mode'),
-    ('TANGENT', 'Tangent', 'Tangent Mode'),
-    ('ARCSINE', 'Arcsine', 'Arcsine Mode'),
-    ('ARCCOSINE', 'Arccosine', 'Arccosine Mode'),
-    ('ARCTANGENT', 'Arctangent', 'Arctangent Mode'),
-    ('POWER', 'Power', 'Power Mode'),
-    ('LOGARITHM', 'Logatithm', 'Logarithm Mode'),
-    ('MINIMUM', 'Minimum', 'Minimum Mode'),
-    ('MAXIMUM', 'Maximum', 'Maximum Mode'),
-    ('ROUND', 'Round', 'Round Mode'),
-    ('LESS_THAN', 'Less Than', 'Less Thann Mode'),
-    ('GREATER_THAN', 'Greater Than', 'Greater Than Mode'),
-    ]
-# in BatchChangeNodes additional types/operations in a form that can be used as 'items' for EnumProperty.
-navs = [
-    ('CURRENT', 'Current', 'Leave at current state'),
-    ('NEXT', 'Next', 'Next blend type/operation'),
-    ('PREV', 'Prev', 'Previous blend type/operation'),
-    ]
-# list of mixing shaders
-merge_shaders = ('MIX', 'ADD')
-# list of regular shaders. Entry: (identified, type, name for humans). Will be used in SwapShaders and menus.
-# Keeping mixed case to avoid having to translate entries when adding new nodes in SwapNodes.
-regular_shaders = (
-    ('ShaderNodeBsdfTransparent', 'BSDF_TRANSPARENT', 'Transparent BSDF'),
-    ('ShaderNodeBsdfGlossy', 'BSDF_GLOSSY', 'Glossy BSDF'),
-    ('ShaderNodeBsdfGlass', 'BSDF_GLASS', 'Glass BSDF'),
-    ('ShaderNodeBsdfDiffuse', 'BSDF_DIFFUSE', 'Diffuse BSDF'),
-    ('ShaderNodeEmission', 'EMISSION', 'Emission'),
-    ('ShaderNodeBsdfVelvet', 'BSDF_VELVET', 'Velvet BSDF'),
-    ('ShaderNodeBsdfTranslucent', 'BSDF_TRANSLUCENT', 'Translucent BSDF'),
-    ('ShaderNodeAmbientOcclusion', 'AMBIENT_OCCLUSION', 'Ambient Occlusion'),
-    ('ShaderNodeBackground', 'BACKGROUND', 'Background'),
-    ('ShaderNodeBsdfRefraction', 'BSDF_REFRACTION', 'Refraction BSDF'),
-    ('ShaderNodeBsdfAnisotropic', 'BSDF_ANISOTROPIC', 'Anisotropic BSDF'),
-    ('ShaderNodeHoldout', 'HOLDOUT', 'Holdout'),
-    )
-
-
-def get_nodes_links(context):
-    space = context.space_data
-    tree = space.node_tree
-    nodes = tree.nodes
-    links = tree.links
-    active = nodes.active
-    context_active = context.active_node
-    # check if we are working on regular node tree or node group is currently edited.
-    # if group is edited - active node of space_tree is the group
-    # if context.active_node != space active node - it means that the group is being edited.
-    # in such case we set "nodes" to be nodes of this group, "links" to be links of this group
-    # if context.active_node == space.active_node it means that we are not currently editing group
-    is_main_tree = True
-    if active:
-        is_main_tree = context_active == active
-    if not is_main_tree:  # if group is currently edited
-        tree = active.node_tree
-        nodes = tree.nodes
-        links = tree.links
-
-    return nodes, links
-
-
-class NodeToolBase:
-    @classmethod
-    def poll(cls, context):
-        space = context.space_data
-        return space.type == 'NODE_EDITOR' and space.node_tree is not None
-
-
-class MergeNodes(Operator, NodeToolBase):
-    bl_idname = "node.merge_nodes"
-    bl_label = "Merge Nodes"
-    bl_description = "Merge Selected Nodes"
-    bl_options = {'REGISTER', 'UNDO'}
-
-    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(
-            name="merge type",
-            description="Type of Merge to be used",
-            items=(
-                ('AUTO', 'Auto', 'Automatic Output Type Detection'),
-                ('SHADER', 'Shader', 'Merge using ADD or MIX Shader'),
-                ('MIX', 'Mix Node', 'Merge using Mix Nodes'),
-                ('MATH', 'Math Node', 'Merge using Math Nodes'),
-                ),
-            )
-
-    def execute(self, context):
-        tree_type = context.space_data.node_tree.type
-        if tree_type == 'COMPOSITING':
-            node_type = 'CompositorNode'
-        elif tree_type == 'SHADER':
-            node_type = 'ShaderNode'
-        nodes, links = get_nodes_links(context)
-        mode = self.mode
-        merge_type = self.merge_type
-        selected_mix = []  # entry = [index, loc]
-        selected_shader = []  # entry = [index, loc]
-        selected_math = []  # entry = [index, loc]
-
-        for i, node in enumerate(nodes):
-            if node.select and node.outputs:
-                if merge_type == 'AUTO':
-                    for (type, types_list, dst) in (
-                            ('SHADER', merge_shaders, selected_shader),
-                            ('RGBA', [t[0] for t in blend_types], selected_mix),
-                            ('VALUE', [t[0] for t in operations], selected_math),
-                            ):
-                        output_type = node.outputs[0].type
-                        valid_mode = mode in types_list
-                        # When mode is 'MIX' use mix node for both 'RGBA' and 'VALUE' output types.
-                        # Cheat that output type is 'RGBA',
-                        # and that 'MIX' exists in math operations list.
-                        # This way when selected_mix list is analyzed:

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-extensions-cvs mailing list