Grasshopper

algorithmic modeling for Rhino

Hi,

I would like to log some data from a custom component when the Grasshopper document is closed. I was hoping to find something in the line of OnDocumentClosed.

Any thoughts on how to do this? Your help is appreciated.

Thank you!

Ana

Views: 378

Replies to This Discussion

Try the GH_Document.ContextChanged event.

Thanks, David, that worked!

This works but,

Private Sub RunScript(ByVal x As Object, ByVal y As Object, ByRef A As Object)

DocServer = instances.DocumentServer
End Sub

'<Custom additional code>

WithEvents DocServer As gh_documentServer

Private Sub OnClosed() Handles DocServer.DocumentRemoved
rhinoapp.writeline("BAM")
End Sub

But there must be better ways. Also, you can add the class GH_AssemblyPriority to create an event when grasshopper read the assembly, which occurs when a document is closed. But you have to destroy it at some time. For example, in this case ocurrs when a canvas is created:

Public Class Yiiiiihaaaa

Inherits Grasshopper.Kernel.GH_AssemblyPriority

Public Overrides Function PriorityLoad() As GH_LoadingInstruction

AddHandler Instances.CanvasCreated, AddressOf SomeMethod

Return GH_LoadingInstruction.Proceed
End Function

Private Sub SomeMethod(canvas As GH_Canvas)

RemoveHandler Instances.CanvasCreated, AddressOf SomeMethod

'Do something.
End Sub

End Class

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service