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).
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 )
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
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