Resources
Curated snippets, articles, and learning content from the world of manufacturing software engineering.
Recursively walk a SolidWorks assembly tree to collect all component references, paths, and suppression states. Essential for BOM extraction and batch operations.
public void TraverseAssembly(Component2 comp, int level) { var children = (object[])comp.GetChildren(); foreach (Component2 child in children) { string indent = new string(' ', lev…
Extract a Bill of Materials from an active SolidWorks assembly document and write it to a CSV file with part number, description, quantity, and material.
public void ExportBomToCsv(ModelDoc2 model, string outputPath) { var feat = model.FirstFeature(); while (feat != null) { if (feat.GetTypeName2() == "BomFeat") { …
Iterate through a folder of SolidWorks drawing files (.slddrw) and export each as a PDF, preserving sheet sizes and custom properties.
public void BatchExportPdf(string folderPath) { var swApp = (SldWorks)Marshal.GetActiveObject("SldWorks.Application"); foreach (var file in Directory.GetFiles(folderPath, "*.slddrw")) { …
A clean implementation of the ICommand interface for WPF MVVM applications. Supports both synchronous and async execution with CanExecute logic.
public class RelayCommand : ICommand { private readonly Action<object?> _execute; private readonly Predicate<object?>? _canExecute; public RelayCommand(Action<object?> execute, Pr…
Off-the-shelf PLM and ERP systems can't cover every workflow. Learn why custom desktop tools, SolidWorks add-ins, and web configurators are becoming essential for competitive manufacturers.
A beginner-friendly introduction to SolidWorks API development using C# and .NET. Covers setting up your project, connecting to SolidWorks, and automating your first task.
How to build browser-based CPQ configurators using React and Three.js. Covers parametric geometry, material systems, real-time pricing, and integration with manufacturing workflows.
Understand bend allowance, bend deduction, and K-factor calculations for sheet metal fabrication. Includes formulas, lookup tables, and practical examples.
A developer-oriented guide to CNC G-code. Learn the coordinate system, common commands (G0, G1, G2, G3), feed rates, spindle control, and how to generate toolpaths programmatically.
Access and modify custom properties on SolidWorks documents and configurations using the CustomPropertyManager. The foundation of every SolidWorks automation project.
public void ReadWriteCustomProperties(ModelDoc2 model) { var ext = model.Extension; // Read all file-level custom properties var mgr = ext.CustomPropertyManager[""]; object names = nu…
Automate exporting SolidWorks parts and assemblies to STEP (.stp) and IGES (.igs) neutral formats for supplier exchange, 3D printing, and cross-platform CAD compatibility.
public void ExportToStepAndIges(ModelDoc2 model, string outputFolder) { int errors = 0, warnings = 0; string title = Path.GetFileNameWithoutExtension(model.GetTitle()); // Export as STEP …
Read and extract geometry entities (lines, arcs, circles) from AutoCAD DXF files using C#. Essential for nesting, laser cutting, and CNC manufacturing workflows.
// Using the netDxf library (NuGet: netDxf) using netDxf; using netDxf.Entities; public List<EntityInfo> ParseDxfFile(string filePath) { var doc = DxfDocument.Load(filePath); var results = ne…
Bind a dynamic list of items to a WPF ListView or DataGrid using ObservableCollection and INotifyPropertyChanged. The core MVVM data binding pattern for .NET desktop apps.
public class PartViewModel : ObservableObject { public ObservableCollection<Part> Parts { get; } = new(); private Part? _selectedPart; public Part? SelectedPart { get => _sele…
Load and display glTF/GLB 3D models in a React application using React Three Fiber and the useGLTF hook. Includes orbit controls, lighting, and Suspense loading.
import { Canvas } from '@react-three/fiber'; import { OrbitControls, useGLTF, Environment } from '@react-three/drei'; import { Suspense } from 'react'; function Model({ url }: { url: string }) { co…
Five actionable AI use cases for manufacturing — from predictive maintenance to computer vision quality inspection. Includes ROI examples and guidance on starting small.
What digital twins actually are, how they're architected, and what tech stacks power them. A practical guide for software developers entering the manufacturing IoT space.
An introduction to the SolidWorks PDM Professional API — connecting to vaults, reading file metadata, and building add-ins. Covers the key differences from the SolidWorks API.
A practical comparison of WPF desktop and React web applications for manufacturing. When to migrate, what works on web, and how to plan a hybrid approach.
A comprehensive comparison of the most common CAD interchange formats. Understand when to use STEP, IGES, STL, or DXF based on geometry type, downstream process, and compatibility.
Essential formulas, material lookup tables, and tool-specific adjustments for calculating CNC feed rates and spindle speeds. Includes a programmatic calculation example.
Essential patterns for reliable COM automation from C# — proper object cleanup, STA threading, the two-dot rule, and avoiding memory leaks when automating SolidWorks, Excel, and other COM servers.
Access custom properties on weldment and sheet metal cut-list items — a completely different API path from standard file-level custom properties that trips up most developers.
public void ReadCutListProperties(ModelDoc2 model) { var feat = (Feature)model.FirstFeature(); while (feat != null) { if (feat.GetTypeName2() == "CutListFolder") { …
Use IModeler to create geometry without features — the advanced SolidWorks API technique for fast mass property calculations, interference checks, and custom geometry operations.
public void TempBodyDemo(SldWorks swApp, ModelDoc2 model) { var modeler = (Modeler)swApp.GetModeler(); var mathUtil = (MathUtility)swApp.GetMathUtility(); // Create a temp cylinder (cente…
Use the SolidWorks API to add coincident, distance, and angle mates in assemblies. Covers the confusing selection mark system that trips up most developers.
public void AddCoincidentMate(AssemblyDoc assy) { var model = (ModelDoc2)assy; var ext = model.Extension; // Clear any existing selection model.ClearSelection2(true); // Select f…
Use SolidWorks Attributes to store custom data directly on geometry — faces, edges, components. The hidden API feature that most developers never discover.
public void AttributeDemo(SldWorks swApp, ModelDoc2 model) { // Step 1: Define the attribute (once per session) var attDef = (AttributeDef)swApp.DefineAttribute( "MyApp.FaceData"); …
Master MathTransform in the SolidWorks API — the 4x4 matrix that controls component position and rotation in assemblies. Essential for coordinate conversion and component placement.
public void TransformDemo(SldWorks swApp, AssemblyDoc assy) { var model = (ModelDoc2)assy; var mathUtil = (MathUtility)swApp.GetMathUtility(); // Get a component's transform var comp …
The B-Rep (Boundary Representation) model is the foundation of all geometry access in the SolidWorks API. Learn the critical difference between topology and geometry objects.
The complete guide to creating a SolidWorks add-in — COM registration, ISwAddin interface, command groups, TaskPane UI, event callbacks, and deployment to other machines.
The definitive lookup table of GetTypeName2() return values — 60+ feature type strings mapped to human-readable names. The reference every SolidWorks API developer bookmarks.
Practical tips for the most frustrating parts of drawing automation — view transforms, annotation positioning, scale handling, and dimension placement gotchas.
Monitor directories for file changes with debouncing and error recovery — the production-hardened pattern that handles FileSystemWatcher's notorious quirks.
using System.IO; using System.Timers; public class FileChangeMonitor : IDisposable { private readonly FileSystemWatcher _watcher; private readonly Timer _debounce; private string? _lastPa…
Robust file operations with retry logic, timestamp-based change detection, and conflict awareness. Patterns from a production PDM file sync tool.
public static class SafeFileOps { /// <summary>Copy with exponential backoff retry.</summary> public static void CopyWithRetry(string src, string dest, int maxRetries = 3) { for (i…
Use the SolidWorks Equation Manager to read, update, and rebuild assembly dimensions from external code. The foundation for any parametric configurator or WPF-driven design tool.
using SolidWorks.Interop.sldworks; public class EquationManagerService { public void UpdateGlobalVariables( ModelDoc2 assemblyDoc, Dictionary<string, string> globalVariables) …
Use GetDocumentDependencies2 to discover all referenced parts, sub-assemblies, and drawings without opening the file. Scans 500+ component assemblies in under a second.
using SolidWorks.Interop.sldworks; public List<string> ScanDependencies(ISldWorks swApp, string assemblyPath) { var uniquePaths = new HashSet<string>(StringComparer.OrdinalIgnoreCase); // No…
Programmatically package a SolidWorks assembly with all referenced files. Supports including drawings, flattening folders, adding prefix/suffix, and auto-incrementing serial numbers.
using SolidWorks.Interop.sldworks; public string PerformPackAndGo(ModelDoc2 assemblyDoc, string destPath, string prefix) { var swExt = assemblyDoc.Extension; var swPackAndGo = swExt.GetPa…
Thread-safe singleton that manages the SolidWorks COM connection with registry-based detection and automatic mock mode fallback for development without SolidWorks.
using Microsoft.Win32; using System.Runtime.InteropServices; using SolidWorks.Interop.sldworks; public class SolidWorksManager { private static SolidWorksManager? _instance; private static re…
Embed a WPF UserControl inside a SolidWorks TaskPane using the ElementHost bridge. Includes the keyboard input workaround essential for text fields to work — a solution not documented in official SolidWorks API docs.
Production-grade assembly tree extraction that handles suppressed components, envelope exclusions, virtual parts, and configuration-aware traversal. Goes beyond basic recursion to build a filterable tree structure.
A three-phase bin packing optimizer for 1D cutting/nesting problems. Best-Fit Decreasing for initial placement, local search for improvement, and domain-specific constraint redistribution.
Implement a manifest-based file synchronization system with conflict detection. Track file states via JSON, compare timestamps with tolerance, and detect when files were modified by others during offline work.