Extend Drag and Drop to Python #39625

Open
opened 2014-04-06 21:43:38 +02:00 by Andrew Peel · 12 comments

Blender Implements the ability to drag files onto the interface and have an operator called when the file is dropped on the interface. Depending on what is under the cursor one of these operators will be called:

  • OBJECT_OT_add_named
  • OBJECT_OT_drop_named_material
  • MESH_OT_drop_named_image
  • VIEW3D_OT_background_image_add
  • OBJECT_OT_group_instance_add

The code for the available dropboxes can be found here:

source/blender/editors/space_view3d/space_view3d.c – view_3d_dropboxes(void) : void

Proposed Implementation:

Allow a python operator to define the functionality that is called when a file is dragged onto the interface. This exposes very intuitive functionality that can be used by Blender Add-on Developers. An example of this functionality can be found in the Fluid Designer project. In order to achieve this functionality in Fluid Designer we just forced a python operator to be called using this code:

PointerRNA ptr;
WM_operator_properties_create(&ptr, "VIEW3D_OT_drag_and_drop");
RNA_string_set(&ptr, "filepath", ima->name);
WM_operator_name_call(C, "VIEW3D_OT_drag_and_drop", WM_OP_INVOKE_REGION_WIN, &ptr);
WM_operator_properties_free(&ptr);

Discussion Topics:

How would the user know if two add-ons are subscribed to the drag and drop operator?
Is there a better way for an operator to subscribe to a drag and drop event? Maybe using the ‘bl_options’ property of an operator.

Blender Implements the ability to drag files onto the interface and have an operator called when the file is dropped on the interface. Depending on what is under the cursor one of these operators will be called: - OBJECT_OT_add_named - OBJECT_OT_drop_named_material - MESH_OT_drop_named_image - VIEW3D_OT_background_image_add - OBJECT_OT_group_instance_add The code for the available dropboxes can be found here: source/blender/editors/space_view3d/space_view3d.c – view_3d_dropboxes(void) : void **Proposed Implementation:** Allow a python operator to define the functionality that is called when a file is dragged onto the interface. This exposes very intuitive functionality that can be used by Blender Add-on Developers. An example of this functionality can be found in the Fluid Designer project. In order to achieve this functionality in Fluid Designer we just forced a python operator to be called using this code: ``` PointerRNA ptr; WM_operator_properties_create(&ptr, "VIEW3D_OT_drag_and_drop"); RNA_string_set(&ptr, "filepath", ima->name); WM_operator_name_call(C, "VIEW3D_OT_drag_and_drop", WM_OP_INVOKE_REGION_WIN, &ptr); WM_operator_properties_free(&ptr); ``` **Discussion Topics:** How would the user know if two add-ons are subscribed to the drag and drop operator? Is there a better way for an operator to subscribe to a drag and drop event? Maybe using the ‘bl_options’ property of an operator.
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @AndrewPeel

Added subscriber: @AndrewPeel

Added subscriber: @JonathanWilliamson

Added subscriber: @JonathanWilliamson

Added subscriber: @ideasman42

Added subscriber: @ideasman42

I cannot speak to the code side, but from a functionality standpoint I think this is really important to increase the power of add ons. This would open a lot more possibilities and improvement for user-friendliness in add ons. Particularly those that deal with scene and/or object management in any way.

What do you think @ideasman42?

I cannot speak to the code side, but from a functionality standpoint I think this is really important to increase the power of add ons. This would open a lot more possibilities and improvement for user-friendliness in add ons. Particularly those that deal with scene and/or object management in any way. What do you think @ideasman42?
Author

Yeah I still have a lot to learn when it comes to working with Blenders C/C++ Code, but it seems like it could be a simple implementation. Hopefully @ideasman42 can help determine if i am totally out of my mind or if this seems like a possible solution.

Yeah I still have a lot to learn when it comes to working with Blenders C/C++ Code, but it seems like it could be a simple implementation. Hopefully @ideasman42 can help determine if i am totally out of my mind or if this seems like a possible solution.

Added subscriber: @Sergey

Added subscriber: @Sergey

I'm not really sure, seems it's not actually a patch but design discussion? We've got separate project for this actually.. Patch tracker is not the best place for such things.

Assigning to @ideasman42 to have a final decision here.

I'm not really sure, seems it's not actually a patch but design discussion? We've got separate project for this actually.. Patch tracker is not the best place for such things. Assigning to @ideasman42 to have a final decision here.
Campbell Barton was assigned by Sergey Sharybin 2014-04-11 08:53:20 +02:00
Author

Yeah i kind of had a feeling that i posted this in the wrong place right after i hit the submit button, but I have implemented this functionality into the Fluid Designer Build so i can submit a diff showing exactly what i changed, but i have a feeling that it wouldn't be accepted since it is mostly a hack. So i guess i will wait to see what @ideasman42 has to say about what direction I should take. Thanks for the info sergey.

Yeah i kind of had a feeling that i posted this in the wrong place right after i hit the submit button, but I have implemented this functionality into the Fluid Designer Build so i can submit a diff showing exactly what i changed, but i have a feeling that it wouldn't be accepted since it is mostly a hack. So i guess i will wait to see what @ideasman42 has to say about what direction I should take. Thanks for the info sergey.
Campbell Barton removed their assignment 2016-08-11 06:35:43 +02:00

Removed subscriber: @ideasman42

Removed subscriber: @ideasman42

Added subscriber: @thanhph111

Added subscriber: @thanhph111

Added subscriber: @apprenti90

Added subscriber: @apprenti90
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
6 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#39625
No description provided.