M_Rhino_Geometry_Intersect_Intersection_ProjectPointsToBreps - mcneel/rhinocommon-api-docs GitHub Wiki
Projects points onto breps.
Namespace: Rhino.Geometry.Intersect
Assembly: RhinoCommon (in RhinoCommon.dll) Version: Rhino 6.0
C#
public static Point3d[] ProjectPointsToBreps(
IEnumerable<Brep> breps,
IEnumerable<Point3d> points,
Vector3d direction,
double tolerance
)
VB
Public Shared Function ProjectPointsToBreps (
breps As IEnumerable(Of Brep),
points As IEnumerable(Of Point3d),
direction As Vector3d,
tolerance As Double
) As Point3d()
- breps
- Type: System.Collections.Generic.IEnumerable(Brep)
The breps projection targets. - points
- Type: System.Collections.Generic.IEnumerable(Point3d)
The points to project. - direction
- Type: Rhino.Geometry.Vector3d
The direction to project. - tolerance
- Type: System.Double
The tolerance used for intersections.
Type: Point3d[]
Array of projected points, or null in case of any error or invalid input.
VB
Imports Rhino
Imports Rhino.DocObjects
Imports Rhino.Input.Custom
Imports Rhino.Commands
Imports System.Collections.Generic
Imports Rhino.Geometry
Imports Rhino.Geometry.Intersect
Namespace examples_vb
Public Class ProjectPointsToBrepsCommand
Inherits Command
Public Overrides ReadOnly Property EnglishName() As String
Get
Return "vbProjectPtointsToBreps"
End Get
End Property
Protected Overrides Function RunCommand(doc As RhinoDoc, mode As RunMode) As Result
Dim gs = New GetObject()
gs.SetCommandPrompt("select surface")
gs.GeometryFilter = ObjectType.Surface Or ObjectType.PolysrfFilter
gs.DisablePreSelect()
gs.SubObjectSelect = False
gs.[Get]()
If gs.CommandResult() <> Result.Success Then
Return gs.CommandResult()
End If
Dim brep = gs.[Object](0).Brep()
If brep Is Nothing Then
Return Result.Failure
End If
' brep on which to project
' some random points to project
' project on Y axis
Dim points = Intersection.ProjectPointsToBreps(New List(Of Brep)() From { _
brep _
}, New List(Of Point3d)() From { _
New Point3d(0, 0, 0), _
New Point3d(3, 0, 3), _
New Point3d(-2, 0, -2) _
}, New Vector3d(0, 1, 0), doc.ModelAbsoluteTolerance)
If points IsNot Nothing AndAlso points.Length > 0 Then
For Each point As Point3d In points
doc.Objects.AddPoint(point)
Next
End If
doc.Views.Redraw()
Return Result.Success
End Function
End Class
End Namespace
C#
using Rhino;
using Rhino.DocObjects;
using Rhino.Input.Custom;
using Rhino.Commands;
using System.Collections.Generic;
using Rhino.Geometry;
using Rhino.Geometry.Intersect;
namespace examples_cs
{
public class ProjectPointsToBrepsCommand : Command
{
public override string EnglishName { get { return "csProjectPtointsToBreps"; } }
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
var gs = new GetObject();
gs.SetCommandPrompt("select surface");
gs.GeometryFilter = ObjectType.Surface | ObjectType.PolysrfFilter;
gs.DisablePreSelect();
gs.SubObjectSelect = false;
gs.Get();
if (gs.CommandResult() != Result.Success)
return gs.CommandResult();
var brep = gs.Object(0).Brep();
if (brep == null)
return Result.Failure;
var points = Intersection.ProjectPointsToBreps(
new List<Brep> {brep}, // brep on which to project
new List<Point3d> {new Point3d(0, 0, 0), new Point3d(3,0,3), new Point3d(-2,0,-2)}, // some random points to project
new Vector3d(0, 1, 0), // project on Y axis
doc.ModelAbsoluteTolerance);
if (points != null && points.Length > 0)
{
foreach (var point in points)
{
doc.Objects.AddPoint(point);
}
}
doc.Views.Redraw();
return Result.Success;
}
}
}
Python
import rhinoscriptsyntax as rs
from scriptcontext import *
from Rhino.Geometry import *
def RunCommand():
srfid = rs.GetObject("select surface", rs.filter.surface | rs.filter.polysurface)
if not srfid: return
brep = rs.coercebrep(srfid)
if not brep: return
pts = Intersect.Intersection.ProjectPointsToBreps(
[brep], # brep on which to project
[Point3d(0, 0, 0), Point3d(3,0,3), Point3d(-2,0,-2)], # points to project
Vector3d(0, 1, 0), # project on Y axis
doc.ModelAbsoluteTolerance)
if pts != None and pts.Length > 0:
for pt in pts:
doc.Objects.AddPoint(pt)
doc.Views.Redraw()
if __name__ == "__main__":
RunCommand()
Supported in: 6.0.16224.21491, 5D58w