Function Arugments

#1

Hello.

I am trying to understand what the function argument (sender,e) does and what other function arguments there are? Example is “def MyFunction (sender,e):”. I know this one currently will execute upon saving, but I want to know what other arguments would do.

Thanks,
Martin

(Menno Deij - van Rijswijk) #2

What you are looking at are functions that can be subscribed to events. These usually have the form of def MyFunction(<object> sender, <event-args> e). One such event is “saving”, and that means that your function, when subscribed to the “save” event, will get called every time a save is perfomed.

You cannot use other arguments, because if you would, the event subscription will not work. Events like these have a fixed function signature.

#3

Thank you! I greatly appreciate that explanation.

What other event arguments are there? I must be searching for them poorly, because I am not getting much results.

I have a code that I realized is not executing when a new file is initially saved. For example, I open a new instance of Rhino and if I save it as a new file, then the command will not execute. It will execute with every save after this. I am wondering if there is an event argument that can handle this.

Appreciate your time!

Martin

#4

I believe I have it figured out by using the CloseDocument event. Thanks!