arrow at end

Joe Burke

Usenet Archive
Joined
May 28, 2000
Messages
653
Reaction score
0
Following is my first stab at using/understanding the vlax-curve functions. Any feedback regarding how I might put them to better use would be appreciated, as usual.

The part I found difficult was dealing with vlax-curve-getPointAtDist. Since the distance is from start point, I felt like I was jumping through hoops to find the distance from end point.

The point of the program is draw an arrow (a solid) at the end of a line, pline or arc. Which end depends on where the user picks. The arc option is what motivated me. Making the arrow align correctly on an arc. I guess those who know will understand the rest. BTW, it works OK as is given limited testing.

;Joe Burke 7/16/2003
(defun c:ArrowEnd ( / Ent PkPt Vobj DimScale StPt EnPt
TotLen Dist CurvePt Ang p1 p2 p3)

(setq Ent
(entsel "\nSelect line, pline or arc near end to place arrow: ")) (while (or (null Ent) (and (/= "LINE" (cdr (assoc 0 (entget (car Ent))))) (/= "ARC" (cdr (assoc 0 (entget (car Ent))))) (/= "LWPOLYLINE" (cdr (assoc 0 (entget (car Ent))))) ) ) (setq Ent (entsel "\nMissed pick or wrong object type - try again: "))
) ;while

(setq PkPt (cadr Ent)) ;pick point
(setq Vobj (vlax-ename->vla-object (car Ent)))
(setq DimScale (getvar "dimscale"))
(setq TotLen (vlax-curve-getDistAtParam Vobj
(vlax-curve-getEndParam Vobj)))
(setq StPt (vlax-curve-getStartPoint Vobj))
(setq EnPt (vlax-curve-getEndPoint Vobj))
(if (< (distance StPt PkPt) (distance EnPt PkPt))
(progn ;from curve start
(setq Dist (* DimScale 0.15625))
(setq p1 StPt)
)
(progn ;else from curve end
(setq Dist (- TotLen (* DimScale 0.15625)))
(setq p1 EnPt)
)
) ;if
(setq CurvePt (vlax-curve-getPointAtDist Vobj Dist))
(if CurvePt
(progn
(setq Ang (angle p1 CurvePt))
(setq p2 (polar CurvePt (+ Ang (/ pi 2)) (* DimScale 0.02604))) (setq p3 (polar CurvePt (- Ang (/ pi 2)) (* DimScale 0.02604))) (entmake (list '(0 . "Solid") (cons 10 p1) (cons 11 p2) (cons 12 p3) (cons 13 p3))) ;entmake ) ;progn (princ "\nCannot place arrow on object ") ;else ) ;if (princ)
) ;end
 

Latest threads

Back
Top