UDIM are not properly imported if spaces are present in the filename #102552

Open
opened 2022-11-16 10:44:02 +01:00 by Alexandre Labedade · 9 comments

System Information
Operating system: Windows 10
Graphics card: NVidia RTX 2070

Blender Version
Broken: version: 3.3.0, branch: master, commit date: 2022-09-06 15:39, type: release
Worked: version: 3.2.2, branch: master, commit date: 2022-08-02 18:15, type: release

Short description of error
If a space character is present in the filename, the UDIM tiles will not be detected, and only the first image will be imported.

Exact steps for others to reproduce the error

  • create some udim images with the names "udim 1001.png","udim 1002.png","udim 1003.png", etc... on your hard drive

  • open blender in the image editor

  • click the open image button, and select all the udim images to load

  • in Blender 3.2.2 it is properly recognized as UDIM tiles, since 3.3.0 is it loaded as an image sequence, with no possibility to properly load the udim.

If the spacing characters are replaced by a _ in the filenames, then everything is fine in 3.3.0.

**System Information** Operating system: Windows 10 Graphics card: NVidia RTX 2070 **Blender Version** Broken: version: 3.3.0, branch: master, commit date: 2022-09-06 15:39, type: release Worked: version: 3.2.2, branch: master, commit date: 2022-08-02 18:15, type: release **Short description of error** If a space character is present in the filename, the UDIM tiles will not be detected, and only the first image will be imported. **Exact steps for others to reproduce the error** - create some udim images with the names "udim 1001.png","udim 1002.png","udim 1003.png", etc... on your hard drive - open blender in the image editor - click the open image button, and select all the udim images to load - in Blender 3.2.2 it is properly recognized as UDIM tiles, since 3.3.0 is it loaded as an image sequence, with no possibility to properly load the udim. If the spacing characters are replaced by a _ in the filenames, then everything is fine in 3.3.0.

Added subscriber: @Alesk

Added subscriber: @Alesk

Added subscriber: @deadpin

Added subscriber: @deadpin

Changed status from 'Needs Triage' to: 'Needs User Info'

Changed status from 'Needs Triage' to: 'Needs User Info'

This was somewhat of a conscious decision due to UDIM detection picking up numbers in the filename incorrectly in many instances - so I changed it to be more conservative and only find numbers bound on both sides by some delimiter (not a space).

For 3.3+, simply change the Image source to 'UDIM Tiles' and type the exact location of <UDIM> in the filename and it should load fine - see below:
image.png

Do you think this is alright? Have you noticed if any other software (don't have to name them) automatically detects such files as UDIMs?

This was somewhat of a conscious decision due to UDIM detection picking up numbers in the filename incorrectly in many instances - so I changed it to be more conservative and only find numbers bound on both sides by some delimiter (not a space). For 3.3+, simply change the Image source to 'UDIM Tiles' and type the exact location of `<UDIM>` in the filename and it should load fine - see below: ![image.png](https://archive.blender.org/developer/F13924186/image.png) Do you think this is alright? Have you noticed if any other software (don't have to name them) _automatically_ detects such files as UDIMs?

In #102552#1446745, @deadpin wrote:
This was somewhat of a conscious decision due to UDIM detection picking up numbers in the filename incorrectly in many instances - so I changed it to be more conservative and only find numbers bound on both sides by some delimiter (not a space).

For 3.3+, simply change the Image source to 'UDIM Tiles' and type the exact location of <UDIM> in the filename and it should load fine - see below:
Do you think this is alright?

It's working but not very user friendly.

Have you noticed if any other software (don't have to name them) automatically detects such files as UDIMs?

I am not sure there is a perfect automated solution for this.

For instance, in modo they give the choice to the user, see here at the bottom of the page : https://learn.foundry.com/modo/901/content/help/pages/uving/udim_workflow.html

I think that a good automated solution would be to split the filenames in chunks of numerical and non-numerical characters, and then find the pattern for UDIM tiles.
Relying on separators here doesn't seems to be flexible enough.

I have no skills in C/C++, but I could provide a python mockup of this kind of function, if you are interested.

> In #102552#1446745, @deadpin wrote: > This was somewhat of a conscious decision due to UDIM detection picking up numbers in the filename incorrectly in many instances - so I changed it to be more conservative and only find numbers bound on both sides by some delimiter (not a space). > > For 3.3+, simply change the Image source to 'UDIM Tiles' and type the exact location of `<UDIM>` in the filename and it should load fine - see below: > Do you think this is alright? It's working but not very user friendly. > Have you noticed if any other software (don't have to name them) _automatically_ detects such files as UDIMs? I am not sure there is a perfect automated solution for this. For instance, in modo they give the choice to the user, see here at the bottom of the page : https://learn.foundry.com/modo/901/content/help/pages/uving/udim_workflow.html I think that a good automated solution would be to split the filenames in chunks of numerical and non-numerical characters, and then find the pattern for UDIM tiles. Relying on separators here doesn't seems to be flexible enough. I have no skills in C/C++, but I could provide a python mockup of this kind of function, if you are interested.

Changed status from 'Needs User Info' to: 'Confirmed'

Changed status from 'Needs User Info' to: 'Confirmed'
Jesse Yurkovich self-assigned this 2022-11-16 11:48:25 +01:00

I'll claim this for now and think about it some more. The filename is already parsed to find the numerical portion but it was "too good" at finding numbers that were not udims, like dates or image resolutions that also fall inside the udim range we support (eg 1999 or 1024 etc.) Enforcing the number to also be between delimiters of _,-, or . was done to eliminate most common occurances, and if automatic detection fails, a quick fix up like above should always be possible where the user directly indicates where in the filename things should be.

I'll claim this for now and think about it some more. The filename is already parsed to find the numerical portion but it was "too good" at finding numbers that were not udims, like dates or image resolutions that also fall inside the udim range we support (eg 1999 or 1024 etc.) Enforcing the number to also be between delimiters of _,-, or . was done to eliminate most common occurances, and if automatic detection fails, a quick fix up like above should always be possible where the user directly indicates where in the filename things should be.

Ok, I see.

In #102552#1446765, @deadpin wrote:
a quick fix up like above should always be possible where the user directly indicates where in the filename things should be.

In this case, it should be mentionned somewhere in the UI, to help the user.

Anyway, I'll think about it and try to find a better automated solution, and let you know if I find something interesting.

Ok, I see. > In #102552#1446765, @deadpin wrote: > a quick fix up like above should always be possible where the user directly indicates where in the filename things should be. In this case, it should be mentionned somewhere in the UI, to help the user. Anyway, I'll think about it and try to find a better automated solution, and let you know if I find something interesting.

Hi,

Here is prototype python code to identify the UDIM pattern. Let me know if it could be of some help, or if I should focus on some modifications.

import re
import numpy as np

# Dummy list of files
files = []
for i in range(1001,1011):
    files.append("my file on 16-11-2022 is udim tile number "+str(i)+".png")

# RegEx pattern to detect 4 digits numbers
pattern = re.compile(r"([0-9]{4})", re.IGNORECASE)

resultA = re.split(pattern, files[0])
resultB = re.split(pattern, files[1])

# will contain an array of strings
reference = None

# will contain an array of booleans
comparisonFilter = None

# loop on files names
for filename in files:
    
    if reference is None:
        reference = np.array(re.split(pattern, filename))
    else:
        splitResult = np.array(re.split(pattern, filename))
        
        comparison = np.compare_chararrays(reference, splitResult, "==", rstrip = True)
        reference = splitResult
        
        - compare the array of bools,
        - they should contain only one occurence of False at the position of the udim number
        if comparisonFilter is None:
            comparisonFilter = comparison
        else:
            # compare the current array of bool with the new one
            comparisonFilter = np.logical_and(comparisonFilter,comparison)
        
        indices = [i for i, x in enumerate(comparisonFilter) if x == False]
        if len(indices) == 1:
            element = splitResult[indices[0]]
            
            if re.match(pattern,element):
                if int(element) < 1001 or int(element) > 9999:
                    # out of the range of UDIMS
                    print("error")
                else:
                    print("ok")
            else:
                # this is not a 4 digits number
                print("error")
        else:
            # if False value is not present, or more than one, then there is a problem
            print("error")
            break 

if comparisonFilter is not None:
    indices = [i for i, x in enumerate(comparisonFilter) if x == False]
    
    if len(indices) == 1:
        reference[indices[0]] = "<UDIM>"
        udim_pattern = ''.join(reference)
        print(udim_pattern)
    else:
        print("error")

Hi, Here is prototype python code to identify the UDIM pattern. Let me know if it could be of some help, or if I should focus on some modifications. ``` import re import numpy as np # Dummy list of files files = [] for i in range(1001,1011): files.append("my file on 16-11-2022 is udim tile number "+str(i)+".png") # RegEx pattern to detect 4 digits numbers pattern = re.compile(r"([0-9]{4})", re.IGNORECASE) resultA = re.split(pattern, files[0]) resultB = re.split(pattern, files[1]) # will contain an array of strings reference = None # will contain an array of booleans comparisonFilter = None # loop on files names for filename in files: if reference is None: reference = np.array(re.split(pattern, filename)) else: splitResult = np.array(re.split(pattern, filename)) comparison = np.compare_chararrays(reference, splitResult, "==", rstrip = True) reference = splitResult - compare the array of bools, - they should contain only one occurence of False at the position of the udim number if comparisonFilter is None: comparisonFilter = comparison else: # compare the current array of bool with the new one comparisonFilter = np.logical_and(comparisonFilter,comparison) indices = [i for i, x in enumerate(comparisonFilter) if x == False] if len(indices) == 1: element = splitResult[indices[0]] if re.match(pattern,element): if int(element) < 1001 or int(element) > 9999: # out of the range of UDIMS print("error") else: print("ok") else: # this is not a 4 digits number print("error") else: # if False value is not present, or more than one, then there is a problem print("error") break if comparisonFilter is not None: indices = [i for i, x in enumerate(comparisonFilter) if x == False] if len(indices) == 1: reference[indices[0]] = "<UDIM>" udim_pattern = ''.join(reference) print(udim_pattern) else: print("error") ```
Philipp Oeser removed the
Interest
Core
label 2023-02-09 14:42:46 +01:00
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
2 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#102552
No description provided.