Grasshopper

algorithmic modeling for Rhino

Hello.

I wonder if there is a way to execute a piece of API code as soon as Grasshopper has just finished initializing? (Normally GH developers put code in a GH_Component subclass which is only executed if the class is instantiated). Also, is there any public event that is invoked when GrasshopperUnloadPlugin is executed? Thanks

Views: 466

Replies to This Discussion

You can create a class which derives from the GH_AssemblyPriority class. Every public class in your assembly which inherits from this class and which has a blank constructor will be instantiated and executed just before the remainder of your GHA is loaded. It was originally designed to give GHA developers a way to prevent their GHA form being loaded (missing license data, expired trial, etc.).

There are no events associated with the end-of-loading or unloading of Grasshopper, however you can watch for the regular Rhino.Commands.Command.EndCommand event to see whether the command that just ran was "Grasshopper" or "GrasshopperUnload".

Normally GH developers put code in a GH_Component subclass which is only executed if the class is instantiated.

Every component btw. IS instantiated during Grasshopper loading. It just isn't run, but the Category, Subcategory, Name, Description, Icon and Exposure are harvested during load.

Thanks guys. Very helpful. I will try out what you suggested today. Especially the GH_AssemblyPriority. :)

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service