Papercut - Copying decimal numbers from command line

Hi All :slight_smile:
There’s a thing that’s been bothering me since forever: If I need a decimal number from the command line, copying it requires me to carefully click’n’drag to get both the integral and decimal part of the number; a hazzle especially on hi-res screens. If I dbl-click, only the integral or decimal part (depending on the pointer position) is selected. It’s probably a windows thing, so it’s probably not something that’s easily changed, but it would be nice if numbers from the command prompt would select decimal numbers in their entirety.
A small work-around is dbl-clicking eg. the integral part, then hold down Shift and just click the decimal part, which will then select the whole number (point included), but it’s still not as smooth as just dbl-clicking and getting the whole number.
Or does anyone have an even niftier way of getting numbers from prompt to clip board?
Regards, Jakob

1 Like

It can probably be scripted. Can you give an example how the command history looks when you are trying to copy the number?
I recall @clement had a script a while back that read back the command history. I’ll see if I can find it.

1 Like

Hi @Gijs
I thought of that too, but I guess that the scenarios are probably too random. It’s usually from commands like Length, Volume or Area, and it’s just something I need every once in a while. I was just wondering, if there was a way to get the numbers on both sides of the decimal point without resorting to scripting it for every single analyze command. It’s not a big thing, but if there’s a script floating around, maybe I can hack/customize it to fit my needs :slight_smile:
-Jakob

EDIT: Just found this :joy: It’s obviously something that’s bothered me at least since March '23!

should be possible with some regex

This seems to work after running Length, Area and Distance (with some quick chat GPT help for the regex)

import Rhino
import re

text = Rhino.RhinoApp.CommandHistoryWindowText
lines = text.splitlines()
target = lines[-6]
# Use regex to find the number
match = re.search(r"(\d+(\.\d+)?)", target)

if match:
    number = float(match.group(1))  # Convert to float
    print(number)

Edit:
the attached script should work in Rhino 8 when run from a button (copies the number to clipboard)

-_ScriptEditor _Run "path\to\script.py"

copynumber.py (341 Bytes)

2 Likes

Hi @Gijs
Thanks a lot! Seems to work perfectly :+1:
-Jakob

OK, so here’s a Rhino script (also with some (OK, a lot of) help from ChatGPT) that will detect if it’s a curve, surface or solid and will copy either length (for curve), area (for surface) or volume (for solid) to the clipboard.
Get length area volume.rvb (2.4 KB)
-Jakob

nice :slight_smile:

and in no time converted to python 3. With this you don’t need temp files (and it will work on Mac):

CurveInfo2.py (23.6 KB)

1 Like

Nice! :slight_smile:

well, theoretically :grimacing: