;圆弧转多段线 ;h为弓高(即弦中心至相对应弧之中心的距离) ;它用来描述以弦代弧的光滑程度,一般化取0.005mm(图上距离)即可 (defun arc->pline(ent h / xtblm xtblz db r po a0 h n) (setq xtblm '("cmdecho" "osmode") xtblz (mapcar 'getvar xtblm) db (entget ent) r (cdr (assoc 40 db)) po (cdr (assoc 10 db)) a0 (cdr (assoc 50 db)) db (- (cdr (assoc 51 db)) a0) db (cond ((< db 0) (+ (* 2.0 pi) db)) (t db) ) n (fix (/ db (atan (/ (sqrt (- (* 2.0 r h) (* h h))) (- r h))))) db (/ db n) ) (mapcar 'setvar xtblm '(0 0)) (command "_pline" (polar po a0 r)) (repeat n (command (polar po (setq a0 (+ a0 db)) r))) (command "" "_matchprop" ent (entlast) "" "_erase" ent "" "redraw") (mapcar 'setvar xtblm xtblz)(princ) ) ;测试程序 (defun cc() (setq t0 (getvar "cdate")) (arc->pline (car (entsel "\n请选取要转化多段线的圆弧:")) 0.005) (princ (strcat "\n耗时:" (rtos (* 1000000 (- (getvar "cdate") t0) 2 3)) "秒")) (princ) ) |