KhronosGroup / glTF-Blender-IO

Blender glTF 2.0 importer and exporter
https://docs.blender.org/manual/en/latest/addons/import_export/scene_gltf2.html
Apache License 2.0
1.46k stars 314 forks source link

support context override #1073

Open ridlimod opened 4 years ago

ridlimod commented 4 years ago

Describe the bug Currently invoking the operator from python doesn't use context overriding as described here: Operators (bpy.ops). At least for "use_selection" setting.

To Reproduce Steps to reproduce the behavior:

  1. Create some mesh primitives: (Cubes, Cylinders, etc.)
  2. Select the Camera or create one and select it if your default scene doesn't have one
  3. Go to scripting tab
  4. Use this
    import bpy
    omeshes = [obj for obj in bpy.data.objects if obj.type == 'MESH']
    context = bpy.context.copy()
    context['active_object'] = omeshes[0]
    context['selected_objects'] = omeshes
    bpy.ops.export_scene.gltf(context, filepath="./tmp.glb", use_selection=True)

Expected behavior To export Meshes Primitives to ./tmp.glb. Instead of this, currently, the operator is exporting the camera as if the context isn't being override.

Version

Additional context After a quick look to the code, it seems that is not using the context at all for retrieve object selection: file line<108>. I could do a quick and dirty patch to fix it but I don't know well the code and design to do a clean one.

julienduroure commented 4 years ago

Confirmed. This is not implemented yet