0
$\begingroup$

devs, I'm still new with python and blender scripting. I tried eding the obj exporter that I found. Can someone help me me with this.

Since I'm exporting tons of object groups, I need each of scene selection or selected objects to be exported as an individual gtlf file

import bpy
import os

# get the path where the blend file is located
basedir = bpy.path.abspath('//')

# deselect all objects
# bpy.ops.object.select_all(action='DESELECT')    

# loop through all the objects in the scene
scene = bpy.context.scene
for ob in scene.objects:
    # make the current object active and select it
    scene.objects.active = ob
    ob.select = True

    # make sure that we only export meshes
    if ob.type == 'MESH':
        # export the currently selected object to its own file based on its name
        bpy.ops.export_scene.gltf(
                filepath=os.path.join(basedir+'gltf-individual', ob.name + '.gltf'),
                use_selection=True,
                )
    # deselect the object and move on to another if any more are left
    ob.select = False
$\endgroup$
  • $\begingroup$ What error or problem are you seeing when you run this? It's not clear what you're asking sorry. Also note that use_selection will need to be renamed as export_selected until github.com/KhronosGroup/glTF-Blender-IO/issues/956 is fixed and released. $\endgroup$ – Don McCurdy Mar 15 at 0:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.