Claude-skill-registry developing-solidworks
ANYTHING related to SolidWorks. Writes, modifies, and debugs C# code that interacts with SolidWorks. Use when working with .cs or .csproj files that (will) reference SolidWorks SDK, SolidWorks.Interop assemblies, COM interop with SolidWorks.
git clone https://github.com/majiayu000/claude-skill-registry
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/developing-solidworks" ~/.claude/skills/majiayu000-claude-skill-registry-developing-solidworks && rm -rf "$T"
skills/data/developing-solidworks/SKILL.mdDeveloping SolidWorks C# Code
Documentation-First Workflow
CRITICAL: Base knowledge of SolidWorks API is inconsistent. Always consult documentation Types, Enums, Docs, Examples, Learnings. You ABSOLUTELY MUST run your code before claiming success. Don't bother with
dotnet build, use dotnet run immediately after code changes. JUST COMPILING IS NOT ENOUGH.
Workflow checklist
Copy and track progress through complex SolidWorks tasks:
SolidWorks Development Progress: - [ ] Step 1: Review API documentation for required methods - [ ] Step 2: Write code with named parameters - [ ] Step 3: Add error handling and null checks - [ ] Step 4: Verify functionality via `dotnet run` - [ ] Step 5: Add cleanup and resource disposal
Required steps before writing code
-
Use grep to explore the docs: The grep-optimized documentation structure makes it easy to find specific methods quickly or extract member documentation programmatically
-
Read documentation: Available in the skill folder:
- API Reference in
and./types/
(method signatures, parameters, enum values)./enums/ - Programming Guide in
(best practices, patterns)./docs/ - Code Examples in
(proven implementations)./examples/ - Troubleshooting Guide in
(documented solutions to common problems)./learnings/
- API Reference in
-
If documentation is unavailable: Run
command to download the API documentation, then continue. If the command fails, ABORT and notify user/download-solidworks-docs -
Verify approach: Confirm alignment with current SDK conventions
Grep Use Cases
Find specific methods quickly
# Find CreateArc method documentation grep -r "CreateArc" .claude/skills/developing-solidworks/types/IModelDoc2/ # Get just that method's file cat .claude/skills/developing-solidworks/types/IModelDoc2/CreateArc2.md
Extract member documentation programmatically
# Get all methods in IModelDoc2 ls .claude/skills/developing-solidworks/types/IModelDoc2/*.md | grep -v "_overview" # Extract all method signatures grep "^**Signature**:" .claude/skills/developing-solidworks/types/IModelDoc2/*.md
Search by metadata
# Find all members in "Application Interfaces" category grep -r "category: Application Interfaces" .claude/skills/developing-solidworks/types/ # Find all methods (not properties) grep -r "kind: method" .claude/skills/developing-solidworks/types/
Find and use enums (each enum is a directory with _overview.md and individual value files):
# Find enum directory ls .claude/skills/developing-solidworks/enums/ | grep -i "endconditions" # Read enum overview cat .claude/skills/developing-solidworks/enums/swEndConditions_e/_overview.md # Find specific enum value grep -r "swEndCondBlind" .claude/skills/developing-solidworks/enums/ cat .claude/skills/developing-solidworks/enums/swEndConditions_e/swEndCondBlind.md # Find enum usage in examples grep -r "swEndConditions_e" .claude/skills/developing-solidworks/examples/
Navigate by category
# View all types in a category cat .claude/skills/developing-solidworks/index/by_category.md | grep -A 20 "Application Interfaces" # View statistics cat .claude/skills/developing-solidworks/index/statistics.md
Troubleshooting Guide
IMPORTANT: When encountering errors or unexpected behavior, consult
./learnings/ first. This directory contains documented solutions to real issues encountered during development, including:
- Problem symptoms and error messages
- Root cause analysis
- Working solutions with code examples
- Best practices to avoid the issue
When encountering new issues not covered in learnings, document the problem, investigation, and solution in a new file with appropriate frontmatter.
SolidWorks-Specific Patterns
SDK library references
The SolidWorks SDK works with .NET Framework only. Find latest SDK libraries via find_api_redist.py. It will return the main folder with all SolidWorks.Interop.* assemblies.
Code quality requirements
Named parameters (required for methods with many parameters):
// Good - Clear what each value represents IFeature extrudeFeature = swFeatureMgr.FeatureExtrusion3( Sd: true, // Single direction Flip: false, // Don't flip side to cut Dir: false, // Don't flip extrusion direction //... ); // Avoid - Unclear what values mean IFeature extrudeFeature = swFeatureMgr.FeatureExtrusion3(true, false, false, (int)swEndConditions_e.swEndCondBlind, (int)swEndConditions_e.swEndCondBlind, 0.1, 0, false, false, false, false, 0, 0, false, false, false, false, false, false, true, (int)swStartConditions_e.swStartSketchPlane, 0, false);
Error handling (SolidWorks API frequently returns null):
IModelDoc2 doc = swApp.ActiveDoc as IModelDoc2; if (doc == null) { throw new InvalidOperationException("No active document"); }
Return value checks (many methods return bool for success):
bool success = doc.Extension.SelectByID2( Name: "Face1", Type: "FACE", X: 0, Y: 0, Z: 0, Append: false, Mark: 0, Callout: null, SelectOption: 0 ); if (!success) { throw new Exception("Selection failed"); }
Type casting (consult documentation for exact return types, cast appropriately):
// Enum casting - cast to int for API input, cast from int for readable output Dir1: (int)swEndConditions_e.swEndCondBlind // API parameter var status = (swSketchCheckFeatureStatus_e)sketch.CheckFeatureUse(); // Return value // Interface casting - check docs for return type, chain casts as needed ISketch sketch = (ISketch)((IFeature)doc.SelectionManager.GetSelectedObject6(1, -1)).GetSpecificFeature2(); // Always verify return types in documentation before casting
Run code before claiming success (you MUST run your new code using
dotnet run or similar. Just building it is NOT enough)
Common patterns
Part creation: Use
GetUserPreferenceStringValue to avoid hardcoding template paths.
swModel = (ModelDoc2)swApp.NewDocument( TemplateName: swApp.GetUserPreferenceStringValue((int)swUserPreferenceStringValue_e.swDefaultTemplatePart), PaperSize: 0, Width: 0, Height: 0);
Document state: Check before operations
if (doc.GetType() != (int)swDocumentTypes_e.swDocPART) { throw new InvalidOperationException("Operation requires part document"); }
Code Verification Checklist
Before delivering code:
Code Quality: - [ ] Consulted API documentation (types/, enums/, docs/, examples/, learnings/) - [ ] Used latest SDK library references - [ ] Applied documented API patterns - [ ] Used named parameters - [ ] Added null checks and error handling - [ ] Included SolidWorks-specific comments - [ ] Handled units correctly - [ ] Code is complete and runnable - [ ] Code was validated at least once via `dotnet run` or `dotnet test`
When to Ask for Clarification
- Requested functionality may not be possible with SolidWorks API
- Multiple significantly different approaches exist
- Task requires specific SolidWorks version or configuration details
- Documentation is ambiguous or contradictory
Quick Examples
Creating a part with extrusion
- Consult API documentation for
(search inCreateExtrudeFeatureSolid2
)./types/ - Write code:
using SolidWorks.Interop.sldworks; using SolidWorks.Interop.swconst; // Get application and create new part ISldWorks swApp = new SldWorks.SldWorks(); IModelDoc2 doc = swApp.NewDocument( TemplateName: swApp.GetUserPreferenceStringValue((int)swUserPreferenceStringValue_e.swDefaultTemplatePart), PaperSize: 0, Width: 0, Height: 0); if (doc == null) throw new Exception("Failed to create document"); // Create sketch on front plane doc.Extension.SelectByID2( Name: "Front Plane", Type: "PLANE", X: 0, Y: 0, Z: 0, Append: false, Mark: 0, Callout: null, SelectOption: 0 ); doc.SketchManager.InsertSketch(true); doc.SketchManager.CreateCenterRectangle(0, 0, 0, 0.05, 0.05, 0); doc.SketchManager.InsertSketch(true); // Create extrude doc.Extension.SelectByID2( Name: "Sketch1", Type: "SKETCH", X: 0, Y: 0, Z: 0, Append: false, Mark: 0, Callout: null, SelectOption: 0 ); IFeature feature = doc.FeatureManager.FeatureExtrusion2( Sd: true, // Single direction Flip: false, // Don't flip side to cut Dir: false, // Don't flip extrusion direction Dir2: (int)swEndConditions_e.swEndCondBlind, // End condition for direction 2 Dir1: (int)swEndConditions_e.swEndCondBlind, // End condition for direction 1 D1: 0.1, // Depth in meters D2: 0, // Depth for direction 2 Dchk1: false, // Draft outward direction 1 Dchk2: false, // Draft outward direction 2 Ddir1: false, // Draft direction 1 Ddir2: false, // Draft direction 2 Dang1: 0, // Draft angle direction 1 Dang2: 0, // Draft angle direction 2 Offstatus: false // Offset from surface ); if (feature == null) throw new Exception("Extrusion failed");