algorithmic modeling for Rhino
Testing this David's VB.net script for visualizing thickness in viewport, but don´t work inside clusters. Is it because of the change of display of the Current GHDocument?
Private Sub RunScript(ByVal curves As List(Of Curve), ByVal colours As List(Of Color), ByVal widths As List(Of Integer), ByRef A As Object)
'Destroy the currently active display object
If (m_display IsNot Nothing) Then
m_display.Dispose()
m_display = Nothing
End If
'Abort on no valid input
If (curves Is Nothing) Then Return
If (curves.Count = 0) Then Return
If (colours.Count = 0) Then colours.Add(Color.Black)
If (widths.Count = 0) Then widths.Add(1)
'Create a new display object
Dim display As New Rhino.Display.CustomDisplay(True)
Dim count As Int32 = 0
'Iterate over all curves and create new display data
For i As Int32 = 0 To curves.Count - 1
If (curves Is Nothing) Then Continue For
Dim iColour As Int32 = Math.Min(i, colours.Count - 1)
Dim iWidth As Int32 = Math.Min(i, widths.Count - 1)
If (widths(iWidth) <= 0) Then Continue For
display.AddCurve(curves(i), colours(iColour), widths(iWidth))
count += 1
Next
If (count = 0) Then
display.Dispose()
display = Nothing
Else
RegisterDocumentEvents()
m_display = display
End If
End Sub
'<Custom additional code>
Private m_display As Rhino.Display.CustomDisplay
Private Sub RegisterDocumentEvents()
UnregisterDocumentEvents()
Dim document As GH_Document = owner.OnPingDocument()
If (document Is Nothing) Then Return
AddHandler document.EnabledChanged, AddressOf EnabledChanged
End Sub
Private Sub UnregisterDocumentEvents()
Dim document As GH_Document = owner.OnPingDocument()
If (document Is Nothing) Then Return
RemoveHandler document.EnabledChanged, AddressOf EnabledChanged
End Sub
Private Sub EnabledChanged(ByVal sender As Object, ByVal e As GH_DocEnabledEventArgs)
If (m_display IsNot Nothing) Then
m_display.Enabled = e.Enabled
End If
End Sub
Tags:
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by