🔢 Basic Math and Special chars in VCB - Proposal

I have heard whispers of maths that include not only numbers and symbols, but letters as well, but have done my best to avoid them so as to be able to sleep at night.

I think that adding basic functionality (+, -, *, /) would satisfy most if not all basic input… SketchUp will likely never replace a graphing calculator, but I feel that the basics would be an amazing way to start!

5 Likes

What @TheOnlyAaron said ^^^

Nothing like 0.75*(31^3-17^2+599)+sqrt(17)

(=22579.8731056)

Just expanding the basic functionality of some of the tools in changing geometry.

1 Like

I think it will be a useful evolution if the VCB could allow any characters after the first character when it is a digit or a special character like (+*-/=@#?’ etc…, so that full formulas and units are allowed for input.

Currently, only some non-digit are allowed, and shortcuts are not disabled, so that depending on your shortcut assignments, some characters would go to the VCB or trigger a shortcut (see this post).

Possibly, a gold key could be agreed (say = or @) that would popup a window with more capabilities to enter formula, including with variables, math functions, etc…. Scripts could design their own dialog. (Note: this cannot be done currently, because the API onKeyDown returns char codes, not a character).

3 Likes

key.chr will return the corresponding character, no ?
That’s what I use to capture the “X” character here.

Unfortunately, mixing all the operators is not as simple as it seems if the result is to be a length.

Currently when a user type 123, this value is converted to 123u, where u is the model length unit.

Adding (+) or subtracting (-) one length from another is not a problem. However, multiplying (*) and dividing (/) is. For both operations, one of the two operand is no longer a length, but a factor.

But where is the factor and where is the length in 100*2 ?

10”/2 if model unit is millimeters, for example will be computed as 10” / 2mm, Which is not the expected result.

`onKeyDown

For instance, if you type a question mark (?) on a regular US Qwerty keyboard, you get 2 keys events:

Key Down 16
Key Down 191

If you try to ‘parse’ the keyboard code (first one is a Shift, second is a slash /)

16.chr

=> "\x10"

191.chr

=> "\xBF"

So, not easy to find out that one charcater was typed and is ?

Here is another example with key ‘+’ on a main Qwerty keyboard

Key Down 16
Key Down 187
16.chr
=> "\x10"
187.chr
=> "\xBB"

Oh, SHIFT key code is 16 on US Query Keyboard :flushed_face: ?

onKeydown and onKeyUp returns virtual keys, not ascii or Unicode value. So this depends on the operating system, the language of the keyboard and maybe other parameters of the computer environment.

Thereseems to be no Ruby method to perform the translation of a sequence of virtual keys to a regular character

I answered to myself. Finally, I found a solution and I did it.
I’ve integrated basic arithmetic operations into OpenCutList tools.

For those curious, you can test it on the DEV version :+1:

You can mix units, use multiple parenthesis, minus and place the @ character where ever you want in the expression.

Enregistrement de l’écran 2025-10-19 à 20.28.58-GIF 720x720 15 ips

Enregistrement de l’écran 2025-10-19 à 20.33.28-GIF 720x720 15 ips

My biggest nightmare was to try to handle correctly the multiple way to write dimension in fractional … :roll_eyes:

4 Likes

I was inspired by this thread by Boris so I tried my hand at incorporating one of the suggestions to copy measurements with a “MathBox” extension. Similar functionality to what’s shown above but I added memory slots. So, memory slots are stored to as: $1=, $2=, $3’, etc. Then those can be used in expressions in the VCB. For example, @+$1

MathBox

Not sure $ is the way to go but it avoids shortcut keys.

1 Like

The “@.” symbol may also refer to the name of a parameter in the ascending hierarchy, this would save the tedious work of redefining the parameter in all descending levels (xxx= Parent!xxx)

342 / 5.000

Still based on Justin’s video, which advocates for more modeling tools, wouldn’t it be time to define a parameter type for angle? When editing a component by selecting two edges, it would be possible to define the angle between them using this new parameter type. This parameter type is native to REVIT and is very useful.

You’re talking about more of an angle tool? Would this be different than the protractor tool?

The protractor simply measures. My intention is to define the measurement between two edges as a parameter so that when the component is stretched, the angle between those two edges is preserved. Currently, the possibilities for creating parameters are limited to decimal numbers, text, and length. Mr. Aaron showed us how to make a picture frame. Sensational. But if it were possible to define a 45-degree angle between the frame edges, everything would be much simpler and more intuitive. REVIT users often use this approach to create parametric roof trusses, among other things.