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?