sw-api-patterns

Provide reusable SolidWorks API patterns for C# add-in development.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/ttsmith21/swcsharpaddin --skill sw-api-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sw-api-patterns
Source: https://github.com/ttsmith21/swcsharpaddin/tree/main/.claude/skills/sw-api-patterns
Command: npx skills add https://github.com/ttsmith21/swcsharpaddin --skill sw-api-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This collection provides reusable patterns and templates for accessing SolidWorks APIs from C#, helping developers build consistent, reliable add-ins.

Core Features & Use Cases

  • Getting Active Document: pattern to safely obtain the current model.
  • Traversing Features and Components: guidance to enumerate features, bodies, faces, and components.
  • Safe Casting and Property Handling: utilities for robust type casts and property access.
  • Assembly Traversal and Component Management: patterns for dealing with components and model docs.
  • Error Handling and Debugging: recommended patterns to catch and report API errors.
  • Common Gotchas: known pitfalls with SW API calls and how to avoid them.

Quick Start

Review and apply these patterns to implement SolidWorks API calls in your C# add-in development.

Frequently Asked Questions about sw-api-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I get the active SolidWorks document in C# without runtime errors?

To get the active SolidWorks document in C#, use the pattern for safely obtaining the current model object. This approach validates the active document state and applies error handling practices to prevent runtime exceptions during API access.

What is the best way to traverse SolidWorks assembly components using the API?

The best way to traverse SolidWorks assembly components is using dedicated component traversal patterns. These utility helpers provide safe type casting and structured enumeration for navigating assemblies, features, faces, and bodies reliably.

How do I read and write custom properties in a SolidWorks model using C#?

You can read and write custom properties in a SolidWorks model using C# through safe property handling utilities. These patterns ensure robust type casts and secure property access, preventing common API errors during model data manipulation.

Why does my SolidWorks API add-in crash when casting COM objects?

SolidWorks API add-ins often crash when casting COM objects due to unsafe type conversions. Applying utility helpers for robust type casts and the recommended error handling practices catches these API errors and prevents unexpected application failures.

What are common SolidWorks API gotchas when developing a C# add-in?

Common SolidWorks API gotchas in C# add-in development include unsafe type casting, improper document access, and unhandled component traversal errors. This collection outlines known pitfalls and provides patterns to avoid them.

Do I need any specific dependencies to use these SolidWorks API patterns in C#?

No external dependencies are required to apply these SolidWorks API patterns in C#. The collection provides standalone templates and utility helpers that you can directly integrate into your existing add-in development workflow.