按照楼上大佬思路写的
 - (defun c:tt(/ an b bf-curve-subsegment-picked-points bf-curve-subsegment-points c gs1- gs1+ gs2 h jd1 jd2 lm-3d2d lm-entmake-pline pt pt1 pt2 pt3 pts1 pts2 ptx ty x1 x2)
- (defun BF-curve-subsegment-picked-Points (obj p)
- (BF-curve-subsegment-points
- obj
- (fix
- (vlax-curve-getParamAtPoint
- obj
- (vlax-curve-getClosestPointTo obj (trans p 1 0))
- )
- )
- )
- )
- (defun BF-curve-subsegment-points (curve n)
- (list
- (lm-3d2d(vlax-curve-getPointAtParam curve (fix n)))
- (lm-3d2d(vlax-curve-getPointAtParam curve (1+ (fix n))))
- )
- )
- (defun lm-3d2d (pt) (mapcar '+ '(0 0) pt))
- (defun lm-entmake-pline (pldata / a s1 ptlst bihe co tc)
- (mapcar'set '(ptlst bihe co tc) pldata)
- (or co (setq co 256))
- (or tc (setq tc (getvar "clayer")))
- (entmake (append (list
- '(0 . "LWPOLYLINE")
- '(100 . "AcDbEntity")
- '(100 . "AcDbPolyline")
- (cons 62 co)
- (cons 8 tc)
- (cons 90 (length ptlst))
- (cons 70 (if bihe 1 0))
- (cons 38 (if (setq h(nth 2 (car ptlst))) h 0))
- )
- (mapcar '(lambda (a) (cons 10 a)) ptlst))
- )
- (entlast)
- )
- (setq ty (car(entsel "选择三角形多段线:")))
- (setq pts1(mapcar 'cdr (vl-remove-if-not '(lambda(x) (= (car x) 10) ) (entget ty))))
- (setq pt (getpoint "\n指定D点:"))
- (setq pts2(vl-sort (BF-curve-subsegment-picked-Points ty pt) '(lambda (p1 p2)(< (car p1) (car p2)))))
- (foreach x pts2 (setq pts1(vl-remove x pts1)))
- (setq
- pt1(car pts2)
- pt2(cadr pts2)
- pt3(car pts1)
- an1(angle pt pt1)
- h(distance pt pt3)
- b(distance pt pt1)
- c(distance pt pt2)
- )
- (setq gs1+(* h (+ (* 3.0 c) b (sqrt (* (+ b c (/ (* 2.0 b c) h)) (+ b c (- (/ (* 2.0 b c) h))))))))
- (setq gs1-(* h(+ (* 3.0 c) b (- (sqrt (* (+ b c (/ (* 2.0 b c) h)) (+ b c (- (/ (* 2.0 b c) h)))))))))
- (setq gs2(+ (/ (* 2 b c) h) (/ (* 4 h c) b) (* 2 h)))
- (setq x1 (/ gs1+ gs2))
- (setq x2 (/ gs1- gs2))
- (setq ptx(polar pt an1 x1))
- (setq jd1(inters ptx (polar ptx (+ an1 (* pi 0.5)) 0.5) pt1 pt3 nil))
- (setq an(- (angle pt jd1) (* pi 0.5)))
- (setq jd2(inters pt (polar pt an 0.5) pt2 pt3 nil))
- (lm-entmake-pline(list (list pt jd1 jd2) t 4))
- (setq ptx(polar pt pi x2))
- (setq jd1(inters ptx (polar ptx (+ an1(* pi 0.5)) 0.5) pt1 pt3 nil))
- (setq an(- (angle pt jd1) (* pi 0.5)))
- (setq jd2(inters pt (polar pt an 0.5) pt2 pt3 nil))
- (lm-entmake-pline(list (list pt jd1 jd2) t 3))
- ;(entmake (list '(0 . "CIRCLE")'(100 . "AcDbEntity")'(100 . "AcDbCircle")(cons 62 1)(cons 10 pt)(cons 40 x1)))
- ;(entmake (list '(0 . "CIRCLE")'(100 . "AcDbEntity")'(100 . "AcDbCircle")(cons 62 2)(cons 10 pt)(cons 40 x2)))
- (princ)
- )
|