Hi Dima,
the first 4 items are warnings and it should work even with those. The
"blah blah is passed by reference and null exception could occur"
warning happens when you feed variables into a function (such as
RhinoCurveBrepIntersect) that haven't been initialized yet.
If you replace: Dim points As On3dPointArray
with: Dim points As On3dPointArray = Nothing
the warning will go away.
The exception is thrown at runtime, not compile. That means that your
script was compiled successfully (albeit with a couple of warnings),
but an error occured while it was running.
The error "Index was out of range" happens when you are accessing a
non-existing element in an array or list.
I notices that your inner loop goes from zero to the number of curves:
For i As int32=0 To Crvs_top_surface.count
This is not correct. If you Crvs_top_surface list contains 10 items,
the valid indices are:
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
And you loop should go from 0 to 9, not from 0 to 10. Thus:
For i As int32=0 To (Crvs_top_surface.count - 1)
In RhinoScript you are probably used to making loops go from zero to
the UBound. But note that the UBound of an array is the Count minus
one.
--
David Rutten
[email protected]
Robert McNeel & Associates
On Feb 19, 3:34 pm, "[email protected]"
<[email protected]> wrote:
> hi David,
>
> thank you a lot! and sorry for my English.
>
> I'm trying to make the intersection points of,
> the two lines that intersected by a cylinder,
> and check the distance between them for adding lines.
>
> but I got just the
> warnings(http://groups.google.com/group/grasshopper3d/web/warning_Dima.jpg
> )
>
> Dim pts As New List(Of On3dPoint)
> Dim pts_B As New List(Of On3dPoint)
>
> For Each cyl As OnBRep In cylinders
>
> For i As int32=0 To Crvs_top_surface.count
>
> '______top pts
> Dim points As On3dPointArray
> Dim overlaps As OnCurve()
> If (Not RhUtil.RhinoCurveBrepIntersect(Crvs_top_surface.item
> (i), cyl, 0.001, overlaps, points)) Then Continue For
> If (points.Count() = 0) Then Continue For
>
> For Each pt As on3dpoint In points
> pts.Add(pt)
> Next
>
> '____bottom pts
> Dim points_B As On3dPointArray
> Dim overlaps_B As OnCurve()
> If (Not RhUtil.RhinoCurveBrepIntersect(Crvs_bottom_surface.item
> (i), cyl, 0.001, overlaps_B, points_B)) Then Continue For
> If (points_B.Count() = 0) Then Continue For
>
> For Each pt_B As on3dpoint In points_B
> pts_B.Add(pt_B)
> Next
>
> Next i
>
> Next
>
> A = pts
> B = pts_B