Hi @Samuel_Dwyer,
usually you would add an event watcher which looks if a command has started or ended and write a function which is called before or after that command. This works for many commands, eg. below example prints something after the _Line command completed:
import Rhino
import scriptcontext
import rhinoscriptsyntax as rs
def MyEndCommandEvent(sender, e):
if e.CommandEnglishName == "Line":
print "You ended the Line command: ", e.CommandResult
def DoSomething():
key = "MyEndCommandEvent"
if scriptcontext.sticky.has_key(key):
print "Event removed"
Rhino.Commands.Command.EndCommand -= scriptcontext.sticky[key]
scriptcontext.sticky.Remove(key)
else:
print "Event added"
scriptcontext.sticky[key] = eval(key)
Rhino.Commands.Command.EndCommand += eval(key)
if __name__=="__main__":
DoSomething()
The command _BlockEdit
however is a special case where a dialog opens and stays modeless, which means a user can still interact with Rhino. I think, modeless dialogs have no return value so Rhino thinks the command ended right after the dialog is shown.
There is a hidden command however which ends after _BlockEdit
ended which you could use instead in the event function:
def MyEndCommandEvent(sender, e):
if e.CommandEnglishName == "BlockEditApplyInPlaceEditItemChanges":
print "You ended the BlockEdit command: ", e.CommandResult
Here is more information about the same problem.
@dale, i think this is a bug or at least a limitation, if you eg. try to wait for the completion of the BlockEdit command using a macro like this:
! _-BlockEdit _MultiPause _SelBlockInstance
it should select the edited block after the command has completed, however, the command is not paused. It immediately prints this to the command line:
Command: _SelBlockInstance
No objects added to selection.
Is there some room for improvement ?
_
c.