Ispointinsurface for Rhino5 vb.net


#1

Hello All,

There is a rhino 4 script that I am trying to convert to rhino 5 vb.net.
The only thing I am missing is ispointinsurface.

The script has to delete all points that are not in the surface.
So only the underlying points need to stay.

The excisting script part is:

For i=0 To UBound(allpointsinfile)
Dim pointcoords = Rhino.pointcoordinates(allpointsinfile(i))
If Not Rhino.ispointinsurface(surface, pointcoords ) Then
Rhino.deleteobject allpointsinfile(i)
End If
Next

and what i got is:

Dim objref As Rhino.DocObjects.ObjRef() = Nothing
Dim vb = Rhino.Input.RhinoGet.GetMultipleObjects(“PointSelected”, False, DocObjects.ObjectType.Point, objref)

If vb <> Rhino.Commands.Result.Success Then
Return vb
End If

For Each obj In objref
doc.Objects.UnselectAll()
doc.Objects.Select(objref(i))
If Not (ISOBJECTINSURFACE) Then
doc.Objects.Delete(objref(i), True)
i = i + 1
End If

Next

Can anyone help me?


(Dale Fugier) #2

Hi Jordy,

See if this helps:

Dim go = New GetObject()
go.SetCommandPrompt("Select closed surface or polysurface")
go.GeometryFilter = ObjectType.Surface Or ObjectType.Brep
go.GeometryAttributeFilter = GeometryAttributeFilter.ClosedSurface Or GeometryAttributeFilter.ClosedPolysrf
go.Get()
If go.CommandResult() <> Result.Success Then
  Return go.CommandResult()
End If

Dim brep As Brep = go.Object(0).Brep()
If brep Is Nothing Then
  Return Result.Failure
End If

Dim refs As ObjRef() = Nothing
Dim rc As Result = Rhino.Input.RhinoGet.GetMultipleObjects("Select test points", False, DocObjects.ObjectType.Point, refs)
If rc <> Result.Success Then
  Return rc
End If

doc.Objects.UnselectAll()
Dim tol As Double = doc.ModelAbsoluteTolerance

For Each ref As ObjRef In refs
  Dim pt As Point = ref.Point()
  If pt IsNot Nothing Then
    If brep.IsPointInside(pt.Location, tol, True) Then
      doc.Objects.Select(ref)
    End If
  End If
Next

doc.Views.Redraw()

#3

Works perfect. Had to change some things because my vb2010 did not recognize Brep only so needed Rhino.DocObjects.Brep same with GeometryAttributeFilter etc.

P.S. Why would you use:

Dim go = New GetObject() go.SetCommandPrompt(“Select closed surface or
polysurface”) go.GeometryFilter = ObjectType.Surface Or
ObjectType.Brep go.GeometryAttributeFilter =
GeometryAttributeFilter.ClosedSurface Or
GeometryAttributeFilter.ClosedPolysrf go.Get() If go.CommandResult()
<> Result.Success Then Return go.CommandResult() End If

in stead of:

Dim objref As Rhino.DocObjects.ObjRef() = Nothing
Dim mesh_point2 = Rhino.Input.RhinoGet.GetMultipleObjects(“PointSelected”, False,
DocObjects.ObjectType.Point, objref)

        If mesh_point2 <> Rhino.Commands.Result.Success Then
            Return mesh_point2
        End If