I don’t know the words for what to search for here, but where can I find documentation for what can go into a button?
Like _Enter and _Pause for example.
Plus, some people write a dash (-), or an exclamation mark (!) or an apostrophe (’) before commands and I’m guessing these do different things, but what?
I’m also curious to know, if you put for example SelCaptives in a button, is there some way to check if anything actually got selected?
Finally, if you put a lot of commands in a button, is there any way to group them so that an Undo works to undo everything in that button, instead of having to step through each part?
These macros (that’s what they are usually called) simply allow you to set a sequence of Rhino commandline commands to a single button. These commands are executed as if they were typed in the command prompt.
All available (standard) rhino commands can be found here and the accompanying documentation here.
If anything is selected the command prompt usually tells you how many objects and of which type.
So, can you type Python script straight into a button, without referencing a .py file?
The documentation for that is probably vast, so do you know of a tutorial anywhere for doing simple things like checking what is currently selected, and then executing a command, for example?
Yes but it is much easier to type _EditPythonScript, write your file, save it and then put RunPythonScript + Filename in a button to run your script. The editor is limited but has some integrated help and autocomplete. You can copy your script into a button once you are happy with it, if you like.
Vast, well paced, readable. It is worth the effort to read it and things which seem like distractions from getting things done are actually there to help you learn the essentials more quickly.
No but here is a simple sample, for example:
import rhinoscriptsyntax as rs
my_objects = rs.SelectedObjects()
rs.UnselectAllObjects()
for object in my_objects:
if rs.IsText(object):
rs.SelectObject(object)
rs.Command('_Delete')
else:
print("not text")
_NoEcho ! -_RunPythonScript (
<whole script in here>
)
The ! cancels any running command before running the script. The _NoEcho goes in front of the ! otherwise you will also see NoEcho printed to the command line every time.