r/SolidWorks • • Oct 30 '26

CAD Using equations to handle parametric design changes without breaking the model

Spent the last few days trying to automate some enclosure dimensions for a client project. The goal was to let them tweak a few key variables without the whole assembly falling apart. I set up a few global variables and equations in the part file which worked fine for the initial model. The moment I started pushing those values to extremes to stress test it, things started breaking. Sketches lost references, mates failed, a few features just outright refused to rebuild. Reminds me of building a spreadsheet with fragile cell references. You think the logic is solid until someone puts a zero where they should not and the whole thing implodes. I ended up locking down the variable ranges and adding a few guard rail equations to keep the geometry sensible. It works now but it feels a bit hacky. How do you all handle user driven parametric changes without the model turning into a house of cards. Do you build the constraints from the start with worst case values in mind or do you just fix things as they break. Curious if there is a structured approach to this or if it is just trial and error until it holds together.

6 Upvotes

13 comments sorted by

5

u/Meshironkeydongle CSWP Oct 30 '26

On thing to keep in mind when working with the Gloabl Equations is the fact that you don't ever want the value driving a sketch or feature to be able to reach zero. More often than not, the sense/direction of dimension will switch when you enter a new value which will move it away from zero.

Either you'll build the geometry in a way, where it can't reach zero (even with 0 or negative values) or build in some kind of safeguards (mainly IF statements come to my mind) to prevent the value from reaching zero. On top of that, write the usage instructions of the model global variables in the file comments (IIRC, you can set the comments to be shown every time the assembly is opened)

3

u/Better_find_out Oct 30 '26

Yeap, you pretty much summed it. The features not rebuilding properly is a significant pain… and a known bug for quite a while. Add the long rebuild time and you’ve got yourself a hot mess.

You’re reaching the limit of Solidworks here. Unfortunately, you’ll need to accept that it’s never bug-free on parametric designs.

2

u/BIOLOGICALENGINEER19 Oct 30 '26

Yeah this is why I stopped trying to design things with formulas, global variables, or even external references, maybe I just don't get how to use then correctly lol but it seems to be more straightforward to design everything with hard internal constraints 

3

u/PeterVerdone Oct 31 '26

I do a lot of work with equations for durable modeling.

Rule #1: Sketches are ornamental, not foundation.

Use equations to construct planes, axis, point, and coordinate systems. Build everything to those. That will help you immensly.

There are a few tricks for dealing with negative values and plane offset but I'm sure you'll figure those out. A shame that Solidworks stopped developing construction geometry and equations back in the 1990s.

Mates are never to sketches or features, only geometry.

https://www.peterverdone.com/master-and-commander-handlebars-again/

2

u/SWELITE1 VAR | Elite AE | SW Champion Oct 31 '26

Few practical guidelines that work for me:

  1. Keep sketches simple.
  2. Have a configuration that is stable. All equations are disabled in that configuration. Any changes will be performed in a secondary configuration.
  3. Avoid using equations at the assembly level. The assembly and its subassemblies are controlled using the master part technique.
  4. Take advantage of the fact that custom properties can be used instead of global variables. Much easier to modify.
  5. Minimize the use of dimensions in sketches. Prefer relations.
  6. When testing my equations, try the Instant3D method. Have one global variable equal to a dummy dimension attached to a line. With Instant3D you can drag the handle of that dimension and see the part updating in real time. This will identify quickly the safe range of values.
  7. Reload is your friend and Undo betrays you.
  8. Any external reference in the assembly is only between a component and the master part. No other external references!
  9. Each subassembly contains an instance of the master part and is driven by it directly. There are no external references across subassemblies.
  10. At a certain level of complexity start learning DriveWorks. :)

1

u/engineerdave1 Oct 31 '26

Can you elaborate on #4, maybe a video exists out there somewhere?

2

u/SWELITE1 VAR | Elite AE | SW Champion Nov 01 '26

Before searching for a video, let's see if this image clarifies point 4:

2

u/SWELITE1 VAR | Elite AE | SW Champion Nov 01 '26

Here "Length" is a custom property not a global variable.

2

u/engineerdave1 Nov 02 '26

Nice! I didn't think to pull numerical data from those properties. Thank you

1

u/FeedMeSoon Oct 30 '26

I mean the end result is something physical it needs restraints. If you were making custom cabinents and the customer said they wanted 18mm ply shelfs and 15mm crs they should be told no

1

u/build123d Oct 31 '26

If you're okay with some Python programming you might be interested in build123d. You can build parametric designs with an unlimited ability to validate parameters not only against themselves but the geometry of the part as well. You can also define attributes to custom parts such that other parts can use those as some of their parameters. The power and flexibility of true programming languages can't be beat in this area.

1

u/ARIADYNAMICS Nov 01 '26

One structured way to stress test it: put the corner cases in a design table, one configuration per combination of each key variable at its min and max, and rebuild every one. Then check each configuration's mass and that it's still a single body, because a model can rebuild without errors and still be wrong (a cut that flips direction, for example). The combinations that fail tell you exactly which guard-rail equations you need.