algorithmic modeling for Rhino
so can anyone tell me the method or property to expose the ability to access/launch a user from form right clicking a context option in a component.
Basically, consider the color swatch or the path component. Right clicking the color swatch launches teh interactive color 3d box for selecting color.
Is there a method or property in the grasshopper SDK for this?
Basically I want to be able to launch a form when the user right clicks such a context]]thanks
Tags:
make sure the variables in question are get/set by overridden versions of the Read and Write methods on the component.
Public Class DropDownList
Inherits Grasshopper.Kernel.GH_Component
'Global Variables
Private ListStr As New List(Of String)
Private SelectedItem As String = ""
Public Sub New()
MyBase.New("Dropdown List", "Dropdown", "Right click to select item", "Extra", "Other")
End Sub
Public Overrides ReadOnly Property ComponentGuid As Guid
Get
Return New Guid("xxx")
End Get
End Property
Protected Overrides Sub RegisterInputParams(pManager As GH_InputParamManager)
pManager.AddTextParameter("LStr", "LS", "List of String", GH_ParamAccess.list)
End Sub
Protected Overrides Sub RegisterOutputParams(pManager As GH_OutputParamManager)
pManager.AddTextParameter("Str", "S", "The Selected String", GH_ParamAccess.item)
End Sub
Protected Overrides Sub SolveInstance(DA As IGH_DataAccess)
ListStr.Clear()
If (Not DA.GetDataList(0, ListStr)) Then Return
'If the retrieved data is Nothing, we need to abort.
'We're also going to abort on a zero-length String.
If (ListStr Is Nothing) Then Return
If (ListStr.Count = 0) Then Return
DA.SetData(0, SelectedItem)
End Sub
Public Overrides Function AppendMenuItems(ByVal menu As ToolStripDropDown) As Boolean
menu.Items.Clear()
For i As Integer = 0 To ListStr.Count - 1
Dim str As String = ListStr(i)
Menu_AppendItem(menu, str, AddressOf Menu_MyCustomItemClicked)
Next
'Return True, otherwise the menu won't be shown.
Return True
End Function
Private Sub Menu_MyCustomItemClicked(sender As Object, e As EventArgs)
SelectedItem = sender.ToString
ExpireSolution(True)
End Sub
Public Overrides Function Write(writer As GH_IWriter) As Boolean
writer.SetString("Str", SelectedItem)
Return MyBase.Write(writer)
End Function
End Class
---------------------------------------------------
I am not sure why I need a read method. I have added the Write method but it's not working. Am I getting this wrong?
Thanks!
Hi Qi WU,
Check this link and see if it helps:
http://www.grasshopper3d.com/forum/topics/class-variables?xg_source...
The values need to be saved (Read / Write) with the file. This way when the user opens / closes GH the values are read back in to the file.
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