Skip to content

Instantly share code, notes, and snippets.

@zeffii
Created August 8, 2015 18:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeffii/7355f338f9a125d0d5e8 to your computer and use it in GitHub Desktop.
Save zeffii/7355f338f9a125d0d5e8 to your computer and use it in GitHub Desktop.
# ##### 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 #####
# Author Dealga McArdle
# yanked some boilerplate written by Linus Yng for 'generic note node'
# pep8
bl_info = {
"name": "",
"description": "",
"author": "",
"version": (0, 0, 1),
"blender": (2, 7, 4),
"location": "Node Editor, N-Panel",
"category": "Node",
"warning": "The node will not work for people without this addon",
"wiki-url": "",
}
import importlib
import bpy
import nodeitems_builtins
from bpy.types import NodeTree, Node
import nodeitems_utils
from nodeitems_utils import NodeCategory, NodeItem
from nodeitems_builtins import ShaderNewNodeCategory
from bpy.props import BoolProperty, FloatProperty
class PieCustomTree(NodeTree):
bl_idname = 'PieCustomTreeType'
bl_label = 'Pie Node Tree'
# bl_icon = 'SOUND'
# our own base class with an appropriate poll function,
# so the categories only show up in our own tree type
class MyNodeCategory(NodeCategory):
@classmethod
def poll(cls, context):
try:
return context.space_data.tree_type == 'ShaderNodeTree'
except:
return False
class PieCustomTreeNode:
@classmethod
def poll(self, node_tree):
try:
return node_tree.bl_idname == 'ShaderNodeTree'
except:
return False
class PieSetupNode(Node, PieCustomTreeNode):
bl_idname = 'PieSetupNode'
bl_label = 'Pie Setup Node'
bl_icon = 'OUTLINER_OB_EMPTY'
@classmethod
def poll(cls, ntree):
return True
def updateNode(self, context):
scn = bpy.context.scene
...
# do via exec?
bx = FloatProperty(min=0.0, options={'ANIMATABLE'}, update=updateNode)
by = FloatProperty(min=0.0, options={'ANIMATABLE'}, update=updateNode)
bw = FloatProperty(min=0.0, options={'ANIMATABLE'}, update=updateNode)
bh = FloatProperty(min=0.0, options={'ANIMATABLE'}, update=updateNode)
def draw_buttons(self, context, layout):
col = layout.column(align=True)
node_categories = [
MyNodeCategory(
"CUSTOMNODEXAMPLE", "Some custom Nodes",
items=[NodeItem("PieSetupNode", label=PieSetupNode.bl_label)]
)
]
def register():
bpy.utils.register_module(__name__)
nodeitems_utils.register_node_categories("PIECUSTOM_NODES", node_categories)
def unregister():
nodeitems_utils.unregister_node_categories("PIECUSTOM_NODES")
bpy.utils.unregister_module(__name__)
if __name__ == "__main__":
register()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment