jeinselen/VF-BlenderAutosaveRender

Doesnt seem to be working -3.6.2

Closed this issue · 12 comments

Hello,

I have installed the addon, followed all of the instructions and read the documentation. It loads up fine but does not seem to be able to read the tokens at all. I end up with {project}_{camera}_0001.png in a folder named {project} for example.

Am i doing something really stupid, or does the addon not work on newer versions of Blender?

Hello @stedalton!

I haven't experienced any issues in Blender 3.6.x (I'm currently using 3.6.4), but some questions may clarify the situation and help track down an answer:

  1. What version of the plugin are you using?
  2. Are render variables enabled in the plugin preferences? (depending on the version, this might be two checkboxes or one...they should be checked by default, and I'm sure this isn't the issue, but just to make sure they weren't accidentally unchecked!)
  3. Are you using relative or absolute paths in your render output?
  4. What operating system are you running?
  5. Are there any errors that pop up in the Blender interface? (doesn't sound like it?)
  6. Can you open a system terminal window to see if there are any errors printed there?

In MacOS (and maybe Linux) you will have to open Blender via the Terminal before testing in order to see printed outputs (on my system I use /Applications/Blender.app/Contents/MacOS/Blender to open it from the Terminal app). I think Windows lets you open the system terminal from the Window menu in Blender after it's already open.

Hi @jeinselenVF

thanks very much for your fast reply. In answer to your questions:

What version of the plugin are you using?
I'm using version 2.7.2. I saved the .py from git hub

Are render variables enabled in the plugin preferences
Yep, the Render Variables box is ticked

Are you using relative or absolute paths in your render output?
My path is - //Renders/{project}/{project}####_

What operating system are you running
Windows 11

Are there any errors that pop up in the Blender interface?
nope, no errors. It renders just fine, it just doesnt apply the tokens in the way it should

Can you open a system terminal window to see if there are any errors printed there?
No errors for this Addon showing in the terminal.

Thanks again for taking the time to reply.

Ste

Thanks for checking everything @stedalton! I really appreciate it, especially since I can't replicate the issue yet. One question and two more steps we can try to narrow things down a little more:

  1. Have you successfully used this plugin (of any version) in previous versions of Blender before?
  2. Are you able to uninstall the plugin and install version 2.0.9 from the releases list https://github.com/jeinselenVF/VF-BlenderAutosaveRender/releases and test that? (may help figure out if this is a recent regression in the plugin or something with how Python is handled in Windows 11 + Blender 3.6)
  3. Are you able to temporarily change your Blender settings folder in Windows and start up Blender with a fresh install? (should indicate if there's another plugin installed that's conflicting in some way...seems doubtful, but maybe?)

Temporarily swapping settings is pretty easy in MacOS, just rename the 3.6 folder in the user's ~/Library/Application Support/Blender/ directory to something else, start up Blender and install only the one plugin, and when you're done testing, just delete the newly generated folder and set the original name back to 3.6...but I don't know how this is handled in Windows.

It's weird not just because I can't replicate the issue yet (it may be exclusive to Windows?), but also because I'm not certain what changes might have triggered issues for only some machines, all without throwing an error message of any kind.

Thanks again for your help, I'd definitely like to find out why it's not working for you.
John

hi again @jeinselenVF

answers below -

  1. No i haven't ever used the plugin before.
  2. Yep just did that
  3. Yep, did that too

unfortunately the same thing is happening. this is what my test output is - 'E:\test\variable_test\Renders{project}{camera}_0001.png'

I wonder if it might be an issue with python on my PC, as i used chatGTP to write a python script to use render token variables in blender and had the same issue. It seems like its just not interpreting the { } 's I'm not sure at all how i'd debug this though as i have zero python scripting knowledge

cheers

Ste

@jeinselenVF

update on this, I managed to get this script to run and the tokens seemed to create and labels folders and frames correctly:

import bpy
import os

Get the current blend file name (without extension)

current_file_name = os.path.splitext(os.path.basename(bpy.data.filepath))[0]

Set the base output path with render tokens

output_path = f"//renders/{current_file_name}render###.png"
bpy.context.scene.render.image_settings.file_format = 'PNG'

Set the frame range for the animation

bpy.context.scene.frame_start = 1
bpy.context.scene.frame_end = 50 # Adjust this to your desired frame range

Loop through the frames and render each one

for frame in range(bpy.context.scene.frame_start, bpy.context.scene.frame_end + 1):
# Set the current frame
bpy.context.scene.frame_set(frame)

# Get the frame number
frame_number = str(frame).zfill(3)

# Replace the render tokens with actual values
render_path = output_path.replace("###", frame_number)

# Set the render file path
bpy.context.scene.render.filepath = render_path

# Render the frame
bpy.ops.render.render(write_still=True)

Interestingly, when i ran it, it created 2 folders and file sequences simultaneously, 1 with the name in the script and one with the name in your addon. I had to remove the addon to make it only create the folder and file structure in the script above.

hope this helps

Thanks for checking! And I'm glad you have something simple working.

If you're ok continuing to help figure out why the plugin isn't working on your system, I've created a debugging version that prints messages to the terminal during the pre-render stage (where the output path is modified) and the variable replacement function (where the string patterns are replaced with Blender data). I think these are the two sections that are most likely failing. I already checked with a coworker, and they're using 2.7.2 without issues...but they're still on Windows 10.

Testing process I followed:

  1. Fresh Blender install (as described earlier)
  2. Install Autosave Render & Output Variables (debugging) VF_autosaveRender.py.zip (I made no changes to the default settings outside of turning on the plugin after installation)
  3. Save untitled.blend test file with 3-frame animation with //Renders/{project}-{camera}-#### output path
  4. Quit Blender
  5. Start Blender from the Terminal (in your case, opening the terminal display immediately after opening Blender)
  6. Open test file
  7. Render animation
  8. Quit Blender

If you can use the same test file, that should help ensure project parity: untitled.blend.zip

Screenshot 2023-10-03 at 4 13 15 PM

On my machine, this successfully rendered the expected three frames along with auto-saving the final rendered frame with the default jpg settings.

Screenshot 2023-10-03 at 4 13 26 PM

And below is the Terminal output from my machine during the test. There may be some variations in how things are printed in Windows, but it should be largely the same. Could you share the entire terminal output from your machine? Including any Blender boot-up messages? (after removing any personal information)

Read prefs: "~/Library/Application Support/Blender/3.6/config/userpref.blend"
2023-10-03 16:10:02.878 Blender[24701:530230] apply_selection_policy_once: prefer use of removable GPUs (via org.blenderfoundation.blender:GPUSelectionPolicy->preferRemovable)
Device with name AMD Radeon Pro 5600M supports metal minimum requirements
METAL API - DETECTED GPU: AMD Radeon Pro 5600M
Read blend: "~/Desktop/untitled.blend"
2023-10-03 16:10:22.059 Blender[24701:530230] WARNING: Secure coding is not enabled for restorable state! Enable secure coding by implementing NSApplicationDelegate.applicationSupportsSecureRestorableState: and returning YES.
DEF: autosave_render_start
autosave_render_start path before variable replacement: //Renders/{project}-{camera}-####
autosave_render_start: render output variables is enabled
autosave_render_start: send output path to replaceVariables
DEF: replaceVariables
replaceVariables path input = //Renders/{project}-{camera}-####
replaceVariables render time input = -1.0
replaceVariables serial number input = -1
replaceVariables: Blender Eevee render values set
replaceVariables renderEngine = Eevee
replaceVariables renderDevice = GPU
replaceVariables renderSamples = 64+7+64
replaceVariables renderFeatures = None
replaceVariables projectItem = Cube
replaceVariables projectMaterial = Material
replaceVariables projectNode = Principled BSDF
replaceVariables path before replacement = //Renders/{project}-{camera}-####
replaceVariables path {project} = //Renders/untitled-{camera}-####
replaceVariables path {camera} = //Renders/untitled-Camera-####
replaceVariables path output after replacement = //Renders/untitled-Camera-####
autosave_render_start: receive output path from replaceVariables
autosave_render_start path after variable replacement: //Renders/untitled-Camera-####
Saved: '~/Desktop/Renders/untitled-Camera-0000.png'
 Time: 00:01.79 (Saving: 00:00.17)

DEF: autosave_render_estimate
Saved: '~/Desktop/Renders/untitled-Camera-0001.png'
 Time: 00:00.27 (Saving: 00:00.15)

DEF: autosave_render_estimate
Saved: '~/Desktop/Renders/untitled-Camera-0002.png'
 Time: 00:00.27 (Saving: 00:00.14)

DEF: autosave_render_estimate
DEF: autosave_render
DEF: replaceVariables
replaceVariables path input = ~/Desktop/untitled
replaceVariables render time input = 2.42
replaceVariables serial number input = -1
replaceVariables: Blender Eevee render values set
replaceVariables renderEngine = Eevee
replaceVariables renderDevice = GPU
replaceVariables renderSamples = 64+7+64
replaceVariables renderFeatures = None
replaceVariables projectItem = Cube
replaceVariables projectMaterial = Material
replaceVariables projectNode = Principled BSDF
replaceVariables path before replacement = ~/Desktop/untitled
replaceVariables path {project} = ~/Desktop/untitled
replaceVariables path {camera} = ~/Desktop/untitled
replaceVariables path output after replacement = ~/Desktop/untitled
DEF: replaceVariables
replaceVariables path input = {project}-0000
replaceVariables render time input = 2.42
replaceVariables serial number input = -1
replaceVariables: Blender Eevee render values set
replaceVariables renderEngine = Eevee
replaceVariables renderDevice = GPU
replaceVariables renderSamples = 64+7+64
replaceVariables renderFeatures = None
replaceVariables projectItem = Cube
replaceVariables projectMaterial = Material
replaceVariables projectNode = Principled BSDF
replaceVariables path before replacement = {project}-0000
replaceVariables path {project} = untitled-0000
replaceVariables path {camera} = untitled-0000
replaceVariables path output after replacement = untitled-0000
Info: Saved "untitled.blend"

Saved session recovery to "/var/folders/wg/26qdxl5d6sv7f8r7r1yzyf0sjw8txq/T/quit.blend"

Blender quit

Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.
Deleting expired sessions...none found.

[Process completed]

Hi @jeinselenVF

thanks for sending across all the info and test scene. I tested it out just now and it worked - i got 3 frames named 'untitled-Camera-0000-0002, which is great!

I have attached the Terminal output for the whole process, hope it helps! Let me know how you get on, I'm happy to run more tests if you need.

Cheers

Ste
Blender_Terminal_Output.txt

also, this test was run on Blender 3.5, i have not yet tested it on 3.6

Thank you @stedalton! Looks like the terminal output is exactly as expected, so that's great.

If you run into any issues in Blender 3.6, would you mind trying out the debugging version of the plugin?

I'm wondering if there could be anything in your project file that might be causing issues, such as an unrecognised character in the output path. For example, if Windows automatically replaces curly brackets with a special character when editing a text field, the plugin wouldn't be able to recognise the variables. MacOS does this with "smart quotes" and I always have to turn it off. Drives me nuts.

Hi @jeinselenVF

I've worked out what the issue is....I have been trying to use the addon to render the viewport animation sequence (equivalent of a playblast in Maya) rather than rendering using cycles or eevee. That is where it breaks. If i render properly its fine, but with the viewport render i get the incorrect file naming.
Do you think there is a way to get it working with viewport renders? Having moved over from Maya i find it very odd that Blender uses the same output path for viewport and 'final' renders.

Thanks again for all your help, I'm very happy to have the addon working now, it's really useful.

cheers

Ste

Thank you @stedalton!

This is a known limitation of the API. Blender only triggers pre-render and post-render events when performing a final render, never a viewport render. Any plugin that needs to process data before or after rendering can only work with the final render system.

Longer explanation: output variables have to be processed before rendering begins so that Blender can reference the revised output path when saving a frame, and the plugin restores the original variable names after rendering completes so they can be replaced with fresh variables the next time a render is started. So even without the auto-saving and other features, output variables rely on both pre-render and post-render events, neither of which occur when Blender saves images or animations from the viewport.

There are two workarounds documented in issue #7:

  1. Custom script (manually trigger autosave_render_start and autosave_render_end before and after a viewport render)
  2. Use Proxy Render (shortcut to temporarily switch the final render settings to output a Workbench render, much like a viewport render but using the render settings instead)

Option 2 is limited to the current camera and (with multi-sampling antialiasing and other options) may be slower than option 1, but it's what I personally use in my animation productions.

From what I can tell, the Blender Python API does not support threading; starting an animation from a Python script will freeze the Blender interface while it waits for the render to complete. Not always a significant limitation when dealing with Workbench/OpenGL renders (depending on the scene, mesh processing could take longer than the actual rendering and it doesn't take too long), but it is certainly frustrating. Which is why I haven't added an implementation of option 1 into this plugin directly; it's a bad user experience. But maybe that's something I need to consider...along with submitting a feature request to the Blender dev team regarding render events when saving the viewport!

For now I'll add a note to the documentation about viewport rendering — I didn't anticipate this being such a common issue (I've always used the proxy rendering setup), and you're the second person to report a bug because of this Blender limitation!

Closing: duplicate