Forgot password?

Create an account!

Forum

« back

RhinoScript – Flipped Surface Normal Selection

Messages

Please log in to write a message.

  • 7. jmartlncln (Apr 05, 2016 07.52):

    For some reason the syntax didn't copy correctly, so attached is a picture.

    Flipped Surface Normal Selection
  • 6. jmartlncln (Apr 05, 2016 07.49):

    Yep, that did it. Thanks!

    (Just to re-post it as I currently have it working)

    [
    Call SelBackfaces()
    Sub SelBackfaces()
    Dim VisibleObjects:VisibleObjects = Rhino.VisibleObjects()
    Dim UV, Vector,punto,object,CameraVector,Suma,LenghtNormal,LenghtCamara,LenghtSuma

    Dim UbicationCamera:UbicationCamera = Rhino.ViewCamera()

    Rhino.UnselectAllObjects

    For Each object In VisibleObjects
    If rhino.IsSurface(object) Then

    UV = Rhino.SurfaceClosestPoint(object, UbicationCamera)
    Vector = Rhino.SurfaceNormal(object, UV)
    Punto = Rhino.EvaluateSurface(object, UV)
    CameraVector = Rhino.VectorCreate(Punto, UbicationCamera)
    LenghtNormal = Rhino.VectorLength(Vector)
    LenghtCamara = Rhino.VectorLength(CameraVector)
    Suma = Rhino.VectorAdd(Vector, CameraVector)
    LenghtSuma = Rhino.VectorLength(Suma)
    If LenghtCamara < LenghtSuma Then Rhino.SelectObject object

    End If
    Next

    End Sub
    ]

  • 5. pulgarata (Oct 29, 2015 12.35):

    Hello,
    It left you write before:

    Call SelBackfaces()

    Regards!

    Seba,

  • 4. jmartlncln (Oct 29, 2015 08.41):

    Thanks for the tips.

    I can't seem to get anything to happen with the sample code. I have copied it into the Rhinoscript editor (as in the attached image), but nothing happens when I run it...

    I will have a look into the Surface Normal and View Camera Plane documentation to see if there is any way to link them.

    Any other ideas, please share them.

    Cheers!

  • 3. pulgarata (Oct 27, 2015 15.48):

    Hello,
    Try this. It works for me, but it will not work with surfaces that are curves or not flats.
    Probably

    Sub SelBackfaces()
            Dim VisibleObjects:VisibleObjects = Rhino.VisibleObjects()
            Dim UV, Vector,punto,object,CameraVector,Suma,LenghtNormal,LenghtCamara,LenghtSuma

            Dim UbicationCamera:UbicationCamera = Rhino.ViewCamera()
           
            Rhino.UnselectAllObjects
           
            For Each object In VisibleObjects
                    If rhino.IsSurface(object) Then
                           
                            UV = Rhino.SurfaceClosestPoint(object, UbicationCamera)
                            Vector = Rhino.SurfaceNormal(object, UV)
                            Punto = Rhino.EvaluateSurface(object, UV)
                            CameraVector = Rhino.VectorCreate(Punto, UbicationCamera)
                            LenghtNormal = Rhino.VectorLength(Vector)
                            LenghtCamara = Rhino.VectorLength(CameraVector)
                            Suma = Rhino.VectorAdd(Vector, CameraVector)
                            LenghtSuma = Rhino.VectorLength(Suma)
                            If LenghtCamara < LenghtSuma Then Rhino.SelectObject object
                           
                    End If
            Next

    End Sub
     

    Seba,

  • 2. Hanno (Oct 27, 2015 13.30):

    Hi,

    if you want to solve this with RhinoScript, have a look at methods SurfaceNormal and ViewCameraPlane to compare the orientations.

    Hope that helps!

    Hanno

  • 1. jmartlncln (Oct 27, 2015 05.58):

    Very simple problem here, not sure where to even start though..

    I want to select surfaces whose backfaces are visible from the current perspective viewpoint.

    This would be useful for flipping the direction of surfaces that are difficult or tedious to select manually.

    3ds Max has a similar function in Editable Poly sub-object Face mode, where you can select faces that are oriented within a specified angle to the current perspective. There should be a way to do this in Rhino, but not necessary to include the angle tolerance.. only visible back faces of surfaces.

    Thanks for any help or tips.

Recommend

Why are these buttons gray?