algorithmic modeling for Rhino
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
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by