_Dir and Surface.FrameAt() Differ

@stevebaer , all,
after using _Dir _Flip, the frame extracted from a surface with FrameAt() differs from what Rhino _Dir displays (please see video). Is there a method to consistently get the frame/plane that _Dir displays? The Python code used in the second part of the video is below. This is in Rh7, latest SR. I cannot switch to Rh8 yet.
Thanks!

import Rhino.Geometry as rhg
import rhinoscriptsyntax as rs


def test():
    sect_srf = rs.GetObject('Select section plane', preselect=True, filter=rs.filter.surface)
    if not sect_srf:
        print('Nothing selected, aborting.')
        return

    sect_rh_srf = rs.coercesurface(sect_srf, True)
    uv_orig = (sect_rh_srf.Domain(0)[0], sect_rh_srf.Domain(1)[0])
    res = sect_rh_srf.FrameAt(uv_orig[0], uv_orig[1])
    if res[0] == False:
        print('Could not get frame')
        return
    sect_plane = res[1]
    # X Axis of frame is wolrd Z 0,0,1, _Dir is world X 1,0,0
    print(sect_plane.XAxis)
    
    # Draws the visualization of the frame as lines, as seen in video, not shared
    # rhu.draw_frame(sect_plane)


test()

Hi @silvano,

The Dir command works off of the Brep’s faces, not the underlying surfaces (which is what your code you’re is doing).

Something like this will get the correct normal direction of a Brep face at a giving parameter.

import rhinoscriptsyntax as rs

def test():
    brep_id = rs.GetObject('Select section plane', preselect=True, filter=rs.filter.surface)
    if not brep_id:
        return
    
    brep = rs.coercebrep(brep_id, True)
    if not brep:
        return
    
    face = brep.Faces[0]
    du = face.Domain(0)
    dv = face.Domain(1)
    normal = face.NormalAt(du.Min, dv.Min)
    if face.OrientationIsReversed:
        normal.Reverse()
    print('Normal direction: {0}'.format(normal))

test()

–Dale

1 Like