Grasshopper

algorithmic modeling for Rhino

After having a great time with the basic functions of Grasshopper, over the last few weeks I've been dipping in to VB scripting for more complex applications.

I'm finding the hardest part is finding the right commands for various functions. I've trawled the SDK helpfile and have found intersection code for spheres and lines:

OnUtil.ON_Intersect(Line, sphere0, point0, point1)

as well as spheres and spheres, but can't track down the right code for intersecting a sphere with a surface to produce a curve as per the 'intersect' command in Rhino:

Curve>Curve From Objects>Intersection

Is this impossible, or have I missed something?

All help gratefully appreciated!

Views: 665

Replies to This Discussion

James, if you're creating spheres from within the VB component, you need to get the Nurbs form of the Sphere before creating a intersection. Try this:


Dim tol As Double = doc.AbsoluteTolerance()
Dim cenPt As New On3dPoint(0, 0, 0)

Dim tSphere As New OnSphere
Dim rad As Double = 5.0
tSphere.Create(cenPt, rad)

Dim nSphere As New OnNurbsSurface
tSphere.GetNurbForm(nSphere)

Dim tSrf As New OnNurbsSurface
Dim ptList As New List (Of On3dPoint)
ptList.Add(New On3dPoint(-5, -5, 0))
ptList.Add(New On3dPoint(-5, 5, 0))
ptList.Add(New On3dPoint(5, 5, 0))
ptList.Add(New On3dPoint(5, -5, 0))
tSrf = RhUtil.RhinoCreateSurfaceFromCorners(ptList(0), ptList(1), ptList(2), ptList(3))

Dim arrCrv(0) As OnCurve
RHUtil.RhinoIntersectSurfaces(nSphere, tSrf, tol, arrCrv, Nothing)

A = arrCrv
Thanks Dirk, I'll play with this a bit more and see how I get on.

Many thanks for replying!

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