Grasshopper

algorithmic modeling for Rhino

Dear,,,,.

 

I want to use windows form with Grasshopper... to use many buttons and picturebox to show simulation results using data from grasshopper.

But,...it is not so easy for me. of course it is hard to find example...

I do not know how to load windows form and send data to object in form.vb...using grasshopper sdk.

 

it is the same,, when I try to use dll(class) with VB component in grasshopper.

 

may be I have to make two class (class1, form1) but,

when I send data to class1, form1 can not receive class1 data because form 1 made new class1 and both class1, class1(from form1) is different session?

 

for novice programer,, for me it is very hard.

 

load class1,

class1 load form1

send data from grasshopper to form1. x

and button click

couldn't calculated,... result was always "0"

 

and tried many other methods,, but it failed...

may be some known technic but it is hard to find books...

 

Please...help me.

if possible would you tell me how to load form1 using grasshopper sdk and ""send data "" to form1

or form1 could use data from grasshopper?

 

Thank you....

 

for ex)

 

'(in class.vb)

 

Public Class Class1
    Private Shared fl As Form1
    Public Sub fload()
        If fl Is Nothing Then
            fl = New Form1
            fl.Show()
        End If
       
    End Sub
End Class

 

'(in form1.vb)

Public Class Form1
    Public x, y As Double
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        ab(x, y)
        MsgBox("hi" & y)
    End Sub
    Sub ab(ByRef a As Double, ByRef b As Double)
        b = a * 2
    End Sub
End Class

 

'(in Grasshopper VB.component)

Dim cl As ClassLibrary1.Class1
    If cl Is Nothing And f = True Then
      cl = New Class1
      cl.fload()
    End If
    Dim fr As ClassLibrary1.Form1
    If fr Is Nothing Then
      fr = New Form1
    End If
    fr.x = x
    a = fr.y

Views: 260

Replies to This Discussion

Hi Daniel,

are you making a form from scratch in your code, or are you doing this from within Visual Studio?

--
David Rutten
david@mcneel.com
Seattle, WA
Dear, David
I use Visual Studio 2010 and
attached sample file using Grasshopper SDK.
Dear, David,,

I attached sample file,
Visual Studio 2010 files.
Attachments:
I attached your project with a few changes.

I moved the zz and Form1 fields into the SolveInstance function. There was no need to have them be class-level variables. I also changed the contents of Form1, so communication between the component and the form now happens via Properties instead of poking variables directly.

I'm also using some Grasshopper functions to position the form in a good spot, format and interpret numbers and strings.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Attachments:
Thank you, David...

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service