本帖最后由 song宋_74729 于 2022-5-18 10:33 编辑
试试这个
(defun c:lxcj (/ pt pts dist1 dist2 p1 N)
(setq pt(getpoint "\n 请指定开始点:")) (setq p1(getpoint pt "\n 请指定下一点:")) (SETQ DIST1(DISTANCE P1 Pt)) (PRINC(strcat "\n 本段长度为"(rtos dist1 2 2))) (grdraw ptp1 1 1) (if p1 (PROGN (setq pts(cons p1 (list pt))) (SETQ DIST1(DISTANCE (car pts) (last pts))) (PRINC(strcat " 累计长度为" (rtos dist1 2 2))) (setq M 0) (while (if pt (progn (initget 128 "F") (setq pt (getpoint p1 "\n 下一点[下一点(NEXT)/重新开始点(F)]<NEXT>: " ) ;_ 结束getpoint ) ;_ 结束setq ) ;_ 结束progn ) ;_ 结束if (if (= pt"F") (progn (setqp1 (getpoint "\n 请指定重新开始点:")) (setqpt (getpoint p1 "\n 请指定下一点:")) (grdrawpt p1 1 1) (ifp1 (PROGN (setq pts (cons p1 (list pt)))) ) ;_ 结束if );_ 结束progn ) ;_ 结束if (setq pts(cons pt pts)) (if (>=(length pts) 2) (grdraw pt p1 1 1) ) ;_ 结束if (SETQ DIST2(DISTANCE p1 pt)) (PRINC(strcat "\n 本段长度为"(rtos dist2 2 2))) (SETQ DIST1(+ (DISTANCE P1 Pt) dist1)) (PRINC(strcat " 累计长度为" (rtos dist1 2 2))) (setq p1 pt) (SETQ M (1+M)) ) ;_ 结束while ) ;_ 结束PROGN ) ;_ 结束if (princ(strcat "\n (总长度为"(rtos dist1 2 2)")>>>>>>>")) (princ(strcat "(共测量了"(rtos (+ M 1) 2 0) "条线)")) (if (zeropdist1) (princ " 零长度尺寸,请重新测量!") ) ;_ 结束if (princ) ) ;_ 结束defun
|