Add collada_import routine to Python API that is usable from batch mode #33157

Closed
opened 2012-11-13 05:00:24 +01:00 by Lawrence D'Oliveiro · 5 comments

%%%I recently wanted to do batch conversion of Collada files to .blend files. However, the existing bpy.ops.wm.collada_import operator is unusable from batch mode: it fails with “RuntimeError: Operator bpy.ops.wm.collada_import.poll() failed, context is incorrect” when you try invoking it from a script.

Therefore, I came up with the enclosed patch, which adds a bpy.utils.collada_import routine that doesn’t try to do any UI of its own, it just imports the file specified.

I had to make some minor changes to the definitions of the args passed to the collada_import/export routines, because I couldn’t figure out where the “Scene” typedef was defined, so I just used “struct Scene” instead.%%%

%%%I recently wanted to do batch conversion of Collada files to .blend files. However, the existing bpy.ops.wm.collada_import operator is unusable from batch mode: it fails with “RuntimeError: Operator bpy.ops.wm.collada_import.poll() failed, context is incorrect” when you try invoking it from a script. Therefore, I came up with the enclosed patch, which adds a bpy.utils.collada_import routine that doesn’t try to do any UI of its own, it just imports the file specified. I had to make some minor changes to the definitions of the args passed to the collada_import/export routines, because I couldn’t figure out where the “Scene” typedef was defined, so I just used “struct Scene” instead.%%%

Changed status to: 'Open'

Changed status to: 'Open'

Added subscriber: @Sergey

Added subscriber: @Sergey

I think operator itself could be changed in a way to be usable for the batch import/export by just using some default values for whatever setting it expects to be pulled form the context. Or, alternatively, if they're really crucial for operator thy can be properties initialzied form context on operator invoke().

The issue with your approach is that it adds rather specific function to rather generic module.

I think operator itself could be changed in a way to be usable for the batch import/export by just using some default values for whatever setting it expects to be pulled form the context. Or, alternatively, if they're really crucial for operator thy can be properties initialzied form context on operator invoke(). The issue with your approach is that it adds rather specific function to rather generic module.

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'
Sergey Sharybin self-assigned this 2015-04-30 15:39:42 +02:00

No activity in quite some time now and current state of the patch can not be accepted. But if it is changed to use operator properties instead it'll be all fine.

No activity in quite some time now and current state of the patch can not be accepted. But if it is changed to use operator properties instead it'll be all fine.
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 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-addons#33157
No description provided.