# Math when typing

When I am entering a value in a text box like depth of cut, I want to be able to enter a fraction, then equals, and have it calculate the value.

For instance 1 / 8 = would change the value to 0.125.

Or, 0.125 / 3 = results in 0.042.

Basically, onkeypress, if the key is an equal, get the value, strip the equal, make sure it’s only numbers, period, and a single math operator, and then push it through eval(), then round to 3 or 4 places…

3 Likes

That is a Vectric Product feature

Sure… that’s where I got the idea. It adds tremendous polish for a very small amount of effort.

Hacked out a fiddle so it would be obvious what I expect.
You’d probably want to sanitize the input for the valid range of characters.
https://jsfiddle.net/vxzsc9zp/23/

Enter and Equals both trigger a calculation.

This is a standard feature in many drawing programs — no equal necessary. Freehand even respects order of operations and allows one to use parentheses to control that.

Does and has worked for me in Easel

1 Like

I have had many projects where I wished that Vcarve would allow me to create variables with assigned values (either a constant or an expression). Then when cutting multiples of the same project on different thickness material I could just change one value for thickness and all the other variables would adjust in the toolpaths.

For example if I wanted a pocket to be cut to half the material thickness, I could define the depth for the pocket to be “T/2”, and the profile cut would be at depth “T”

1 Like

@WillAdams how do you trigger calculate if not equals

@BlakeIngramDesign works with the {ENTER} key right now. Thanks. Didn’t realize that. It sure would be nice for it to work with {=} as well.

Maybe they could add it to the documentation… https://inventables.desk.com/?b_id=9566

And maybe some user and seo friendly URLs while they’re at it…