Line tangent to 3D spline?

Hi All,
Is there a way to draw a line tangent to a 3D spline at some arbitrary point on the spline?

Comments

  • You can draw a line Perpendicular to a 3d spline in a specific plane, then perp to that in the intersection.
    You really need to know what plane you want the tangent in. Set the UCS the align your view.

  • Roy Klein Gebbinck
    edited August 26

    Here is some Lisp code:

    (defun KGA_Geom_VectorScale (vec scl)
      (mapcar '(lambda (a) (* a (float scl))) vec)
    )
    
    (defun KGA_Geom_VectorUnit (vec / mag)
      (if (/= 0.0 (setq mag (distance '(0.0 0.0 0.0) vec)))
        (KGA_Geom_VectorScale vec (/ 1.0 mag))
      )
    )
    
    (defun c:DrawTangent ( / doc enm len pt vec)
      (setq doc (vla-get-activedocument (vlax-get-acad-object)))
      (vla-endundomark doc)
      (vla-startundomark doc)
      (if
        (and
          (setq enm (car (entsel "\nSelect curve: ")))
          (setq pt (getpoint "\nPick point on curve: "))
          (setq pt (vlax-curve-getclosestpointto enm pt))
          (setq len (getdist "\nLength of line: "))
        )
        (progn
          (setq
            vec (KGA_Geom_VectorUnit (vlax-curve-getfirstderiv enm (vlax-curve-getparamatpoint enm pt)))
            vec (KGA_Geom_VectorScale vec (/ len 2.0))
          )
          (entmake
            (list
              '(0 . "LINE")
              (cons 10 (mapcar '- pt vec))
              (cons 11 (mapcar '+ pt vec))
            )
          )
        )
      )
      (vla-endundomark doc)
      (princ)
    )
    
  • Here is some Lisp code: [snip]

    Excellent!

    One of these days I really need to sit down to go through the VLAX- and associated documentation...

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!