哎呀,谢谢Wizman。
- (defun c:perp (/ i ss ent pt p1 p2 ptList LASTPT)
- (vl-load-com)
- (command "_undo" "_begin")
- (princ "\n>> Select Points >>")
- (if (setq i -1
- ss (ssget '((0 . "POINT"))) )
- (if (and (setq ent (car (entsel "\nSelect Curve: ")))
- (wcmatch (cdr (assoc 0 (entget ent))) "*LINE,CIRCLE,ELLIPSE,ARC"))
- (while (setq pt (ssname ss (setq i (1+ i))))
- (setq p2 (vlax-curve-getClosestPointto ent (setq p1 (cdr (assoc 10 (entget pt))))))
- (setq ptList (cons p2 ptList))
- (entmake (list '(0 . "LINE") '(8 . "perp") (cons 10 p1) (cons 11 p2)))
- )
- )
- )
- (if ptList
- (progn
- (setq Startpt (vlax-curve-getstartpoint ent)
- Lastpt Startpt)
- ;; sort by distance
- (setq ptList (vl-sort ptList '(lambda (e1 e2)
- (< (vlax-curve-getdistatpoint ent e1)
- (vlax-curve-getdistatpoint ent e2)))))
- (foreach pt ptList
- (if (> (distance pt Startpt) 0.001)
- (entmake
- (list '(0 . "MTEXT")
- '(100 . "AcDbEntity")
- '(100 . "AcDbMText")
- '(8 . "point")
- (cons 10 (polar pt (angle pt Lastpt)(/ (distance pt Lastpt) 2.)))
- '(40 . 0.6)
- '(41 . 0.0)
- '(71 .
- '(72 . 5)
- (cons 1 (rtos (distance pt Lastpt) 2 2))
- '(7 . "Standard")
- ;'(210 0.0 0.0 1.0)
- '(50 . 0.0)
- '(73 . 1)
- '(44 . 1.0)
- )
- )
- )
- (setq LastPt pt)
- )
- )
- )
-
- (command "_undo" "_end")
- (princ)
- )
|