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 AI to automate repetitive sketch constraints in CATIA V5/V6

Last updated on 13 hours ago
A
admin2Member
Posted 13 hours ago
Rajan_Varma ✓ Senior ME
Mechanical Engineer · Pune, India
Mar 2026
Been doing CATIA for 12 years and the sketcher constraint problem is real — you spend half your session just fixing under-constrained profiles. What actually works in 2026 is using CATIA's built-in macros combined with a local Python script that talks to the COM API. I wrote a small loop that reads all open sketches, detects unconstrained DOFs via the constraint status flag, and auto-applies symmetry or fix constraints based on geometry proximity. It's not glamorous but it saves maybe 40 minutes per day. The key function you need is sketch.Constraints.AddMonoEltCst — most people don't know this exists because the official docs bury it. Check the Dassault developer portal at 3ds.com/support/documentation and look under V5 Automation SDK. Also, the CATIA forum on eng-tips.com has a thread from late 2025 where someone shared a working VBA macro for this — still valid today.
A
admin2Member
Posted 13 hours ago
Stefan_Lehmann
CAD Developer · Stuttgart
Mar 2026
Adding to what Rajan said — if you're on 3DEXPERIENCE (R2024x or R2025x), there's a newer route using EKL (Engineering Knowledge Language) scripts that can be triggered by PLM events. I used this to auto-constrain standard bolt hole patterns based on a catalog lookup. The trick is that EKL has access to the Sketch.GeomElems collection and you can iterate through curves to find circles, check their radius against a tolerance band, and fire the constraint rule automatically when a sketch is opened. Here's a minimal EKL snippet that auto-fixes a circle center to origin if it's within 2mm:

/* EKL - auto-fix near-origin circles */
let oSketch = ThisObject->Sketch
let elems = oSketch->GeomElems
for i from 1 to elems->Size() {
 let el = elems->Item(i)
 if el->IsKindOf("Circle2D") {
 if el->Center.X < 2.0 and el->Center.Y < 2.0 {
 oSketch->Constraints.AddMonoEltCst(catCstTypeOn, el)
 }
 }
}
EKL documentation is genuinely sparse so the best real-world reference is the 3DS ENOVIA community wiki.
A
admin2Member
Posted 13 hours ago
Priya_Krishnamurthy
PLM Consultant
Apr 2026
One thing nobody mentions — if you're using AI tools like GitHub Copilot or Claude to write these macros, always validate constraint indices against your specific CATIA service pack. Dassault quietly changes enum values between SP releases and a macro that worked on V5-6R2023 SP2 can silently apply wrong constraint types on SP5. I got burned by this on a landing gear bracket project and wasted two days debugging. Always add a constraint type verification step and log the applied catCstType values to a text file for audit purposes. Combine that with automated regression testing using a reference CATPart as a golden file — compare constraint counts and sketch DOF before committing any macro update.
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 7
Members Online 0

Total Members: 40
Newest Member: Remax14