Finder thumbnails and "Open with" registration fail in the field for three compounding reasons: the app claims com.autodesk.dwg/.dxf but never declares them (UTImportedTypeDeclarations was missing, so on systems with no other declarer Launch Services can't bind the extensions at all); the QuickLook appex only serves com.autodesk.dwg while machines with AutoCAD installed resolve .dwg to its exported com.autodesk.autocad.dwg (BricsCAD etc. likewise win with their own UTIs); and the ad-hoc --deep signature carries no entitlements, but a QuickLook thumbnail extension must be sandboxed (com.apple.security.app-sandbox) before macOS will run it. Import-declare both UTIs, claim and serve the AutoCAD variants too, add the appex sandbox entitlements, and add packaging/build_macos_signed.sh — a local mirror of the CI build-macos job that signs with a Developer ID (hardened runtime, per-component entitlements), notarizes and staples. DEVELOPER_ID=- reproduces the CI ad-hoc build. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
DWG thumbnails for OS file managers
dwg_thumbnailer::extract reads only the embedded preview from a DWG (file
header → preview seeker → parse — never the whole drawing) and returns it as an
image::RgbaImage. It's the shared core behind every platform's thumbnail
integration.
crates/
dwg-thumbnailer/ this crate — shared core + macOS extension sources
dwg-thumbnailer-win/ Windows IThumbnailProvider COM DLL (depends on the core)
Linux (COSMIC, GNOME, Nautilus, Nemo, …) — handled by OpenCADStudio itself
No separate binary. OpenCADStudio embeds this core and, on startup, installs a
freedesktop .thumbnailer pointing at its own hidden --dwg-thumbnail mode
(see src/io/file_association.rs::install_thumbnailer). Launch OCS once and file
managers render DWG thumbnails; clear stale "no thumbnail" cache if needed:
rm -f ~/.cache/thumbnails/fail/*/*.png
Windows (Explorer) — authored, build & test on Windows
A COM in-proc server implementing IThumbnailProvider. Not compiled/tested on
the Linux dev host — build and verify on Windows.
cd crates\dwg-thumbnailer-win && cargo build --release
regsvr32 target\release\dwg_thumbnailer_win.dll :: register (elevated)
regsvr32 /u target\release\dwg_thumbnailer_win.dll :: unregister
ie4uinit.exe -show :: refresh thumbnails
If regsvr32's self-registration needs adjusting, the equivalent registry keys
are (replace the path):
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\CLSID\{8F2A9C41-3B6E-4E2D-9C7A-1E0B5D6F42AA}]
@="OpenCADStudio DWG Thumbnail Provider"
[HKEY_CLASSES_ROOT\CLSID\{8F2A9C41-3B6E-4E2D-9C7A-1E0B5D6F42AA}\InprocServer32]
@="C:\\path\\to\\dwg_thumbnailer_win.dll"
"ThreadingModel"="Apartment"
[HKEY_CLASSES_ROOT\.dwg\ShellEx\{e357fccd-a995-4576-b01f-234630154e96}]
@="{8F2A9C41-3B6E-4E2D-9C7A-1E0B5D6F42AA}"
macOS (Finder) — sources provided, build in Xcode
A QuickLook Thumbnail Extension (macos/ThumbnailProvider.swift) calls the
Rust core's C ABI, linked as a static library. Requires Xcode + a host app.
- Build the core as a static lib for your arch(s):
cargo build -p dwg-thumbnailer --release --target aarch64-apple-darwin # → target/aarch64-apple-darwin/release/libdwg_thumbnailer.a - In Xcode, add a Thumbnail Extension target to a host app.
- Use
macos/Info.plist(lists thecom.autodesk.dwgUTI). - Add
macos/ThumbnailProvider.swift. - Add a bridging header that
#includesmacos/dwg_thumbnailer.h. - Link
libdwg_thumbnailer.a(+ system frameworks it needs).
- Use
- Sign, install the host app, and Finder picks up the extension.
C ABI (see dwg_thumbnailer.h):
dwg_thumbnail_png(path, max_dim, &ptr, &len) / dwg_thumbnail_free(ptr, len).
Formats: DWG BMP-DIB and PNG embedded previews decode. WMF previews and files without a preview (or DXF) produce no thumbnail — the file manager falls back.