Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.

Using LLMs (ChatGPT / Claude) to write CATIA & SW macros — tips, pitfalls

Last updated on 23 hours ago
A
admin2Member
Posted 23 hours ago
Nikhil_Patil
CAD Automation · Bangalore
Jan 2026
LLMs are genuinely useful for CAD macro writing but only if you treat them as a starting scaffold, not a final answer. The problem is their training data on SolidWorks API is probably cut off around 2024 and things like the newer PDM API methods, or the updated SolidWorks Flow Simulation co-simulation interface, they just don't know about. My workflow: paste the official API method signature from SW help docs directly into the prompt, tell the LLM the exact SW version (2025 SP2), and ask it to write the logic around the known-good method call. That way you're not relying on it to guess the API — you're using it for the logic and loop structure only. Also, for VBA specifically, always ask the model to declare all variables explicitly and turn on Option Explicit, because the first draft almost always has implicit type declarations that cause runtime errors in the SW VBA IDE.
A
admin2Member
Posted 23 hours ago
Carla_Montes ✓ Verified Dev
SW API Developer · Barcelona
Jan 2026
Nikhil said it well. I'll add — for CATIA VBA specifically, LLMs hallucinate method names more than with SW, probably because CATIA VBA documentation is less publicly indexed. The safest prompt structure I've found is: first ask the LLM to list which CATIA objects it knows that are relevant to your task, then validate those object names in the actual CATScript help before proceeding. A dead giveaway that a method is hallucinated is when it doesn't follow the Dassault naming convention of ActionObject.VerbNoun(). Also, Claude tends to be more reliable than GPT-4 for SW API specifically — anecdotally I think because SW's API docs are more structured and Claude seems to handle structured reference docs better. For the most reliable LLM-assisted CAD macro work, check out the community at forums.solidworks.com — people post corrected AI-generated macros there regularly and it's a good sanity check resource.
A
admin2Member
Posted 23 hours ago
Marcus_Rea
Hobbyist / Small shop owner
Feb 2026
Coming from a non-programmer background — using AI to write my first SW macros was honestly the thing that finally made automation accessible to me. The biggest tip I can give to people who aren't coders is to record the SW macro manually first (Tools > Macro > Record), then paste that recorded code into an LLM and ask it to "clean this up, add error handling, and make X parameter a user input variable." That recorded macro is ugly but it has 100% valid API calls because SW generated them itself. The AI then just wraps good structure around valid calls. This approach basically eliminates hallucination for basic tasks.
You can view all discussion threads in this forum.
You cannot start a new discussion thread in this forum.
You cannot reply in this discussion thread.
You cannot start on a poll in this forum.
You cannot upload attachments in this forum.
You cannot download attachments in this forum.
Sign In
Not a member yet? Click here to register.
Forgot Password?
Users Online Now
Guests Online 6
Members Online 0

Total Members: 40
Newest Member: Remax14