algorithmic modeling for Rhino
Hello, i am new in programming, so i need some help with this.
I managed to get 1 number from Grasshopper with the following code:
____________________________________________
Imports Grasshopper.Kernel
Imports Grasshopper.Kernel.Types
Public Class Class1
Inherits GH_Component
''constructor
Public Sub New()
MyBase.New("SimpleComponent", "SC", "My First GH Component", "Extra", "Demo")
End Sub
Public Overrides ReadOnly Property ComponentGuid As Guid
Get
Return New Guid("80016c7b-a160-4423-b445-a9ce00464833")
End Get
End Property
Protected Overrides Sub RegisterInputParams(pManager As Grasshopper.Kernel.GH_Component.GH_InputParamManager)
pManager.AddNumberParameter("num", "n", "num_parameter", GH_ParamAccess.item)
End Sub
Protected Overrides Sub RegisterOutputParams(pManager As Grasshopper.Kernel.GH_Component.GH_OutputParamManager)
End Sub
Protected Overrides Sub SolveInstance(DA As IGH_DataAccess)
Dim number As Double
DA.GetData(Of Double)(0, number)
MsgBox(number)
End Sub
End Class
____________________________________________
Now i am trying to get a flatten list form Grashopper component, but i don't know how.
I tried changeing GH_ParamAccess.item to GH_ParamAccess.list and store this to array but that didn't work.
Any ideas? Thanks.
Tags:
You'll need to set the parameter access to list as you mentioned, and then you use DA.GetDataList() inside SolveInstance.
--
David Rutten
david@mcneel.com
Tirol, Austria
Thank you, i made some progress, but still i don't get what i want.
I have this list: (16 points with x,y,z coordinates)
With this code i only get 16 values in my list that i can't even relate to coordianates.
______________________________________________________
Protected Overrides Sub SolveInstance(DA As IGH_DataAccess)
Dim list As New List(Of Double) DA.GetDataList(Of Double)(0, list)
For i = 0 To list.Count - 1 MsgBox(list.Item(i)) Next
End Sub
______________________________________________________
I get this 16 numbers:
0.020829
3.00661
3.86903
5.60463
5.60463
3.86903
7.21195
6.71253
3.00661
6.03383
7.09210
3.86903
3.86903
7.09210
8.58844
7.21195
Edit: i see, this numbers are geometric mean. Still, how would i get all my numbers to a list?
-
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
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by