Bpy.ops.object.collection_external_asset_drop

@julianeisel Had a question about the asset manager. I’d like to be able to add an asset using a button. I found the bpy.ops.object.collection_external_asset_drop operator, but, the python API docs don’t really help much in understanding how to use it.

There are some arguments that are puzzling, I’ve dropped a few assets and seen this operator reported as being run after a drag ‘n’ drop of an asset, here’s what I saw;

  1. The session_uuid argument is set to an integer, which is unrelated to any property of the datablocks themselves. I checked the datablocks of the dropped assets to see if there was a ‘session_uuid’ property, but couldn’t find one.
  2. The ‘collection’ argument is completely opaque to me, all the docs say is;
    collection (enum in [ ] , ( optional )) – Collection. It doesn’t appear to be used according to the reports I see after doing a drag ‘n’ drop, I am not sure if its needed, would help to know what its supposed to be used for.

Basically, I’d really like to know how or even if I can use this op as a button to add an the currently active asset to the scene. I’m not sure how to do this using this operator, of if there’s a better way, I’d love to hear about it!

Help would be much appreciated!

Hi @brecht sorry to bother you with this, tried mentioning @julianeisel but so far no response, not to worry :slight_smile: was wondering if you could either ask him or anyone else to take a look at this question?

As far as I can tell this operator is for internal use and there’s no way to do anything useful with it from Python. There may just not be a way to do what you want with the current implementation.

Thanks @brecht ideally what I’d love to have is a bpy.app.hander.asset_dropped list to add a callback to so I can react to dropped assets. Currently working on a new addon that assist with sculpting workflows by automating a few button presses after an asset gets dropped into the scene.

Can’t really find a way around the issues I am currently having though. When as asset drops, I am handling the depsgraph_update and detecting a new asset from our library. But, this method has issues with undo because I add a custom property to the asset to stop it from being processed as a new asset on further depsgraph updates.

On undo, the custom property is removed, and our script processes the already dropped asset as a freshly dropped one.

I was hoping to use the bpy.ops.object.collection_external_asset_drop operator in a new operator so that adding the asset and handling it would not require this new customer property.

Happy to look at a patch for this and was keen to hear from @julianeisel if a handler for drag ‘n’ drop was planned already?

J