relative_remap in bpy.data.libraries.write() no longer working #77768

Closed
opened 2020-06-11 17:39:22 +02:00 by MACHIN3 · 26 comments

System Information
Operating system: Linux-4.15.0-101-generic-x86_64-with-debian-buster-sid 64 Bits
Graphics card: GeForce GTX 1050/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 435.21

Blender Version
Broken: version: 2.83.0, branch: master, commit date: 2020-06-03 14:38, hash: 211b6c29f7
Worked: 2.82a

Short description of error
I have a blend file with an object and material using an image texture //textures/color.png.

I have a script, that moves the image from its initial location to a target location. The script then updates the img.filepath according to the new location, and finally saves the scene(object, material and image) to that same location.
This is done using bpy.data.libraries.write(). So, I end up with a blend file and the color.png in the same target location.
I'm passing relative_remap=True to write(), and so expect the image texture path to be //color.png in the saved blend file.

This worked perfectly in the past, even before 2.80.
As of 2.83 it no longer works and the blend is stored with an absolute image path, despite relative_remap being True.

relative_remap.jpg

relative_remap.zip

Exact steps for others to reproduce the error

  • extract the zip and open relative_remap.blend in Blender 2.83
  • in the scripting workspace run the script, which copies the image to //my/folder/ and saves the scene to the same location
  • close blender without saving, open the same blend file in Blender 2.82a and run the script again
  • go to the //my/folder/ location and compare the image paths in the two blend files
  • in 2.82.7.blend the path should be //color.png
  • whereas in 2.83.0 it should be an absolute path
**System Information** Operating system: Linux-4.15.0-101-generic-x86_64-with-debian-buster-sid 64 Bits Graphics card: GeForce GTX 1050/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 435.21 **Blender Version** Broken: version: 2.83.0, branch: master, commit date: 2020-06-03 14:38, hash: `211b6c29f7` Worked: 2.82a **Short description of error** I have a blend file with an object and material using an image texture `//textures/color.png`. I have a script, that moves the image from its initial location to a target location. The script then updates the img.filepath according to the new location, and finally saves the scene(object, material and image) to that same location. This is done using `bpy.data.libraries.write()`. So, I end up with a blend file and the `color.png` in the same target location. I'm passing `relative_remap=True` to `write()`, and so expect the image texture path to be `//color.png` in the saved blend file. This worked perfectly in the past, even before 2.80. As of 2.83 it no longer works and the blend is stored with an absolute image path, despite relative_remap being True. ![relative_remap.jpg](https://archive.blender.org/developer/F8608684/relative_remap.jpg) [relative_remap.zip](https://archive.blender.org/developer/F8608646/relative_remap.zip) **Exact steps for others to reproduce the error** * extract the zip and open `relative_remap.blend` in Blender 2.83 * in the scripting workspace run the script, which copies the image to //my/folder/ and saves the scene to the same location * close blender without saving, open the same blend file in Blender 2.82a and run the script again * go to the //my/folder/ location and compare the image paths in the two blend files * in 2.82.7.blend the path should be `//color.png` * whereas in 2.83.0 it should be an absolute path
Author

Added subscriber: @MACHIN3

Added subscriber: @MACHIN3

Added subscriber: @ostapblender

Added subscriber: @ostapblender

Yeah, I see the same

image.png

image.png

Yeah, I see the same ![image.png](https://archive.blender.org/developer/F8608796/image.png) ![image.png](https://archive.blender.org/developer/F8608798/image.png)

Added subscriber: @bigbadcat3d

Added subscriber: @bigbadcat3d

Confirming
2020-06-12_10-09-20.png

2020-06-12_10-08-57.png

Confirming ![2020-06-12_10-09-20.png](https://archive.blender.org/developer/F8610469/2020-06-12_10-09-20.png) ![2020-06-12_10-08-57.png](https://archive.blender.org/developer/F8610468/2020-06-12_10-08-57.png)

Added subscriber: @Carlosan

Added subscriber: @Carlosan

+1

+1
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Member

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'
Member

Confirmed, checking...

Confirmed, checking...

Added subscriber: @ManuH

Added subscriber: @ManuH
Member

Caused by f7386b9757

So (if I read #62612 (Saving with "Remap Relative" makes ALL paths relative) correctly) this is now intended behavior.
Afaict, only relative paths now get remapped, absolute paths stay untouched.

Caused by f7386b9757 So (if I read #62612 (Saving with "Remap Relative" makes ALL paths relative) correctly) this is now intended behavior. Afaict, only relative paths now get remapped, absolute paths stay untouched.
Author

Thanks for the info!

Thanks for the info!
Member

Changed status from 'Confirmed' to: 'Archived'

Changed status from 'Confirmed' to: 'Archived'
Philipp Oeser self-assigned this 2020-06-16 17:32:50 +02:00
Member

So, since this was a conscious decision in f7386b9757 and I assume there are ways to adapt your scripts, I think we need to close this?
(feel free though to comment again if issues persist)

So, since this was a conscious decision in f7386b9757 and I assume there are ways to adapt your scripts, I think we need to close this? (feel free though to comment again if issues persist)
Author

It's a bit cumbersome to first collect all images in the scene that is to be saved, then change the paths, then save out the scene, then change the paths back to what they were before (absolute).
So I really liked the way it worked before and wish there was an option that would restore that behavior. It was a lot simpler and just worked.

It's a bit cumbersome to first collect all images in the scene that is to be saved, then change the paths, then save out the scene, then change the paths back to what they were before (absolute). So I really liked the way it worked before and wish there was an option that would restore that behavior. It was a lot simpler and just worked.
Member

Added subscribers: @ideasman42, @dr.sybren

Added subscribers: @ideasman42, @dr.sybren
Member

In #77768#955092, @MACHIN3 wrote:
It's a bit cumbersome to first collect all images in the scene that is to be saved, then change the paths, then save out the scene, then change the paths back to what they were before (absolute).
So I really liked the way it worked before and wish there was an option that would restore that behavior. It was a lot simpler and just worked.

@ideasman42, @dr.sybren ^^

@MACHIN3 : not sure if bpy.ops.file.make_paths_relative / bpy.ops.file.make_paths_absolute help in your workflow?

> In #77768#955092, @MACHIN3 wrote: > It's a bit cumbersome to first collect all images in the scene that is to be saved, then change the paths, then save out the scene, then change the paths back to what they were before (absolute). > So I really liked the way it worked before and wish there was an option that would restore that behavior. It was a lot simpler and just worked. @ideasman42, @dr.sybren ^^ @MACHIN3 : not sure if `bpy.ops.file.make_paths_relative` / `bpy.ops.file.make_paths_absolute` help in your workflow?
Author

Thing is I only export some images in the file, theses ops would make all paths relative/absolute, which is overkill, as I can easily have hundreds of images, but save out only a handful.

Thing is I only export some images in the file, theses ops would make all paths relative/absolute, which is overkill, as I can easily have hundreds of images, but save out only a handful.

Added subscriber: @dfelinto

Added subscriber: @dfelinto

@ideasman42 just wondering if f7386b9757 was really the way to go. Because it changed the behaviour that dated back to 2.5 (alpha2) I believe. I'm yet to dig the original commit, but maybe we should just accept that the implemented behaviour was the expected, even though the tooltip never really reflected that.

@ideasman42 just wondering if f7386b97571 was really the way to go. Because it changed the behaviour that dated back to 2.5 (alpha2) I believe. I'm yet to dig the original commit, but maybe we should just accept that the implemented behaviour was the expected, even though the tooltip never really reflected that.

@dfelinto think we could make it an option to make all paths relative, or only make relative paths relative - since it seems both as useful.

I'm not so keen on adding back old behavior by default since it means you can't use absolute paths.

@dfelinto think we could make it an option to make all paths relative, or only make relative paths relative - since it seems both as useful. I'm not so keen on adding back old behavior by default since it means you can't use absolute paths.

Changed status from 'Archived' to: 'Resolved'

Changed status from 'Archived' to: 'Resolved'

This usage from Python makes sense to support.

You can now use: bpy.data.libraries.write(path, datablocks, path_remap='RELATIVE_ALL') for previous behavior, other options are ABSOLUTE/RELATIVE/NONE

This usage from Python makes sense to support. You can now use: `bpy.data.libraries.write(path, datablocks, path_remap='RELATIVE_ALL')` for previous behavior, other options are `ABSOLUTE/RELATIVE/NONE`
Author

In #77768#956604, @ideasman42 wrote:
This usage from Python makes sense to support.

You can now use: bpy.data.libraries.write(path, datablocks, path_remap='RELATIVE_ALL') for previous behavior, other options are ABSOLUTE/RELATIVE/NONE

Fantastic, thank you so much!

> In #77768#956604, @ideasman42 wrote: > This usage from Python makes sense to support. > > You can now use: `bpy.data.libraries.write(path, datablocks, path_remap='RELATIVE_ALL')` for previous behavior, other options are `ABSOLUTE/RELATIVE/NONE` Fantastic, thank you so much!
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
8 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#77768
No description provided.