| 
 | 
 
Public Overrides Function RunCommand(ByVal context As RMA.Rhino.IRhinoCommandContext) _ 
    As RMA.Rhino.IRhinoCommand.result 
    ' Select two curves to intersect 
    Dim go As New MRhinoGetObject() 
    go.SetCommandPrompt("Select two curves") 
    go.SetGeometryFilter(IRhinoGetObject.GEOMETRY_TYPE_FILTER.curve_object) 
    go.GetObjects(2, 2) 
    If (go.CommandResult() <> IRhinoCommand.result.success) Then 
      Return go.CommandResult() 
    End If 
 
 
    ' Validate input 
    Dim curveA As IOnCurve = go.Object(0).Curve() 
    Dim curveB As IOnCurve = go.Object(1).Curve() 
    If (curveA Is Nothing Or curveB Is Nothing) Then 
      Return IRhinoCommand.result.failure 
    End If 
 
 
    ' Calculate the intersection 
    Dim intersection_tolerance As Double = 0.001 
    Dim overlap_tolerance As Double = 0.0 
    Dim xEvents As New ArrayOnX_EVENT() 
    Dim count As Integer = curveA.IntersectCurve(curveB, xEvents, intersection_tolerance, _ 
                                                 overlap_tolerance) 
 
 
    ' ON_EPSILON will be added to future builds of the SDK 
    ' For now just use a hard coded value 
    Dim epsilon As Double = 0.00000000000000022204460492503131 
 
 
    ' Process the results 
    If (count > 0) Then 
      Dim line As New OnLine() 
      For i As Integer = 0 To xEvents.Count() - 1 
        Dim e As IOnX_EVENT = xEvents(i) 
        Dim ptA As New On3dPoint(e.m_pointA(0)) 
        Dim ptB As New On3dPoint(e.m_pointB(0)) 
        context.m_doc.AddPointObject(ptA) 
        Dim distance As Double = ptA.DistanceTo(ptB) 
        If (distance > epsilon) Then 
          context.m_doc.AddPointObject(ptB) 
          line.from = ptA 
          line.to = ptB 
          context.m_doc.AddCurveObject(line) 
        End If 
      Next 
      context.m_doc.Redraw() 
    End If 
 
 
    Return IRhinoCommand.result.success 
  End Function |   
 
 
 
 |