I’m working on a script to find and replace text throughout a document (we do all of our shop drawings in Rhino, so if a material spec changes, that could mean sifting through 40+ pages of layouts to make the revisions.)
I have the base functionality sorted out, and am now trying to make the script a little more robust. Part of that is allowing the user to enter a String in the command line, or simply selecting the text object they’d like to replace.
I know how to do each of these individually, but is there any way to combine these into a single command prompt? i.e.
“Enter text, or select text object?”
i know i could do this with an additional prompt level (“1 to enter text, or 2 to select text object.”), but wondering if it could be more streamlined for the user.
I figured I would be able to do this through RhinoCommon, but I’m new to python and not yet sure of the RhinoCommon Python relationship and syntax. I’ll try plugging this into my script and let you know how it works. I’ll post the script/plugin once it’s ready as well.
IMO RhinoCommon input classes are not so easy to use and understand at first, but are very powerful
and let you customize user input as you like.
You can find better samples here:
About RhinoCommon and Python in general, I am no expert, but as far as I understand it’s just object oriented Python.
RhinoCommon is a collection on Python classes. Once you are comfortable with Python classes, you can use RhinoCommon without problems … well, except maybe for its not so good documentation …
Well, I’ve got this integrated into my script beautifully except for one thing. I can’t figure out how to ,make rhino accept ‘space’ as a valid character. Say i want to replace the text “two words”. as soon as i hit the space bar, it moves on to the next step in the script. i know i can enter the command in quotes to avoid this, but i’d rather not force the user into that situation, as i think it will cause confusion.
Yeah, i’m trying to avoid having to convey that to the user, as it’s not really intuitive. I’m looking for a way to make spaces work via something along the lines of AcceptLiteralString(), while maintaining the ability to select an object.