Skip to content

Instantly share code, notes, and snippets.

@Besjan
Created September 11, 2023 22:13
Show Gist options
  • Save Besjan/39a842379c60cd85c051ffa5ea99d665 to your computer and use it in GitHub Desktop.
Save Besjan/39a842379c60cd85c051ffa5ea99d665 to your computer and use it in GitHub Desktop.
Convert IFC to GLB using BlenderBIM
import bpy
import os
import sys
addons = ["blenderbim"]
for addon in addons:
bpy.ops.preferences.addon_enable(module=addon)
# set input and output file paths
input_file = sys.argv[-2]
output_file = sys.argv[-1]
# Delete the default cube, camera, and light
bpy.ops.object.select_all(action="SELECT")
bpy.ops.object.delete()
# Load IFC project
bpy.ops.bim.load_project(filepath=input_file, use_relative_path=False, should_start_fresh_session=False)
# Export GLB file with Draco compression
bpy.ops.export_scene.gltf(
filepath=output_file,
export_format="GLB",
export_draco_mesh_compression_enable=True,
export_draco_mesh_compression_level=6,
export_draco_position_quantization=14,
export_draco_normal_quantization=10,
export_draco_texcoord_quantization=12,
export_draco_color_quantization=10,
export_draco_generic_quantization=12,
)
# Exit Blender
os._exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment