(defun c:zx( / ent1 ent2 num p1list p2list p3list i cp p1 cv1 cv2 stp endp) (setq ent1 (car (entsel "\n选择第1对象:")))
(setq ent2 (car (entsel"\n选择第2对象:")))
(setq cv1 ent1 cv2 ent2)
(setq num (getint "\n控制点数量(越多效果越好:"))
(if (ssget "x" (list (cons 0 "POINT"))) (command "erase" (ssget "x" (list (cons 0 "POINT"))) ""))
(command "divide" ent1 num)
(setq ent1 (ssget "x" (list (cons 0 "POINT"))))
(setq p1list nil i 0)
(while (setq cp (ssname ent1 i))
(setq p1list (append p1list (list (cdr (assoc 10 (entget cp))))))
(setq i (1+ i))
)
(setq stp (vlax-curve-getStartPoint cv1) endp (vlax-curve-getEndPoint cv1))
(if (> (distance stp (nth 0 p1list)) (distance endp (nth 0 p1list)))
(setq p1list (append (list endp) p1list (list stp)))
(setq p1list (append (list stp) p1list (list endp)))
)
(command "erase" ent1 "")
(command "divide" ent2 num)
(setq ent2 (ssget "x" (list (cons 0 "POINT"))))
(setq p2list nil i 0)
(while (setq cp (ssname ent2 i))
(setq p2list (append p2list (list (cdr (assoc 10 (entget cp))))))
(setq i (1+ i))
)
(setq stp (vlax-curve-getStartPoint cv2) endp (vlax-curve-getEndPoint cv2))
(if (> (distance stp (nth 0 p2list)) (distance endp (nth 0 p2list)))
(setq p2list (append (list endp) p2list (list stp)))
(setq p2list (append (list stp) p2list (list endp)))
)
(command "erase" ent2 "")
(if (> (distance (nth 0 p1list) (nth 0 p2list)) (distance (nth 0 p1list) (nth (- num 2) p2list)))
(setq p2list (reverse p2list))
)
(setq i 0 p3list nil)
(while (and (setq cp (nth i p1list)) (setq cp1 (nth i p2list)))
(setq p3 (list (* (+ (car cp) (car cp1)) 0.5) (* (+ (cadr cp) (cadr cp1)) 0.5)))
(setq p3list (append p3list (list p3)) i (1+ i))
)(command "undo" "be")
(setq temposm (getvar "osmode"))
(setvar "osmode" 0)
(setq i 2 p1 (nth 0 p3list) cp (nth 1 p3list))
(command "pline" (trans p1 0 1) (trans cp 0 1) "")
(setq ent1 (entlast) p1 cp)
(while (setq cp (nth i p3list))
(command "line" (trans p1 0 1) (trans cp 0 1) "")
(command "pedit" ent1 "J" (entlast) "" "")
(setq p1 cp i (1+ i))
)
(setvar "osmode" temposm)(command "undo" "e")
(princ)
)