Handler render init ignores output placeholders #66555

Closed
opened 2019-07-08 14:53:11 +02:00 by Eugenio Pignataro · 19 comments

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

Render_init_placeholder.blend

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 [Render_init_placeholder.blend](https://archive.blender.org/developer/F7575208/Render_init_placeholder.blend)
Author
Member

Added subscriber: @EugenioPignataro

Added subscriber: @EugenioPignataro

Added subscriber: @dr.sybren

Added subscriber: @dr.sybren

I can't reproduce this on either Blender versions ad16af7a7e and 805cabdf17 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.

@EugenioPignataro Can you give us more information on how to reproduce this issue?

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`. @EugenioPignataro Can you give us more information on how to reproduce this issue?
Author
Member

Hi Sybren!

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

THANKS!

2019-07-09 09-42-26.mov

Hi Sybren! I send you more data. 1 video explain better than 1000 writelines. THANKS! [2019-07-09 09-42-26.mov](https://archive.blender.org/developer/F7579052/2019-07-09_09-42-26.mov)

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.

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.
Author
Member

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!

2019-07-09 10-34-12.mov

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! [2019-07-09 10-34-12.mov](https://archive.blender.org/developer/F7579145/2019-07-09_10-34-12.mov)

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.

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.
Author
Member

Okey! :)

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

THANKS!!!

Okey! :) I have not clues about problem. It's strange.... THANKS!!!

Added subscriber: @mont29

Added subscriber: @mont29

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'
Bastien Montagne self-assigned this 2019-07-23 15:41:50 +02:00

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…

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…
Author
Member

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)

**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)

Changed status from 'Archived' to: 'Open'

Changed status from 'Archived' to: 'Open'
Author
Member

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

Hi Sybren! I tested on windows system too, same problem.
Bastien Montagne removed their assignment 2019-08-08 15:49:04 +02:00

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.

#66555-Render_init_placeholder.blend

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) 
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. [#66555-Render_init_placeholder.blend](https://archive.blender.org/developer/F7662065/T66555-Render_init_placeholder.blend) 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) ```
Author
Member

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.

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.

This issue was referenced by f94f4e1d79

This issue was referenced by f94f4e1d79f73e55ac215dd4cccc287c3611f68d

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Sybren A. Stüvel self-assigned this 2019-09-24 16:00:37 +02:00

The empty files were placeholders, which were made with a copy of the render settings (which thus weren't influenced by the change in the handler).

The empty files were placeholders, which were made with a copy of the render settings (which thus weren't influenced by the change in the handler).
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#66555
No description provided.