Numbering tool

Hi all- someone on the Rhino for Mac forum asked about a numbering tool- after a bit of back and forth I cobbled a py script together that seems to do about the right things. Just in case someone finds it useful or wants to make it better, i’ll attach the script here as well as a compiled v5 plug-in which may be easier to use.(drag and drop the rhp file onto Rhino to add the command Numberer. I think usage is pretty self explanatory… shout if not).

numberer.py (4.1 KB)
Numberer.rhp (12 KB)

-Pascal

1 Like

Thanks Pascal,

Great example for commandline options and multiple input structure.

My contribution is to clean up the suffix/prefix stringboxes
( they annoyed me instantly for not accepting an empty string :wink:)

I found the Stringbox returns:
a String-type with value None when hitting enter on an empty box
If it is canceled however it returns a None-type, so I let it check if a String-type is returned



            elif gp.OptionIndex()== opPref:
                prefix = rs.StringBox("Set prefix.", default_value = prefix, title = "Numberer Prefix") 
                if isinstance(prefix, str):
                    sc.sticky["NumPrefix"]= prefix
                        
            elif gp.OptionIndex()== opSuf:
                suffix = rs.StringBox( "Set suffix.", default_value = suffix, title = "Numberer Suffix")
                if isinstance(suffix , str):
                    sc.sticky["NumSuffix"]= suffix


Thanks
-Willem

Thanks Willem!- I’ll tune it up- I misread, I guess, the return code as None in each case and punted with the inelegant solution that bugged you.

-Pascal

Well I never ran into this but saw wjen debugging the difference in return for the 2 situations.

So I learned something new today. :blush:

Hi Willem- ok, I took another look - the problem I was trying to get around with the ‘none’ was that I wanted Cancel not to change the prefix, regardless of what was typed, so with your ‘isinstance’ and one more check, I think it is all covered.

            if prefix is None:
                prefix = sc.sticky["NumPrefix"]
            else:
                 if isinstance(prefix, str):
                    sc.sticky["NumPrefix"] = prefix

Tuned up:

numberer.py (3.9 KB)

Numberer.rhp (11.5 KB)

-Pascal

Ah yes, my oversight.
To spare your recovering arm some typing this is how I’d get around that with 2 lines less:

                new_prefix = rs.StringB...
                if isinstance(new_prefix, str):
                    sc.sticky["NumPrefix"] = new_prefix

-Willem

yep, better , thanks.

-Pascal

Added some text settings, though not the font, yet.

Numberer.rhp (17 KB)

numberer.py (7.8 KB)

UPDATE: Now you can set the font- I think it works ok…

numberer.py (9.5 KB)

Numberer.rhp (19 KB)

UPDATE: you can now just type in a number to reset the current number. That was bugging me every time I used the thing.

numberer.py (9.7 KB)

Numberer.rhp (19.5 KB)

This does get in the way of setting a point at the origin using ‘0’ but I think it is worth it.

-Pascal

2 Likes