usingRhino;usingRhino.DocObjects;usingRhino.Input.Custom;usingRhino.Commands;usingSystem.Collections.Generic;usingRhino.Geometry;usingRhino.Geometry.Intersect;namespace examples_cs
{publicclassProjectPointsToBrepsCommand:Command{publicoverridestringEnglishName{get{return"csProjectPtointsToBreps";}}protectedoverrideResultRunCommand(RhinoDoc doc,RunMode mode){var gs =newGetObject();
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)returnResult.Failure;var points =Intersection.ProjectPointsToBreps(newList<Brep>{brep},// brep on which to projectnewList<Point3d>{newPoint3d(0,0,0),newPoint3d(3,0,3),newPoint3d(-2,0,-2)},// some random points to projectnewVector3d(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();returnResult.Success;}}}
import rhinoscriptsyntax as rs
from scriptcontext import*fromRhino.Geometryimport*defRunCommand():
srfid = rs.GetObject("select surface", rs.filter.surface | rs.filter.polysurface)ifnot srfid:return
brep = rs.coercebrep(srfid)ifnot 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 projectVector3d(0,1,0),# project on Y axis
doc.ModelAbsoluteTolerance)if pts !=Noneand pts.Length>0:for pt in pts:
doc.Objects.AddPoint(pt)
doc.Views.Redraw()if __name__ =="__main__":RunCommand()
ImportsRhinoImportsRhino.DocObjectsImportsRhino.Input.CustomImportsRhino.CommandsImportsSystem.Collections.GenericImportsRhino.GeometryImportsRhino.Geometry.IntersectNamespace examples_vb
PublicClassProjectPointsToBrepsCommandInheritsCommandPublicOverridesReadOnlyPropertyEnglishName()AsStringGetReturn"vbProjectPtointsToBreps"EndGetEndPropertyProtectedOverridesFunctionRunCommand(doc AsRhinoDoc, mode AsRunMode)AsResultDim gs =NewGetObject()
gs.SetCommandPrompt("select surface")
gs.GeometryFilter=ObjectType.SurfaceOrObjectType.PolysrfFilter
gs.DisablePreSelect()
gs.SubObjectSelect=False
gs.[Get]()If gs.CommandResult()<>Result.SuccessThenReturn gs.CommandResult()EndIfDim brep = gs.[Object](0).Brep()If brep IsNothingThenReturnResult.FailureEndIf' brep on which to project' some random points to project' project on Y axisDim points =Intersection.ProjectPointsToBreps(NewList(OfBrep)()From{ _
brep _
},NewList(OfPoint3d)()From{ _
NewPoint3d(0,0,0), _
NewPoint3d(3,0,3), _
NewPoint3d(-2,0,-2) _
},NewVector3d(0,1,0), doc.ModelAbsoluteTolerance)If points IsNotNothingAndAlso points.Length>0ThenForEach point AsPoint3dIn points
doc.Objects.AddPoint(point)NextEndIf
doc.Views.Redraw()ReturnResult.SuccessEndFunctionEndClassEndNamespace