Unified object and geometry I/O handling #68935

Open
opened 2019-08-20 22:46:18 +02:00 by Dalai Felinto · 28 comments

Motivation

Currently I/O for objects and geometry is primarily handled through import and exporter operators. But there are plans to extend this to:

  • Drag & drop
  • #68933 (Collections for Import/Export)
  • Geometry nodes
  • Asset system

For this we need a unified system to handle I/O for various file formats, to provide consistent functionality across these areas and avoid code duplication.

It will also make a better user interface for the import operator possible, with a single File > Import menu entry where you can then pick a file and see the appropriate options, without having to determine the file format first. Drag & drop similarly should be able to recognize the file type automatically.

Design Proposal

Add new IOHandler type that can be subclassed, similar to operators or render engines (maybe a better name can be found).

It would include:

  • List of file extensions (or method to determine if a filepath matches)
  • Method to create import / export settings
  • Method to make UI layout of import / export settings
  • Method to import a file
  • Method to export to a file
  • Method to provide metadata about file

The precise functionality needs to be determined by looking at the various use cases. But a few general points:

  • Settings:
    Can be stored as ID properties. Potentially the defined properties may depend on the use case, for example an import operator may have additional properties relating to how it affects the scene, compared to collection I/O which may be more local.
  • Import:
    ** This could work similar to library linking .blend files. That is, importing would populate its own main database with datablocks. The operator, geometry node, assets system would then receive this main database and use, copy or link the datablocks as appropriate for each. This gives each use case more control over the ownership, and by not affecting the main .blend database there should be no side effects from running the import method.
  • Export:
    Exporters typically export depsgraph evaluated scene data. They also have options for exporting only selections or the entire scene. There is some potential here for an abstraction that provides the relevant subset of evaluated scene data to the exporter, but the right API for this is not obvious. On the other hand for syncing with Omniverse or other collaborative tools, the data you import and export needs to match, so then you might be exporting original scene data? This might be something we do for USD only and after the basic I/O handler is in place, it's unclear if this would be part of the same system and how it would fit in.
  • Assets:
    Currently assets must always be datablocks from .blend files, but ideally any importable file would be indexable by the asset browsers as well. For this it's important to be able to quickly read metadata, maybe read or generate a preview image. Being able to get the file as a set of datablocks in a database could allow reusing existing code more. Even image files could be read as an image datablock for example. However the asset system might already have plans for its own abstractions here, we need to check how it fits.
## Motivation Currently I/O for objects and geometry is primarily handled through import and exporter operators. But there are plans to extend this to: * Drag & drop * #68933 (Collections for Import/Export) * Geometry nodes * Asset system For this we need a unified system to handle I/O for various file formats, to provide consistent functionality across these areas and avoid code duplication. It will also make a better user interface for the import operator possible, with a single `File > Import` menu entry where you can then pick a file and see the appropriate options, without having to determine the file format first. Drag & drop similarly should be able to recognize the file type automatically. ## Design Proposal Add new `IOHandler` type that can be subclassed, similar to operators or render engines (maybe a better name can be found). It would include: * List of file extensions (or method to determine if a filepath matches) * Method to create import / export settings * Method to make UI layout of import / export settings * Method to import a file * Method to export to a file * Method to provide metadata about file The precise functionality needs to be determined by looking at the various use cases. But a few general points: * Settings: **Can be stored as ID properties.** Potentially the defined properties may depend on the use case, for example an import operator may have additional properties relating to how it affects the scene, compared to collection I/O which may be more local. * Import: ** This could work similar to library linking .blend files. That is, importing would populate its own main database with datablocks. The operator, geometry node, assets system would then receive this main database and use, copy or link the datablocks as appropriate for each. This gives each use case more control over the ownership, and by not affecting the main .blend database there should be no side effects from running the import method. * Export: **Exporters typically export depsgraph evaluated scene data. They also have options for exporting only selections or the entire scene. There is some potential here for an abstraction that provides the relevant subset of evaluated scene data to the exporter, but the right API for this is not obvious.** On the other hand for syncing with Omniverse or other collaborative tools, the data you import and export needs to match, so then you might be exporting original scene data? This might be something we do for USD only and after the basic I/O handler is in place, it's unclear if this would be part of the same system and how it would fit in. * Assets: **Currently assets must always be datablocks from .blend files, but ideally any importable file would be indexable by the asset browsers as well. For this it's important to be able to quickly read metadata, maybe read or generate a preview image.** Being able to get the file as a set of datablocks in a database could allow reusing existing code more. Even image files could be read as an image datablock for example. However the asset system might already have plans for its own abstractions here, we need to check how it fits.
Author
Owner

Added subscriber: @dfelinto

Added subscriber: @dfelinto

Added subscriber: @Jaydead

Added subscriber: @Jaydead

Added subscriber: @lsscpp

Added subscriber: @lsscpp

Added subscriber: @zodiac98177

Added subscriber: @zodiac98177

Nice! Another thing that can be really handy is to be able to see shortcut folders as they are currently not available and when you try to import something you have to fish throughout your regular folders to get to that specific one to which you have a shortcut on your desktop but can't really use in Blender at the moment.

Nice! Another thing that can be really handy is to be able to see shortcut folders as they are currently not available and when you try to import something you have to fish throughout your regular folders to get to that specific one to which you have a shortcut on your desktop but can't really use in Blender at the moment.

Added subscriber: @GeRo

Added subscriber: @GeRo

Added subscriber: @xdanic

Added subscriber: @xdanic

Added subscriber: @Ozeki

Added subscriber: @Ozeki

Removed subscriber: @Ozeki

Removed subscriber: @Ozeki

Users should be able to File > Import, and pick a file, and from that on they get to pick the options for that format.

This should be valid also for exporting

> Users should be able to File > Import, and pick a file, and from that on they get to pick the options for that format. This should be valid also for exporting

Added subscriber: @donmccurdy

Added subscriber: @donmccurdy

Added subscriber: @Mentales

Added subscriber: @Mentales
Member

Added subscriber: @JulianEisel

Added subscriber: @JulianEisel
Member

This popped up on my radar...

Making the File Browser more dynamic (show settings based on active file type) is quite important I think, not just for importers but for the VSE as well. Unfortunately it's not easy to do since a lot of File Browser code assumes the old design.

For drag and drop, this also isn't as easy as it may seem, see #44670 for details and an explanation of how it should be done in my opinion.

This popped up on my radar... Making the File Browser more dynamic (show settings based on active file type) is quite important I think, not just for importers but for the VSE as well. Unfortunately it's not easy to do since a lot of File Browser code assumes the old design. For drag and drop, this also isn't as easy as it may seem, see #44670 for details and an explanation of how it should be done in my opinion.

Added subscriber: @john-astudillo

Added subscriber: @john-astudillo

genial, esto es muy necesario.

genial, esto es muy necesario.

Added subscriber: @IihT2cWA9xiP30BsYphz3EiEISNoScoe

Added subscriber: @IihT2cWA9xiP30BsYphz3EiEISNoScoe

Added subscriber: @TheRedWaxPolice

Added subscriber: @TheRedWaxPolice
Member

Added subscriber: @SonnyCampbell_Unity

Added subscriber: @SonnyCampbell_Unity
Brecht Van Lommel changed title from Unifying I/O importing and drag and drop to Unified object and geometry I/O handling 2022-12-01 17:40:34 +01:00

Added subscriber: @mod_moder

Added subscriber: @mod_moder
Contributor

Added subscriber: @RedMser

Added subscriber: @RedMser

Added subscriber: @erik85

Added subscriber: @erik85

One thing to keep in mind is that multiple plugins could use the same file formats so there needs to be some option for that too.

One thing to keep in mind is that multiple plugins could use the same file formats so there needs to be some option for that too.
Member

Since the asset system is mentioned here:

While it's true that the asset system currently requires assets to be data-blocks (as in IDs), we're moving away from that more and more. The asset system design foresees to only represent assets as a package for arbitrary data (important step: {1efc94bb2f7b}), with enough information to present it to the user and invoke the wanted behavior via some callbacks/interfaces. For example assets can already be loaded from the asset index json files, and only when actually dragging in the asset we call the ID link/append code.

Asset libraries are un-opinionated containers, so add-ons (or core code of course) can populate them however they like. They could just include IO files, or the user manually tells Blender to treat certain files as assets. This code would also provide the callbacks (e.g. for importing/applying the asset, regenerating the preview, visualizing drag & drop, etc).

Fast access to asset metadata is indeed important. If the file format supports metadata well this can be used. For others we discussed sidecar files.


Other thing, IOHandler sounds a bit ambiguous, could also be some file system interface, socket connection or some other data communication system. Maybe ImportExportFormatHandler or so.

Since the asset system is mentioned here: While it's true that the asset system currently requires assets to be data-blocks (as in IDs), we're moving away from that more and more. The asset system design foresees to only represent assets as a package for arbitrary data (important step: {1efc94bb2f7b}), with enough information to present it to the user and invoke the wanted behavior via some callbacks/interfaces. For example assets can already be loaded from the asset index json files, and only when actually dragging in the asset we call the ID link/append code. Asset libraries are un-opinionated containers, so add-ons (or core code of course) can populate them however they like. They could just include IO files, or the user manually tells Blender to treat certain files as assets. This code would also provide the callbacks (e.g. for importing/applying the asset, regenerating the preview, visualizing drag & drop, etc). Fast access to asset metadata is indeed important. If the file format supports metadata well this can be used. For others we discussed sidecar files. --- Other thing, `IOHandler` sounds a bit ambiguous, could also be some file system interface, socket connection or some other data communication system. Maybe `ImportExportFormatHandler` or so.

Added subscriber: @JanErik

Added subscriber: @JanErik
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk

Added subscriber: @kevindietrich

Added subscriber: @kevindietrich

Added subscriber: @AlexeyAdamitsky

Added subscriber: @AlexeyAdamitsky
Philipp Oeser removed the
Interest
Pipeline, Assets & IO
label 2023-02-10 08:54:21 +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
21 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#68935
No description provided.