Bulk Export - SketchUp Models to .DAE

This script selects everything in a SketchUp file, explodes the model, and then exports selections by tags to a .FBX file location of your choosing.

Broken button... I'll fix it eventually...
# SketchUp Tags Batch Exporter -> DAE (Collada)
# Non-destructive approach: isolate visibility per Tag, export full model each time.
#
# Notes:
# - Works well with nested groups/components because Tag visibility affects containers.
# - DAE retains unit metadata better than OBJ in many downstream pipelines.
# - Requires SketchUp Pro for DAE export.
model = Sketchup.active_model
tags = model.layers # "Tags" in UI, "layers" in API
# ----------------------------
# Helpers
# ----------------------------
def sanitize_filename(name)
cleaned = name.to_s.strip
cleaned = "Untagged" if cleaned.empty?
cleaned.gsub(/[:"\/\\|?*\x00-\x1F]/, "_")
end
def safe_set_tag_visibility(tag, visible)
tag.visible = visible
rescue
# If a tag gets deleted/invalidated for any reason, skip.
end
# ----------------------------
# UI Intro
# ----------------------------
UI.messagebox(
"Welcome to the 'SketchUp Tags Batch Exporter to .DAE Files'!\n\n" \
"What it does:\n" \
"• Exports one .dae per Tag by isolating Tag visibility.\n" \
"• Non-destructive: no exploding, no deleting.\n" \
"• Works with nested groups/components.\n\n" \
"Before continuing:\n" \
"• Save your model.\n" \
"• Ensure you are running SketchUp Pro (DAE export requires Pro).\n",
MB_OK
)
export_dir = UI.select_directory(title: "Select Export Directory for .dae Files")
if export_dir.nil?
puts "Export directory selection canceled. Exiting."
return
end
# ----------------------------
# Snapshot current state
# ----------------------------
tag_list = tags.to_a
original_visibility = {}
tag_list.each { |t| original_visibility[t] = t.visible? }
# Some display options can affect what "visible" geometry gets exported depending on workflow.
# We preserve and restore them.
render_opts = model.rendering_options
original_hidden_geometry = render_opts["DisplayHiddenGeometry"]
original_hidden_objects = render_opts["DrawHidden"]
original_section_planes = render_opts["DisplaySectionPlanes"]
original_section_cuts = render_opts["DisplaySectionCuts"]
# Optional: prevent hidden geometry/objects from exporting unexpectedly.
# Comment these out if you WANT hidden geometry exported.
render_opts["DisplayHiddenGeometry"] = false
render_opts["DrawHidden"] = false
# ----------------------------
# Export loop
# ----------------------------
model.start_operation("Batch Export DAEs by Tag", true)
begin
tag_list.each_with_index do |tag, idx|
# Isolate: hide all tags then show current tag
tag_list.each { |t| safe_set_tag_visibility(t, false) }
safe_set_tag_visibility(tag, true)
tag_name = sanitize_filename(tag.name)
export_path = File.join(export_dir, "#{tag_name}.dae")
# Keep options minimal for compatibility.
# SketchUp exporters often ignore unknown keys silently.
options = {}
status = model.export(export_path, options)
if status
puts "[#{idx + 1}/#{tag_list.length}] Exported: #{tag.name} -> #{export_path}"
else
puts "[#{idx + 1}/#{tag_list.length}] FAILED: #{tag.name}"
end
end
ensure
# Restore tag visibility
original_visibility.each { |t, vis| safe_set_tag_visibility(t, vis) }
# Restore render options
render_opts["DisplayHiddenGeometry"] = original_hidden_geometry
render_opts["DrawHidden"] = original_hidden_objects
render_opts["DisplaySectionPlanes"] = original_section_planes
render_opts["DisplaySectionCuts"] = original_section_cuts
model.commit_operation
end
UI.messagebox(
"Export completed.\n\n" \
"• One DAE per Tag has been written to:\n#{export_dir}\n\n" \
"Your original Tag visibility and view settings were restored.",
MB_OK
)
Description
It is an amazing time to be alive. I use a variety of tools for my job and most of the AVL industry is not using Blender as a way to distribute product files.
Understandable but sad.
To get these models into Blender, SketchUp supports exports to .fbx files which Blender can then import.
I CAN get my hands on quite a few SketchUp files but I don't want to sit exporting every single model and reimporting them one by one into Blender. I want to do it in batches. With the help of ChatGPT, here is a script that I am using to speed up the process.
Hopefully, it can help you too! If you are using SketchUp 2024, you may get errors related to tags vs. layers but if you just copy the code and put it back in ChatGPT and ask it to switch out for tags instead of layers it should work.
Happy Sketching & Blending!
