We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

Load ONLY specific Objects or Collections with Apend Scene?

Home Forums Puzzles Load ONLY specific Objects or Collections with Apend Scene?

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
  • #20763

    I have many unique objects to load as per potential user’s choices.
    Instead of having MANY a separate .gltf file for each object,
    Is there a way instead, to have a .gltf file full of all of them, and be able to designate which objects, or collections of objects would be loaded from the scene?

    Further, are the puzzles “append scene” and “load scene” actually loading the entire .gltf OR is it loading a specific “scene” (as per the name) in blender that can be designated to be loaded with it’s objects…
    ie: 1 .gltf file has 6 “scenes”, each with it’s own objects/collections.
    I could designate one specific “scene” from the .gltf and get desired results?



    Is there a way instead, to have a .gltf file full of all of them, and be able to designate which objects, or collections of objects would be loaded from the scene?

    ATM the engine needs to load the whole gltf file in order to access its contents (i.e. no streaming).

    Further, are the puzzles “append scene” and “load scene” actually loading the entire .gltf OR is it loading a specific “scene” (as per the name) in blender that can be designated to be loaded with it’s objects…

    Multiple scenes are exported to gltf, but only the first scene is available after loading.

    Chief 3D Verger | LinkedIn | Twitter


    @GlifTek, I often have the same requirement. I need to load specific objects into a 3D scene on demand. As Yuri pointed out, the Verge3D engine must load and parse a complete GLTF file just to be able to load one of the objects within it. In my scenes, this would be an incredibly inefficient technique (the user experience would suffer). I have scenes with hundreds of objects that could be loaded. Only a small handful are ever loaded during a single end-user’s session. These libraries of objects can be hundreds of megabytes in size. This is why I keep all of the objects that can be loaded on-demand in separate GLTF files. I know that managing a large number of separate GLTF files can be cumbersome, but here is the technique that I developed to make that more manageable:

    1. Develop a descriptive naming system for all objects. In engineering, this is sometimes called an intelligent part number.
    2. Place all objects in a single Blender file. Putting them in one place makes processing them more efficient.
    3. Keep an inventory of all of the objects in the Blender file in a CSV file. This file can come in handy for other purposes such as project management.
    4. Write a Python script in the Blender file that batch export a separate GLTF file for each of the rows in the CSV.
    5. Develop logic in your puzzles that concatenates strings and values to create the required intelligent part numbers when needed.
    6. Use puzzles to load that part and that part only.

    This may seem like a lot of work to set up, but it is work you will only do once. After that, you can cut and paste it into your new projects. I find that being able to produce 500 GLTF files with the press of a single button is magic. This also makes updating to the latest build of Verge3D fast and easy.

    Jeremy Wernick


    @jem thank you very much for sharing this technique! :good:

    Chief 3D Verger | LinkedIn | Twitter


    No, doesn’t sound complex at all! Sounds exactly what I’m talking about. I have a very specific serialized naming convention and aCSV file to store their data!
    What would the python script look like? That is very very interesting to me!
    Thanks! :yahoo:


    @GlifTek, sorry for my delay in responding.
    I have attached an archive of a simple project that uses this script. You will probably need to edit the python script to suit your requirements. I think that it is reasonably simple. I am not a programmer, and I was able to cobble it together.

    How to use this script.
    1. Place all of your objects in the object_library.blend file.
    2. Edit the CSV file. The CSV has two columns, ObjectName and BlenderFileName. This allows the GLTF file name and the object name to differ if needed.
    3. Open gltf_mass_export_example.blend
    4. Edit the gltf_export_script.py script. At a minimum, you will need to change the value for the fp variable to match your environment.
    5. Run the script.

    For each object listed in the CSV, the script will append the object from the object_library.blend, save it at a separate .blend file, save it as a separate .gltf file, and then delete the object from the working blend file.

    You will end up with a directory of blend files and another directory of gltf files.

    The script is flexible. I have used it to perform batch transformations. There are some commented examples included.

    Give it a try and see what you can do with it. I find this type of scripted batch processing to be very powerful.

    # application directory
    fp = "D:\\verge3d\\verge3d\\applications\\gltf_mass_export_example\\"
    # subdirectory where exported blender files will be placed
    dir_blender = "blender_files"
    # subdirectory where exported gltf files will be placed
    dir_gltf = "gltf_files"
    # name of file containing all of the objects to be extracted and saved as gltf files
    combined_object_data_file = "object_library.blend"
    # CSV file with the names of the objects to be extracted and the name of the gltf file to create from each object
    csv_file_name = "my_export.csv"
    with open( fp + csv_file_name ) as csvfile:
        reader = csv.DictReader( csvfile, dialect='excel')
        for row in reader:
            # Deselect all objects
            obj_name = row['ObjectName']
            file_name = row['BlenderFileName']
            directory = fp + combined_object_data_file + '\\Object\\'
            filepath = directory + obj_name 
            bpy.ops.wm.append(filepath=filepath, filename=obj_name, directory=directory)
            #set the imported object active
            bpy.context.view_layer.objects.active = bpy.context.selected_objects[0]
            #bpy.context.active_object.name = bpy.context.active_object.name.upper()
            #if you need to apply any transformations to each object, ues functions such as the following:
            #bpy.ops.transform.resize(value=(0.0254, 0.0254, 0.0254))
            #bpy.ops.object.transform_apply(location=False, rotation=True, scale=True)
            #bpy.context.active_object.name = bpy.context.active_object.name.upper()
            bpy.ops.wm.save_as_mainfile(filepath=fp + dir_blender + '\\' + file_name + '.blend')
            bpy.ops.export_scene.v3d_gltf(filepath=fp + dir_gltf + '\\' + file_name + '.gltf')
    You must be logged in to view attached files.

    Jeremy Wernick


    Fantastic, Jem!
    I’ll try it out.
    ..yet another addition to the ever expanding bag of tricks that should make this project a streamlined success!
    I really appreciate your help in this.


    I have one more hint for using this script. If you want a specific Verge3D export option to be applied to all of the GLTF files, set that Verge3D export option in the gltf_mass_export_example.blend file. All of the .blend files and .gltf files will inherit that option.
    For example, you might want to enable LZMA compression for all exports. In that case, check the LZMA checkbox in the Verge3D section of the render properties tab in the gltf_mass_export_example.blend. This technique avoids having to remember to enable that option on hundreds of separate blender files.

    Jeremy Wernick


    @jem Awesome! Thank you for sharing this solution! :good:

    Chief 3D Verger | LinkedIn | Twitter


    @GlifTek, my technique is similar to @jem ‘s but even simpler. I’m using 3dsmax and have made a script which export every top object-group(s) (no parents, only children) of the selection into a separate file with the name of the group. Simple group together what should go into one file, select all groups you want to export and click a button. My script can export to multiple file formats (every one is a button), the exportpath is saved with the max-file and the option to move the groups to scene origin prior to export and back after. So you can array the groups next to each other work on them and on export they land on 0,0,0.


    I thought of a method that may suit my needs, though I’d need official agreement,cuz I’m not going to try if it won’t definitely work…

    Using “headless” server side working, append the file with ALL the objects, move desired object from master collection group into special collection group, delete master collection group.

    Does this sound like it would work?
    And be memory-friendly?

    I have not toyed with headless operation yet. :scratch:


    P.s.- server side headless rendering needs to be hosted on non-static-only capable hosting services correct?.. My terminology may be off some here.

    • This reply was modified 2 years, 3 months ago by GLiFTeK.
    • This reply was modified 2 years, 3 months ago by GLiFTeK.

    That would be useful to see an example. Mind sharing?

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.