Grasshopper

algorithmic modeling for Rhino

Dear All,

I am trying to find curve-curve intersections between two sets of curves (here called "ZoneCrvs" and "BldgCrvs").  I would like to keep track of the outputs in a VB script, but I am having trouble managing the 1-dimensional arrays that are output by RhUtil.RhinoCurveBooleanIntersection.  The script below produces the error: 'Count' is not a member of 'System.Array'.  When I use "Length" instead of "Count" I get: 'Object reference not set to an instance of the object' for the same line of code.  Any advice?

Thanks,

Jon


Dim XCrvs As List(Of OnCurve)

    For i As Integer = 0 To ZoneCrvs.Count() - 1

      For k As Integer = 0 To BldgCrvs.Count() - 1

        Dim CCX() As OnCurve = RhUtil.RhinoCurveBooleanIntersection(ZoneCrvs(i), BldgCrvs(k))

        For j As Integer = 0 To CCX.Count - 1

          XCrvs.Add(CCX(j))

        Next

      Next

    Next

Views: 198

Replies to This Discussion

Hi Jon,

I've continued the script following the spirit you started with. I also translated it in C#, in case you or someone else is interested.

VB If ZoneCrvs Is Nothing OrElse BldgCrvs Is Nothing Then Return

Dim XCrvs As New List(Of OnCurve)
For i As Integer = 0 To ZoneCrvs.Count() - 1
For k As Integer = 0 To BldgCrvs.Count() - 1

If ZoneCrvs(i) Is Nothing OrElse BldgCrvs(k) Is Nothing Then Continue For

Dim CCX As OnCurve() = RhUtil.RhinoCurveBooleanIntersection(ZoneCrvs(i), BldgCrvs(k))

If CCX IsNot Nothing Then
For j As Integer = 0 To CCX.Length - 1 'Could be also Ubound(CCX)
XCrvs.Add(CCX(j))
Next
End If

Next
Next

A = XCrvs


C# if (ZoneCrvs == null || BldgCrvs == null) return;

List XCrvs = new List();
foreach (OnCurve oneZoneCrv in ZoneCrvs)
{
foreach (OnCurve oneBldgCrv in BldgCrvs)
{
if(oneZoneCrv == null || oneBldgCrv == null) continue;

OnCurve[] CCX = RhUtil.RhinoCurveBooleanIntersection(oneZoneCrv, oneBldgCrv);

if(CCX != null)
for (int j = 0; j < CCX.Length; j++)
XCrvs.Add(CCX[j]);
}
}

A = XCrvs;


Please note the new keyword to allocate memory for the list.
(Formatting will be better in the attached file).
I hope it helps,

- Giulio
_________________
giulio@mcneel.com
McNeel Europe, Barcelona
Attachments:
Works great. Thanks, Guilio!

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