本帖最后由 重慶崽兒 于 2015-9-26 16:54 编辑
前些天看见同事用PL线在圆弧上一点点的画,于心不忍,于是便有了:
- (defun c:tt( / aname bj hc_1 huchang i jsd ksd l name ss bc huchang_1 yxj ii lst pt)
- (setq *error*_bak *error*)
- (setq *error* *error*_non)
- (setq osmode_bak (getvar "osmode"))
- (setvar "osmode" 0)
- (setq Gridmode_bak (getvar "Gridmode"))
- (setvar "Gridmode" 0)
- (setq ss (ssget '((0 . "ARC"))))
- (setq l (getreal "\n请输入点间距:"))
- (setq i 0)
- (if (> l 0)
- (repeat (sslength ss)
- (setq name (ssname ss i))
- (setq bj (cdr (assoc 40 (entget name))))
- (setq aname (vlax-ename->vla-object name))
- (setq ksd (vlax-curve-getStartPoint aname))
- (setq jsd (vlax-curve-getEndPoint aname))
- (setq huchang (vlax-curve-getDistAtParam aname (vlax-curve-getendparam aname)))
- (if (>= (/ l 2.0) bj)
- (entmake (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") (cons 90 2) (cons 10 ksd) (cons 10 jsd)))
- (progn
- (setq hc_1 (shc l bj))
- (huaxian hc_1 huchang aname ksd jsd)
- )
- )
- (setq i (1+ i))
- )
- (progn
- (alert "输入有误!")
- (exit)
- )
- )
- (setvar "osmode" osmode_bak)
- (setvar "Gridmode" Gridmode_bak)
- (setq *error* *error*_bak)
- (princ)
- )
- (defun shc (l bj / )
- (setq bc (sqrt (- (expt bj 2) (expt (/ l 2.0) 2))))
- (setq yxj (* (/ (* (atan (/ l 2.0) bc) 180) pi) 2.0))
- (setq huchang_1 (/ (* yxj pi bj) 180.0))
- )
- (defun huaxian (hc_1 huchang en ksd jsd / )
- (if (< hc_1 huchang)
- (progn
- (setq ii 0 lst nil)
- (while (< ii huchang)
- (setq pt (vlax-curve-getPointAtDist en ii))
- (setq lst (append lst (list pt)))
- (setq ii (+ ii hc_1))
- )
- (setq lst (append lst (list jsd)))
- (entmake (append (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") (cons 90 (length lst))) (mapcar '(lambda (x) (cons 10 x)) lst)))
- )
-
- (entmake (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") (cons 90 2) (cons 10 ksd) (cons 10 jsd)))
- )
- )
- (defun *error*_non (msg)
- (command)
- (setvar "osmode" osmode_bak)
- (setvar "Gridmode" Gridmode_bak)
- (setq *error* *error*_bak)
- (princ)
- )
写的不好,各位莫笑
|