Grasshopper

algorithmic modeling for Rhino

Hi, Everyone.....

Is there any function like the Main()(the entrace of the software) function in the software of  Grasshopper plugin? or some function run when the gh file loaded?

ThankYou.

Views: 557

Replies to This Discussion

Only standalone application have a Main method. I don't understand what you mean by "some function run when the gh file loaded". Obviously, yes. There's a whole bunch of functions that are needed to open, parse, deserialize and load a gh file, but none of them are particularly interesting to anyone except me.

Are you asking about events that are raised when a GH file loads?

Oh sorry, I'm think you are right David.

Is there any such event to be araised when a GH file loads?

The following events may be useful:

  1. Grasshopper.Instances.DocumentServer.DocumentAdded
  2. Grasshopper.Instances.Canvas.DocumentChanged

The first one is raised when a new document is added to the central list (note: there may be cases where documents are constructed anew or loaded from file outside of the DocumentServer's knowledge).

The second one is raised when a new document becomes active within the Grasshopper canvas, either because it was opened, or because it was switched to.

Also note that both the Canvas and the DocumentServer may be constructed after the gha plugins are loaded, so there's no guarantee that you can register these events during plugin load.

ThanyYou David.
But I Actually don't where to place the event register code of My GHA file.

Sorry. I have got it ,write in the ***info.cs file
,ThankYou

It doesn't matter where the code is that handles these events, the only thing that matters is when you register the handlers. You can only do so after the DocumentServer and or the Canvas have been constructed.

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