Grasshopper

algorithmic modeling for Rhino

Locally defined value not inherited from windows form Dialogue.OK

The following code seems to work fine, except that it does not commit changes to the custom component when I click apply (dialogue.ok).

What is happening is, when I input data into the Windows Form, the data seems to be stored in the "Set Data" field of the component pull down menu. Data does not appear as a locally defined value until I select 'Commit Changes'.

Is it possible to eliminate this 'Commit Changes' step?

Public Sub ShowForm()
Dim param As Param_Number = DirectCast(Params.Input(1), Param_Number)
Dim value As Double = 0.0
If (param.PersistentDataCount > 0) Then
value = param.PersistentData.FirstItem(True).Value
End If

Dim myForm As New Form1
myForm.TextBox1.Text = value.ToString()

If (myForm.ShowDialog() = DialogResult.OK) Then
If (GH_Convert.ToDouble(myForm.TextBox1.Text, value, GH_Conversion.Both)) Then
RecordUndoEvent("Focal Point Horiz Dist")
param.PersistentData.Clear()
param.PersistentData.Append(New GH_Number(value))
ExpireSolution(True)
End If
End If
End Sub

Public Overrides Sub AppendAdditionalMenuItems(menu As Windows.Forms.ToolStripDropDown)
MyBase.AppendAdditionalMenuItems(menu)
Menu_AppendGenericMenuItem(menu, "Tiered Seating Settings", AddressOf Menu_MyCustomItemClicked)
End Sub

Private Sub Menu_MyCustomItemClicked(ByVal sender As Object, ByVal e As EventArgs)
ShowForm()
End Sub

Views: 544

Attachments:

Replies to This Discussion

I think the mistake was this:

ExpireSolution(True)

 

It should probably be called on the input parameter. Components do not expire their inputs anymore, only their outputs. Try:

 

param.ExpireSolution(True)

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Thanks so much, that was it.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service