SOLIDWORKS to DWG Export: Assigning AutoCAD Layers by Material via API Macro

Fabrication shops that receive DWG files from SolidWorks drawings often expect specific AutoCAD layers — BRASS, STAINLESS_STEEL, ALUMINUM — matching the actual part materials. The native Save As layer mapping table in Document Properties → DXF/DWG Export → Map SolidWorks to DXF/DWG maps entity types to layers, not component materials. There is no UI checkbox that says “use material name as layer.” This post shows the API approach: read each component’s material from the drawing views, create named layers in the drawing document, assign components to those layers, then export to DWG. It covers the key API calls, a complete working VBA macro, and the three edge cases that will silently fail on a naive implementation. ...

25 July 2026 · 9 min · CadShift