Hi There,
The maths to do this is relatively simple - divide by your "snap unit", round to an integer, then multiply up again by the snap unit.
But first, you need to know about the way that new values get updated from the user interface. For this, you need the special function "current()".
Current() receives a value from your mouse (or VCB) interaction, and then makes the DC equations update once, and only once. Without this, a reference such as...
LenX = round(LenX/25)*25...doesn't know when to stop calculating, because every change to LenX makes it change again, and again - a circular reference. In reality, this kind of error is trapped, but still gives strange results.
The correct form is...
LenX = round(current("LenX")/25) * 25Note that you must wrap the parameter name in quotes as shown here.
You could also use the functions
ceiling() or
floor(), if you want the snapping to always round up, or always round down -
round() always goes to the closest one.
Also, watch out for small lengths that might snap to zero length - the IF function can test for this, e.g...
LenX = if ( current("LenX")>25, round(current("LenX")/25)*25, 25)Here, if current("LenX") is over 25, you will get the result of the rounding functions, otherwise you get a fixed value of 25.
And there is yet another thing to be careful of. No matter what units you use for your drawing, current(), always return the length in inches! So if you are working in metric you may have to multiply the result by 2.54 before rounding.
LenX = if ( current("LenX")>25, round(current("LenX")*2.54/25)*25, 25)There's a full list of functions
HERE.