Grasshopper

algorithmic modeling for Rhino

I have some problems putting list like inputs inside Microsoft Visual Studio 2010 plugin I'm coding. If I put the code inside a VB component inside GH and say to it that curve inputs are a list, the code works perfectly.

 

If I construct the necessary code inside a MSV2010 plugin I can't make the input work properly. This is the solveinstance code:

 

[...]

Dim i As Integer

Dim j As Integer

Dim pt_list As New List(Of Rhino.Geometry.Point3d)       

For i = 0 To lines.Count - 1           

  Dim param() As Double           

  param = lines(i).DivideByCount(div, False)           

      For j = 0 To param.Length - 1               

      pt_list.Add(lines(i).PointAt(param(j)))                        

  Next       

Next

        DA.SetDataList(0, pt_list)

[...]

 

How could I "declare" inputs with DA.GetData without get cast error saying: line >> List'1. I've tryied with DA.GetDataList but GH says to me that I can't use that, instead I must use DA.GetData.

 

Best Regards.

 

Views: 479

Replies to This Discussion

And this is the code I'm trying to make work with DA.GetDataList:

 

'Declaración de las variables inputs       

Dim crv_1 As New List(Of Rhino.Geometry.Curve)       

Dim div As Integer = vbNull       

crv_1.Clear()

'Condiciones para el fallo del componente       

If (Not DA.GetDataList(Of Rhino.Geometry.Curve)(0, (crv_1))) Then Return       

If (Not DA.GetData(1, div)) Then Return       

If (crv_1.Count = 0) Then Return       

If (div = vbNull) Then Return       


'Dividiento las curvas por puntos (exceptuando los extremos).       

Dim pt_list As New List(Of Rhino.Geometry.Point3d)       

For i As Integer = 0 To crv_1.Count - 1           

Dim param() As Double           

param = crv_1(i).DivideByCount(div, False)           

For j As Integer = 0 To param.Length - 1               

     pt_list.Add(crv_1(i).PointAt(param(j)))               

Next       

Next

DA.SetDataList(0, pt_list)

Hi Angel,

 

if you want to use GetDataList, you need to use "GH_ParamAccess.list" in the RegisterInputParams subroutine, in the same class.

Protected Overrides Sub RegisterInputParams(pManager As _
GH_Component.GH_InputParamManager)
pManager.Register_CurveParam("Curves", "C", "The curves group", _
GH_ParamAccess.list)

GetData(Of T)(Integer, byRef T) accepts a single element (no lists)

 - Giulio

___________
giulio@mcneel.com
McNeel Europe

Thanks!!! That was what I was looking for :)

 

Looking in SPM code, I've found "GH_ParamAcces.list". I pass over it.

Hi Ángel,

 

Giulio wrote the same answer I was going to give you, I hope you're ok now!

 

Cheers,

Chris

I'm ok :) Thanks for read this too.

I've post a question in SPM Vector componet group because I'm ussing Reflector to view some code inside some plugins. Geco gives me some errors reading SolveInstance but SPM works fine. GH components are very well coded and condensed, not very friendly to someone is learning.

 

http://www.grasshopper3d.com/group/spmvectorcomponents/forum/topics...

 

 

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service