Replace space image drop-box with a File Handler #117707

Merged
Jesse Yurkovich merged 11 commits from guishe/blender:multiple-image-import into main 2024-04-25 03:40:28 +02:00
Contributor

Replaces Space Image drop-box with a file handler in order
to support open multiple files at once.

Is introduced a operator Image_OT_open_images, that uses
Image_OT_open, this operator groups files that may result
in different sequences or in different a UDIM groups.

Replaces `Space Image` drop-box with a file handler in order to support open multiple files at once. Is introduced a operator `Image_OT_open_images`, that uses `Image_OT_open`, this operator groups files that may result in different sequences or in different a UDIM groups.
Guillermo Venegas added 1 commit 2024-02-01 00:23:36 +01:00
Guillermo Venegas added 1 commit 2024-02-01 04:56:13 +01:00
Jesse Yurkovich requested review from Jesse Yurkovich 2024-02-01 20:27:12 +01:00
Jesse Yurkovich requested changes 2024-02-06 03:57:47 +01:00
Dismissed
Jesse Yurkovich left a comment
Member

Would like @JulianEisel 's opinion on this as well as the owner of drag/drop.

Would like @JulianEisel 's opinion on this as well as the owner of drag/drop.
@ -194,0 +203,4 @@
files: CollectionProperty(type=OperatorFileListElement, options={'SKIP_SAVE', 'HIDDEN'})
relative_path: BoolProperty(name="Use relative path", default=False)
use_sequence_detection: BoolProperty(name="Use sequence detection", default=False)
use_udim_detection: BoolProperty(name="Use UDIM detection", default=False)

It's probably better to set these 3 properties to True to match the existing option defaults. What do you think?

It's probably better to set these 3 properties to True to match the existing option defaults. What do you think?
Author
Contributor

I had it as False because there was no feedback when the images were imported as sequences.
But since the sequence is replaced with # in the name, I think it can be set to true

I had it as `False` because there was no feedback when the images were imported as sequences. But since the sequence is replaced with `#` in the name, I think it can be set to true
guishe marked this conversation as resolved
@ -194,0 +259,4 @@
use_udim_detecting=self.use_udim_detection,
relative_path=self.relative_path)
if len(files) > 1 and self.use_sequence_detection:
context.edit_image.name = "{prefix}{hash}{ext}".format(prefix=seq[0], hash=("#" * seq[2]), ext=seq[1])

This is a nice substitution I think. But it could end up doing this for the name of UDIMs too. I guess this is the primary downside of keeping use_sequence_detection and use_udim_detection set to True at the same time but it could easily happen.

This is a nice substitution I think. But it could end up doing this for the name of UDIMs too. I guess this is the primary downside of keeping `use_sequence_detection` and `use_udim_detection` set to True at the same time but it could easily happen.

When dropping 2 UDIM files "test.1001.png" and "test.1002.png", this code will replace the correct test.<UDIM>.png name with test.####.png. How about doing the following to only do this replacement for sequences:

            is_tiled = context.edit_image.source == 'TILED'
            if len(files) > 1 and self.use_sequence_detection and not is_tiled:
                ...
When dropping 2 UDIM files "test.1001.png" and "test.1002.png", this code will replace the correct `test.<UDIM>.png` name with `test.####.png`. How about doing the following to only do this replacement for sequences: ```python is_tiled = context.edit_image.source == 'TILED' if len(files) > 1 and self.use_sequence_detection and not is_tiled: ... ```
Author
Contributor

Added, but I think it would be good to be able to distinguish in some way the udims images in the name

Added, but I think it would be good to be able to distinguish in some way the udims images in the name
guishe marked this conversation as resolved
@ -194,0 +263,4 @@
return {'FINISHED'}
def invoke(self, context, event):

To match current behavior we could drop the invoke and add bl_options = {'REGISTER', 'UNDO'} to this operator. That would allow users to drag/drop without a popup but still adjust things after the fact with the redo panel. Most folks will be dropping regular files so, if possible, we should try to keep that seamless and quick.

To match current behavior we could drop the `invoke` and add `bl_options = {'REGISTER', 'UNDO'}` to this operator. That would allow users to drag/drop without a popup but still adjust things after the fact with the redo panel. Most folks will be dropping regular files so, if possible, we should try to keep that seamless and quick.
guishe marked this conversation as resolved
@ -194,0 +266,4 @@
def invoke(self, context, event):
if not self.directory or len(self.files) == 0:
return {'CANCELLED'}
title = self.files[0].name if len(self.files) == 1 else "Open {len} imagenes".format(len=len(self.files))

Spelling of "images" here and the bl_label below

Spelling of "images" here and the `bl_label` below
guishe marked this conversation as resolved
Jesse Yurkovich requested review from Julian Eisel 2024-02-06 03:58:49 +01:00
Guillermo Venegas added 2 commits 2024-02-06 20:08:54 +01:00
Guillermo Venegas added 1 commit 2024-02-07 17:25:25 +01:00
Guillermo Venegas added 2 commits 2024-03-28 01:37:30 +01:00
Julian Eisel approved these changes 2024-04-17 17:55:13 +02:00
Julian Eisel left a comment
Member

Didn't really go into the operator implementation details, but overall things look good to me. Just one small thing I suggest changing.

Didn't really go into the operator implementation details, but overall things look good to me. Just one small thing I suggest changing.
@ -194,0 +212,4 @@
@classmethod
def poll(cls, context):
return (context.area and context.area.ui_type == 'IMAGE_EDITOR'
and context.region and context.region.type == 'WINDOW')
Member

I don't think you have to enforce a region type here? That would only be required when getting data from context that is only available in this region, that doesn't seem to be the case here. So I think this can be removed.

I don't think you have to enforce a region type here? That would only be required when getting data from context that is only available in this region, that doesn't seem to be the case here. So I think this can be removed.
guishe marked this conversation as resolved
Guillermo Venegas added 2 commits 2024-04-19 21:59:06 +02:00
Guillermo Venegas added 1 commit 2024-04-23 21:27:06 +02:00
Jesse Yurkovich reviewed 2024-04-24 09:06:40 +02:00
@ -194,0 +260,4 @@
relative_path=self.relative_path)
is_tiled = context.edit_image.source == 'TILED'
if len(files) > 1 and self.use_sequence_detection and is_tiled:
context.edit_image.name = "{prefix}{hash}{ext}".format(

The condition should be not is_tiled - seems like the not got dropped?

The condition should be `not is_tiled` - seems like the `not` got dropped?
guishe marked this conversation as resolved
Guillermo Venegas added 1 commit 2024-04-24 17:23:14 +02:00
Jesse Yurkovich approved these changes 2024-04-25 03:32:36 +02:00
Jesse Yurkovich merged commit b97ac126f8 into main 2024-04-25 03:40:28 +02:00

Reminder to use case insensitive extension matching (fixed 2f003277c5).

Reminder to use case insensitive extension matching (fixed 2f003277c59e34c8d69507367a419272fc6a89ca).
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#117707
No description provided.