Page MenuHome

Adding file drop for Collada Importer

Authored by Gaia Clary (gaiaclary) on May 10 2015, 8:12 PM.



This diff adds Drag&Drop of Collada files to the 3D-Viewport.

Diff Detail

rB Blender

Event Timeline

Gaia Clary (gaiaclary) retitled this revision from to Adding file drop for Collada Importer.
Gaia Clary (gaiaclary) updated this object.

Added missing #ifdef WITH_COLLADA

really great Idea. Would it be possible to generalize this to associate a path ending (like ".obj") with an importer (defined by user or just look for filtered formats in the importer to automatically make an association table)?

It works well for the collada importer, because it is written in C (c++ actually).
All other importers are written in Python. And it would be necessary to
call a python module from within C in order to get this working in general.

I do not know if this is doable for Blender. But it might be possible after all.
Others (Campbell ?) might answer that in more detail.

@Gaia Clary (gaiaclary), I had a quick look at supporting drag&drop for Python written importers yesterday, and think it's easily doable. Maybe it's also worth creating some proper drag&drop api calls, so it can be used for other use cases as well, but we can check that later.

@Julian Eisel (Severin): That sounds great. I also had a look at this but i searched for a generic solution based in poll() copy() functions like i added for the Collada exporter. However, i could not see how to do it easily on that level. My main issue was that i would need one pair of poll()/copy() functions for each file extension, then i could add a WM_dropbox_add() to specify which Operator (and which poll/copy functions) have to be called for each file extension. But that does not sound like a good solution.

So maybe for Python it can be done in another more satisfying way. It would be great if that solution would also be working for the Collada exporter. I believe it would be very helpful if your solution allows to preset import options. Anyways it is just so much easier to use drop to place a collada file into the scene :)

Campbell Barton (campbellbarton) requested changes to this revision.May 11 2015, 4:31 PM
Campbell Barton (campbellbarton) edited edge metadata.

Would prefer to have a general operator, WM_OT_import_activate or so, which could open the importer based on the file path.

Having a separate dropbox for every different file format (or only having for collada) seems a bit weak.


Should use BLI_testextensie, which isn't case sensitive.

This revision now requires changes to proceed.May 11 2015, 4:31 PM
Gaia Clary (gaiaclary) edited edge metadata.

file extension check now uses BLI_testextensie()

Campbell Barton (campbellbarton) requested changes to this revision.May 12 2015, 5:48 AM
Campbell Barton (campbellbarton) edited edge metadata.

@gaia, would prefer to hold off committing this to master, instead do a more generic DND import as discussed here: T44670

This revision now requires changes to proceed.May 12 2015, 5:48 AM

@Campbell Barton (campbellbarton): yes, of course i have not planned to push this to Master. I will start working soon on the more general solution according to T44670 (unless others are faster :) )

Gaia Clary (gaiaclary) edited edge metadata.

a first implementastion of the idea of a generic file dropper

Sergey Sharybin (sergey) requested changes to this revision.May 15 2015, 1:05 PM

It's quite strange functionality. If things like this are accepted then they should do actual import instead of showing a file browser open with the file selected. But then you'll be having issues with settings like axis mapping, scaling and so on.

Don't really see improvements comparing to the current master branch, maybe just search in the file selector could become more easy to use.

This revision now requires changes to proceed.May 15 2015, 1:05 PM

well the possible improvement are:

  • we can use all the benefits of an OS File browser (complex search parameters, preview of all formats, etc...).
  • For many people, it also an improvement in consistency as drag and drop is now part of nearly every program and is already present in many parts of Blender.
  • You can import several object from different location in one step directly where you release your mouse in the scene.

Opening the full window is a bit overkill, I agree, just showing the options part in the tool panel would be enough. Saving last used parameters and/or defaults/presets would allow for even quicker import.

@Sergey Sharybin (sergey): This patch did not open a file browser. It did exactly what you proposed in your comment (and it has all the issues that you identified as well). In the case of the Collada importer i activated the operator redo panel just to see if this could be a feasible way to provide "posthum" import options. And in my tests it worked nicely, so that you actually even could tweak the imported items right after import if necessary.

We already summarized in T44670 what has been identified as major issues. So we already know that the patch as it stands needs an almost complete rewrite. Whether this feature will ever be implemented and how exactly it will be implemented, all of this is still discussed. This patch can be seen as a concept study if you like.