python custom_pynode_in_cycles_tree.py

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python custom_pynode_in_cycles_tree.py相关的知识,希望对你有一定的参考价值。

# ##### 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()

以上是关于python custom_pynode_in_cycles_tree.py的主要内容,如果未能解决你的问题,请参考以下文章

Python代写,Python作业代写,代写Python,代做Python

Python开发

Python,python,python

Python 介绍

Python学习之认识python

python初识