the first _linea is the pink line in the first image
the second _linea is the green line in the second image
I think that the problem is in the Brep object. Is very rare that if the brep is large, when I selected the brep, the selection middle line is not in the middle’s brep and the line Projectios stop there
Why you use large tolerance of 1? What is the projection of the pictures (I assume the ZX plane?) Can you post a file that has the problem, and also the code maybe?
If I use the code below on some simple test cases, it works.
ObjRef cRef;
Result res = RhinoGet.GetOneObject("Select curve to project", false, ObjectType.Curve, out cRef);
if (res != Result.Success)
return res;
ObjRef bRef;
res = RhinoGet.GetOneObject("Select BREP to project to", false, ObjectType.Brep, out bRef);
if (res != Result.Success)
return res;
Brep b = bRef.Brep();
Curve c = cRef.Curve();
Curve[] result = Curve.ProjectToBrep(c, b, Vector3d.YAxis, doc.ModelAbsoluteTolerance);
if (null != result)
foreach (Curve crv in result)
{
if (null != crv)
doc.Objects.AddCurve(crv);
}
doc.Views.Redraw();
Maybe a bit messy but this works for me.
I get a projection. Projection is in the Z-Direction
Imports System
Imports System.Collections.Generic
Imports Rhino
Imports Rhino.Commands
Imports Rhino.Geometry
Imports Rhino.Input
Imports Rhino.Input.Custom
Namespace TestProjectToBrep
<System.Runtime.InteropServices.Guid("c01eae32-2d3c-4384-88db-4ca680cd90e3")> _
Public Class TestProjectToBrepCommand
Inherits Command
Shared _instance As TestProjectToBrepCommand
Public Sub New()
' Rhino only creates one instance of each command class defined in a
' plug-in, so it is safe to store a refence in a static field.
_instance = Me
End Sub
'''<summary>The only instance of this command.</summary>
Public Shared ReadOnly Property Instance() As TestProjectToBrepCommand
Get
Return _instance
End Get
End Property
'''<returns>The command name as it appears on the Rhino command line.</returns>
Public Overrides ReadOnly Property EnglishName() As String
Get
Return "TestProjectToBrepCommand"
End Get
End Property
Protected Overrides Function RunCommand(ByVal doc As RhinoDoc, ByVal mode As RunMode) As Result
doc.Objects.UnselectAll()
Dim Brep As Rhino.DocObjects.ObjRef = Nothing
Dim rc2 = Rhino.Input.RhinoGet.GetOneObject("Brep", False, Rhino.DocObjects.ObjectType.Brep, Brep)
If rc2 <> Rhino.Commands.Result.Success Then
Return rc2
End If
doc.Objects.UnselectAll()
Dim Curve As Rhino.DocObjects.ObjRef = Nothing
Dim rc = Rhino.Input.RhinoGet.GetOneObject("Curve", False, Rhino.DocObjects.ObjectType.Curve, Curve)
If rc <> Rhino.Commands.Result.Success Then
Return rc
End If
Dim DefBrep As Geometry.Brep = Brep.Brep
Dim DefCurve As Geometry.Curve = Curve.Curve
Dim ProjCrv As Geometry.Curve() = Geometry.Curve.ProjectToBrep(DefCurve, DefBrep, New Geometry.Vector3d(0, 0, 1), doc.ModelAbsoluteTolerance)
For Each crv In ProjCrv
doc.Objects.AddCurve(crv)
Next
doc.Views.Redraw()
Return Result.Success
End Function
End Class
End Namespace