Addng My Own Property Values To The Notes Render Stamp

Hi all,

I’m trying to add my own property values to the Notes in the Metadata stamp when rendering.

First, I found this answer on Stack Exchange:

and while that script does work, inserting my own properties does not. I’m sure I have the syntax wrong, but trying to figure it out has lead me down the rabbit hole of the Python API and I’m even more confused than when I started.

Here’s the code I run in the Text Editor of Blender 2.78c (I receive no errors when this code runs):

import bpy


def stamp_set(scene):
    note = "| Displace Strength: "  + str(scene.object.modifiers["Displace"].strength)
    note += "| Midlevel: "  + str(scene.object.modifiers["Displace"].mid_level)
    note += "| Stroke Chaining: "  + str(scene.linestyles["LineStyle"].use_chaining)
    note += "| Stroke Type: "  + str(scene.linestyles["LineStyle"].chaining)
    note += "| Same Object: "  + str(scene.linestyles["LineStyle"].use_same_object)
    note += "| Stroke Caps: "  + str(scene.linestyles["LineStyle"].caps)
    note += "| Base Thickness: "  + str(scene.linestyles["LineStyle"].thickness)
    note += "| Along Stroke Blend Mode: "  + str(scene.linestyles["LineStyle"].thickness_modifiers["Along Stroke"].blend)
    note += "| Along Stroke Mapping: "  + str(scene.linestyles["LineStyle"].thickness_modifiers["Along Stroke"].mapping)
    note += "| Along Stroke Influence: "  + str(scene.linestyles["LineStyle"].thickness_modifiers["Along Stroke"].influence)
    note += "| Along Stroke Min Value: "  + str(scene.linestyles["LineStyle"].thickness_modifiers["Along Stroke"].value_min)
    note += "| Along Stroke Max Value: "  + str(scene.linestyles["LineStyle"].thickness_modifiers["Along Stroke"].value_max)
    note += "| Calligraphy Blend Mode: "  + str(scene.linestyles["LineStyle"].thickness_modifiers["Calligraphy"].blend)
    note += "| Calligraphy Influence: "  + str(scene.linestyles["LineStyle"].thickness_modifiers["Calligraphy"].influence)
    note += "| Calligraphy Orientation: "  + str(scene.linestyles["LineStyle"].thickness_modifiers["Calligraphy"].orientation)
    note += "| Calligraphy Min Thickness: "  + str(scene.linestyles["LineStyle"].thickness_modifiers["Calligraphy"].thickness_min)
    note += "| Calligraphy Max Thickness: "  + str(scene.linestyles["LineStyle"].thickness_modifiers["Calligraphy"].thickness_max)
    note += "| Backbone_Length: "  + str(scene.linestyles["LineStyle"].geometry_modifiers["Backbone Stretcher"].backbone_length)
    note += "| 2D Transform Pivot: "  + str(scene.linestyles["LineStyle"].geometry_modifiers["2D Transform"].pivot)
    note += "| 2D Transform Scale X: "  + str(scene.linestyles["LineStyle"].geometry_modifiers["2D Transform"].scale_x)
    note += "| 2D Transform Scale Y: "  + str(scene.linestyles["LineStyle"].geometry_modifiers["2D Transform"].scale_y)
    note += "| 2D Transform Rotation Angle: "  + str(scene.linestyles["LineStyle"].geometry_modifiers["2D Transform"].angle)
    scene.render.stamp_note_text = note


bpy.app.handlers.render_pre.append(stamp_set)

I did discover that using Copy Data Path doesn’t always work, sometimes just inserting the property name and not it’s path. So the paths showing in my code were copied from the Info window and modified just a bit to fall in line with the syntax from the Stack Exchange answer.

The result I get from running this script and then rendering is that none of the above code appears in the Notes field (it is definitely checked on), and only the default properties show in the render stamp.

Can anyone tell me what’s going wrong with my code here?

I have no idea what the hell a notes render stamp is, but I ran across this code today while I was reading about how to add properties.
Whether it will help you or not is beyond me. https://wiki.blender.org/index.php/Dev:Py/Scripts/Cookbook/Code_snippets/Properties#RNA_properties_versus_ID_properties

LOL skywola.

thanks much for providing that link. I appreciate it, and that actually will help me down the line.

regarding the Notes stamp: if you go to your Render tab in the Properties editor, you’ll see a section called “Metadata”.

If you activate the “Stamp Output” checkbox here, when you render your scene, Blender will “stamp” any of the information that’s enabled in the “Enabled Metadata” section below onto your render, using the font and background settings shown there. You can add your own info in the Notes field, but it gets old copying and pasting it each time.

I actually did end up fixing my script myself after some rigorous trial and error.

It turns out if you hover over a property, the tooltip will show the correct property name to type into the string. (I couldn’t figure out how to copy and paste from the tooltip).

Below is my working code. It’s a bit of a brute force, though. For example, I have to have a Displace modifier in there, or it may not continue on to the rest of the code. As I have time I’ll work on it to get it to fail gracefully, but for now anyone looking to do this the code below should work for you (with your own modifications, of course).

import bpy


def stamp_set(scene):
    note = "Displace Strength: "  + str(bpy.data.objects['Cube'].modifiers['Displace'].strength)
    note += "| Midlevel: "  + str(bpy.data.objects['Cube'].modifiers['Displace'].mid_level)
    note += "| Stroke Chaining: "  + str(bpy.data.linestyles['LineStyle'].use_chaining)
    note += "| Stroke Type: "  + str(bpy.data.linestyles['LineStyle'].chaining)
    note += "| Same Object: "  + str(bpy.data.linestyles['LineStyle'].use_same_object)
    note += "| Stroke Caps: "  + str(bpy.data.linestyles['LineStyle'].caps)
    note += "| Base Thickness: "  + str(bpy.data.linestyles['LineStyle'].thickness)
    note += "| Along Stroke Blend Mode: "  + str(bpy.data.linestyles['LineStyle'].thickness_modifiers['Along Stroke'].blend)
    note += "| Along Stroke Mapping: "  + str(bpy.data.linestyles['LineStyle'].thickness_modifiers['Along Stroke'].mapping)
    note += "| Along Stroke Influence: "  + str(bpy.data.linestyles['LineStyle'].thickness_modifiers['Along Stroke'].influence)
    note += "| Along Stroke Min Value: "  + str(bpy.data.linestyles['LineStyle'].thickness_modifiers['Along Stroke'].value_min)
    note += "| Along Stroke Max Value: "  + str(bpy.data.linestyles['LineStyle'].thickness_modifiers['Along Stroke'].value_max)
    note += "| Calligraphy Blend Mode: "  + str(bpy.data.linestyles['LineStyle'].thickness_modifiers['Calligraphy'].blend)
    note += "| Calligraphy Influence: "  + str(bpy.data.linestyles['LineStyle'].thickness_modifiers['Calligraphy'].influence)
    note += "| Calligraphy Orientation: "  + str(bpy.data.linestyles['LineStyle'].thickness_modifiers['Calligraphy'].orientation)
    note += "| Calligraphy Min Thickness: "  + str(bpy.data.linestyles['LineStyle'].thickness_modifiers['Calligraphy'].thickness_min)
    note += "| Calligraphy Max Thickness: "  + str(bpy.data.linestyles['LineStyle'].thickness_modifiers['Calligraphy'].thickness_max)
    note += "| Backbone_Length: "  + str(bpy.data.linestyles['LineStyle'].geometry_modifiers['Backbone Stretcher'].backbone_length)
    note += " | 2D transform scalex: "  + str(bpy.data.linestyles['LineStyle'].geometry_modifiers['2D Transform'].scale_x)


    scene.render.stamp_note_text = note


bpy.app.handlers.render_pre.append(stamp_set)

Cool. That brute force routine seems to be the norm for me quite often when I cannot find
any examples of how to do things and when the documentation does not quite cover it! Glad
I was able to help . . .

Bumping this to see if @jgstyle or anyone has been able to solve this. I’m trying to visualize some geometry principles and export the camera angle and result of some some formulas in a video so team members can preview settings by scrubbing the video, then reporting back the properties. Would love to add new metadata fields, but notes field would work too.

I’m an experienced coder, but novice at the Blender API.

I have not tried this approach, I don’t know if there are any sort of difficulties or limitations with it.

What I consider a far better approach is to use a text object that is parented to camera and can play the role of becoming a real-world UI layer.

If you have some sort of text object in the scene you can write to it like this:

import bpy

class Console:
    def text_object():
        return bpy.context.scene.objects['Text'].data
    
    def set_text(txt):
        Console.text_object().body = txt

    def clear():
        Console.text_object().body = ''
        
    def print(txt):
        Console.text_object().body += txt

Console.clear()
Console.print('Hello\n')
Console.print('World\n')

import time
Console.print(time.ctime())