Grasshopper

algorithmic modeling for Rhino

Hi David:

I have tried these codes in C#:

 

private void RunScript(Curve x, Curve y, ref object A)
{
    Rhino.Geometry.Intersect.CurveIntersections ci;
    ci = Rhino.Geometry.Intersect.Intersection.CurveCurve(x, y, 0.001, 0.001);
    A = ci.Item[0].PointA;
}

 

Got the Error:

 

'Rhino.Geometry.Intersect.CurveIntersection' does not contain a definition for 'Item'

 

But in VB.Net:

 

Private Sub RunScript(ByVal x As Curve, ByVal y As Curve, ByRef A As Object)

    Dim ci As  Rhino.Geometry.Intersect.CurveIntersections
    ci = Rhino.Geometry.Intersect.Intersection.CurveCurve(x, y, 0.001, 0.001)
    A = ci.Item(0).PointA
End Sub

 

It works well!

Why? Is C# an incomplete version?

 

Thank you for your time!

 

 

Views: 1910

Replies to This Discussion

Hi Jilin,

RhinoCommon is written in C#, so that version is complete. (Just as the Vb.Net access to it should be.) Item() is another name to the main property of a class:

C#
A = c[0].PointA;

Vb.NET
A = c(0).PointA

...should work. This is shown here.

- Giulio
_____________________
giulio@mcneel.com
McNeel Europe, Barcelona
Oh! Thanks a lot! This really confused me for a long time! I should read the SDK carefully!
Hi Giulio, If there were more intersection between the curves, is there a simpler way to do this:

ci = Rhino.Geometry.Intersect.Intersection.CurveCurve(x, y, 0.001, 0.001);

Rhino.Geometry.Point3d[] intPts = new Rhino.Geometry.Point3d[ci.Count];

for (int i = 0; i < ci.Count; i++)
{
intPts[i] = ci[i].PointA;
}

A = intPts;>

Cheers, Evert

PS the > at the end comes from the formating thing in the forum.
BTW how do you enter code in these posts?
I've just noticed the formatting thing got rid of my first line of code!

Rhino.Geometry.Intersect.CurveIntersections ci;
Hi Evert,

the only thing I can see to shorten the code is to remove the curly brackets {},
that's ok for a single statement. :)

for (int i = 0; i < ci.Count; i++)
  intPts[i] = ci[i].PointA;


About formatting: you can use HTML character references to put special chars. For example, &gt; will appear as >.

You can have a code block with <code> ... </code>:this is how it will appear.

I hope it helps,

- Giulio
_____________________
giulio@mcneel.com
McNeel Europe, Barcelona
Hi Giulio, Thanks.

Testing!

testing!!!!!!

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service