Page MenuHome

Handler render init ignores output placeholders
Open, Confirmed, MediumPublic

Description

Linux Ubuntu 19.04

Blender hash b'ad16af7a7e35' 2.8
Worked, some versions of 2.8

The script is for solve render output tokens.
In the scene you can find the script.

1 - run script
2 - run ctrl F12.

You will find renders in RENDER folder.
The placeholder name is not the same as render. ($File_001.png vs scenename_001png)

THANKS!

http://pasteall.org/blend/index.php?id=52021 << pasteall alternative

Details

Type
Bug

Event Timeline

Sybren A. Stüvel (sybren) triaged this task as Needs Information from User priority.

I can't reproduce this on either Blender versions ad16af7a7e350a2164204b8af50ff00836d65386 and 805cabdf177af6c71da6239ff3fc5d2524286a18 running Kubuntu Linux 18.04 LTS.

For me it renders to /home/sybren/workspace/blender-git/blender/RENDERS/Render_init_placeholder_0074.png, which is what I would expect given the output //RENDERS/$File_. It correctly replaced the $File placeholder with Render_init_placeholder.

@Eugenio Pignataro (oscurart) Can you give us more information on how to reproduce this issue?

Hi Sybren!

I send you more data.
1 video explain better than 1000 writelines.

THANKS!

If Blender is outputting multiple files, you must have something else going on than just a plain render to PNG. Please restart Blender to ensure you don't have any lingering persistent Python handlers. Then reset Blender to factory defaults (you can do this temporarily through File → Defaults → Load Factory Settings), run your script, and try again.

In the video your script also calls layer.update_render_passes(), which isn't in the blend file you attached. I don't see why that and the layer.update() calls would be necessary anyway.

Hi Sybren. Thanks for your help!

I erased the config for more security.

You're right, layer.update_render_passes() is not necessary. I wrote only for try it.

Tell me if you need something more.

THANKS!

Please don't attach huge videos, but just describe it. A few well-chosen words are much easier to digest for us developers than having to watch a video.

Okey! :)

I have not clues about problem. It's strange....

THANKS!!!

Bastien Montagne (mont29) closed this task as Archived.
Bastien Montagne (mont29) claimed this task.

More than a week without reply or activity. Due to the policy of the tracker archiving for until required info/data are provided.

Looks like we cannot reproduce the issue here…

System Information
Operating system: Ubuntu 18.10
Graphics card: GeForce GTX 1070 Ti

Blender Version
Broken: version: 2.81 hash: b'3e27dd5b553e'
Worked: it worked well in one of the first versions of the experimental 2.8.
I can't specify the moment, but it worked.

Short description of error
The handler correctly modifies the render path, but blender does not modify the placeholder.
It is important that the placeholder have the same name as the file.

Exact steps for others to reproduce the error
1- Download this .blend http://pasteall.org/blend/index.php?id=52021
2- Run script. (the script replace variables in render filepath when you hit render)
3- Hit ctrlF12
4- Go to the .blend folder and find "RENDER" folder.
5- You must see "$File_0001.png" and "Render_init_placeholder_0001.png"

The correct way for placeholder should be "Render_init_placeholder_0001.png" too.

I'm working in a tool like this (https://knowledge.autodesk.com/support/maya/learn-explore/caas/CloudHelp/cloudhelp/2018/ENU/Maya-Rendering/files/GUID-F6C6AE73-F484-4534-B992-2E599D4AE91E-htm.html)

Sybren A. Stüvel (sybren) raised the priority of this task from Needs Information from User to Waiting for Developer to Reproduce.

Hi Sybren!
I tested on windows system too, same problem.

Sybren A. Stüvel (sybren) lowered the priority of this task from Waiting for Developer to Reproduce to Confirmed, Medium.EditedTue, Aug 13, 2:23 PM

I can confirm the issue. Here is a modified blend file with a bit cleaner logic in the script:

  • Only code for the one variable that's actually used ('$File')
  • Declaring initial value for the global variable
  • Using the scene passed to the function, rather than the global bpy.context.scene
  • Some more debug prints to show when the original output filepath is restored.
  • Using pathlib to manipulate paths.
  • Configured the scene to render 3 frames at 1 sample.

The script:

import bpy
import pathlib
from bpy.app.handlers import persistent

orig_filepath = ''

@persistent
def replace_tokens(scene):
    global orig_filepath

    if not orig_filepath:
        orig_filepath = scene.render.filepath
    
    filename = pathlib.Path(bpy.data.filepath).stem
    scene.render.filepath = orig_filepath.replace('$File', filename)

    print(f'New filepath: {scene.render.filepath}')


@persistent
def restore_tokens(scene):
    global orig_filepath

    if not orig_filepath:
        print('Not restoring empty filepath')
        return

    print(f'Restoring filepath: {orig_filepath}')
    scene.render.filepath = orig_filepath
    orig_filepath = ''


bpy.app.handlers.render_init.append(replace_tokens)
bpy.app.handlers.render_cancel.append(restore_tokens) 
bpy.app.handlers.render_complete.append(restore_tokens)

Excellent!
Perhaps this option is so easy to implement that it can be included as native functionality.
With this addon I add small ideas that are very useful in production.

THOUSAND THANKS.