15
$\begingroup$

I'd like to have a node like the Frame node but one that can have lots of text, not just a header. I've looked and it looks like there isn't any such capability so far, so I was wondering how easy it would be for someone to create a custom Comment node as an add-on or script (I don't know the differences between the two). I myself would love to leave detailed comments in complex node trees so that I can figure out what I was doing/what to do when I come back to them months later.

$\endgroup$
20
$\begingroup$

Since version 2.74, blender has has the ability to display text blocks in the node editor.
See the manual.

screenshot

Add a frame node, then in the properties region add the text block you want to display. (A text block is simply a file made in blender's text editor.)
frame node properties
The frame will display the text exactly as it is in the text editor without word wrapping, you have to add the line brakes in manually (by pressing Enter at the end of the line).
This is the easiest way to make notations in the node editor.

$\endgroup$
8
$\begingroup$

Alternatively, if you want something quick and easy ..enter image description here

$\endgroup$
  • $\begingroup$ I'm sorry. I didn't mean it to be snippity, and I'm sorry if I have offended you in any way.. The grease pencil is a good idea, I personally just can't imagine writing with a mouse (maybe it's just me). $\endgroup$ – gandalf3 Mar 17 '14 at 18:59
  • 3
    $\begingroup$ Well, really all art on a computer is difficult with a mouse. It wasn't until I got a pen tablet that I stopped suffering from claw hand after a couple of hours of work. Now I can go all day, every day without destroying my hand. Combine that with pressure sensitivity and the extra price is well worth the extra money. Sorry for the 'Fake Gandalf' comment. Name calling is totally inappropriate under any circumstances. $\endgroup$ – MarcClintDion Mar 17 '14 at 19:12
5
$\begingroup$

There's no support for text wrapping in Blender, so it's impossible to have a multi-line label or StringProperty. But it's possible to have a collection of strings and draw them in a column inside of a custom node:

Comment Node Addon

bl_info = {
    "name": "Comment Node",
    "author": "CoDEmanX",
    "version": (1, 0),
    "blender": (2, 67, 0),
    "location": "Node Editor > Add > Other Nodes > Comment",
    "description": "Add a node comment node (string property collection)",
    "warning": "",
    "wiki_url": "",
    "category": "Node"}

import bpy
from bpy.types import Node, Operator
from bpy.props import BoolProperty, IntProperty, CollectionProperty

class NodeComment(Operator):
    bl_idname = "node.comment"
    bl_label = "Node Comment"

    index = IntProperty(default=-1)

    @classmethod
    def poll(cls, context):
        return (context.area.type == 'NODE_EDITOR' and
                context.area.spaces[0].node_tree.nodes.active is not None and
                context.area.spaces[0].node_tree.nodes.active.bl_idname == CommentNode.bl_idname)

    def execute(self, context):
        node = context.area.spaces[0].node_tree.nodes.active
        if self.index == -1:
            node.myCollProperty.add()
            node.myBoolProperty = True
        else:
            try:
                node.myCollProperty.remove(self.index)
            except IndexError:
                print("Invalid collection index")
                return {'CANCELLED'}
        return {'FINISHED'}

# Derived from the Node base type.
class CommentNode(Node):
    # === Basics ===
    # Description string
    '''A comment node'''
    # Optional identifier string. If not explicitly defined, the python class name is used.
    bl_idname = 'CommentNodeType'
    # Label for nice name display
    bl_label = 'Comment Node'
    # Icon identifier
    bl_icon = 'GREASEPENCIL'

    myBoolProperty = bpy.props.BoolProperty(name="Edit")
    myCollProperty = bpy.props.CollectionProperty(type=bpy.types.PropertyGroup)

    def init(self, context):
        self.width = 300

    # Copy function to initialize a copied node from an existing one.
    def copy(self, node):
        print("Copying from node ", node)

    # Free function to clean up on removal.
    def free(self):
        print("Removing node ", self, ", Goodbye!")

    # Additional buttons displayed on the node.
    def draw_buttons(self, context, layout):
        #layout.label("Node settings")

        row = layout.row(True)
        row.operator(NodeComment.bl_idname, text="Add", icon="ZOOMIN").index = -1
        row.prop(self, "myBoolProperty", text="", icon="GREASEPENCIL")

        col = layout.column(True)

        if self.myBoolProperty:
            for i, line in enumerate(self.myCollProperty):
                row = col.row(True)
                row.prop(line, "name", text="")
                row.operator(NodeComment.bl_idname, text="", icon="ZOOMOUT").index = i
        else:
            for line in self.myCollProperty:
                col.label(line.name)

import nodeitems_utils
from nodeitems_utils import NodeCategory, NodeItem

# our own base class with an appropriate poll function,
# so the categories only show up in our own tree type
class MyNodeCategory(NodeCategory):
    pass

# all categories in a list
node_categories = [
    # identifier, label, items list
    MyNodeCategory("OTHERNODES", "Other Nodes", items=[
        NodeItem(CommentNode.bl_idname, label="Comment"),
        ]),
    ]


def register():
    bpy.utils.register_class(NodeComment)
    bpy.utils.register_class(CommentNode)

    try:
        nodeitems_utils.register_node_categories("CUSTOM_NODES", node_categories)
    except:
        pass


def unregister():
    nodeitems_utils.unregister_node_categories("CUSTOM_NODES")

    bpy.utils.register_class(NodeComment)
    bpy.utils.register_class(CommentNode)


if __name__ == "__main__":
    register()
$\endgroup$
  • $\begingroup$ Thanks, that looks like the best viable solution since there's no other real comment node, but I don't know anything about coding for blender, so how would I implement this? $\endgroup$ – Thom Blair III Mar 17 '14 at 12:02
  • 1
    $\begingroup$ Not sure what you mean, you can install above code as addon and use the comment node (I hope!). Haven't tested it in-depth, so better check before production if it's kept in .blend on save while addon is disabled. $\endgroup$ – CoDEmanX Mar 17 '14 at 12:36
  • $\begingroup$ Thom Blair, save the code above as a .py file and place it in the Blender\2.69\scripts\addons\ directory. Then in Blender you can go to user preferences>addons and you should be able to find it and enable it by checking the check mark. Then it should work in Blender. $\endgroup$ – cybrbeast Mar 17 '14 at 12:49
  • $\begingroup$ Thanks! That worked great! Thankfully someone had just mentioned how to install a script to me, so I'm just listing the steps below for anyone else: (1) open the Text Editor window (2) click the New Text button (3) paste in the code (4) click the Run Script button (5) then CTRL + U to save the startup file $\endgroup$ – Thom Blair III Mar 17 '14 at 12:55
4
$\begingroup$

There is an addon that can make it possible adding Note Nodes.

It is stated everything needed on the BlenderArtists page where addon was posted, I will make short summary here to not make this answer link-only.

Functionality. You can create the node from a panel (which opens with N) in the node editor called Note. Either an empty node or from clipboard.

A note can either be linked to a blender text buffer or store text. If text is stored a linked file is ignored. You access settings of the node from the properties of the node (press N to open).

(Italic is mine).

What it looks like:

enter image description here

image from BA post


Download

Documentation

$\endgroup$
  • $\begingroup$ Also please note that only people with this addon can read your note as is stated on documentation page $\endgroup$ – Mr Zak Jun 22 '15 at 19:02

protected by Community Dec 27 '17 at 21:19

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.