highflybir 发表于 2011-10-31 15:40
(polar cen ang (+ rad eps))
之类的可以让你直接取得圆内或者圆外的一点.
感谢高飞鸟!现上传非偏移方法的圆内外剪切程序,直接求点集的,这样速度比偏移快吗?可以批量处理的来测试一下。
- (defun c:ctrim ( / circ_pts lst ang inc tmp seg pt ent el pt rad
- ctrim_err x zmode adist f_pts svd_os svd_cmd svd_err)
- (defun ctrim_err (s)
- (if(/= s "Function cancelled")
- (princ(strcat "\n\n" s)) )
- (setvar "cmdecho" svd_cmd)
- (setvar "osmode" svd_os)
- (setq *error* svd_err)
- )
- (defun circ_pts (cen rad segs / lst cnt)
- (setq cnt 0)
- (repeat segs
- (setq lst (cons (polar cen (+ 0 (* cnt (/ (* pi 2) segs))) rad)
- lst
- )
- cnt (1+ cnt)
- )
- )
- ;(setq lst (append lst (list (nth 0 lst))))
- (princ)
- lst
- )
- (setq ent (car(entsel "\nSelect circle: "))
- svd_err *error*
- *error* ctrim_err
- svd_os (getvar "osmode")
- svd_cmd (getvar "cmdecho")
- )
- (setvar "cmdecho" 0)
- (setvar "osmode" 0)
- (initget 128 "Z X")
- (setq zmode(getkword "\n输入选项 (Z内剪切/X外剪切)(默认Z内剪切): "))
- (if (null zmode) (setq zmode "Z"))
- (cond
- ((= zmode "Z") (setq adist -0.1))
- ((= zmode "X") (setq adist 0.1))
- )
- (if(and ent
- (=(cdr(assoc 0(entget ent)))"CIRCLE")
- )
- (progn
- (setq el (entget ent))
- (setq pt (cdr (assoc 10 el)))
- (setq rad (cdr (assoc 40 el)))
- (setq f_pts(circ_pts pt (+ rad adist) 25))
- (repeat 2
- (command "trim" ent "" "f")
- (foreach x f_pts(command x))
- (command "" "")
- )
- (redraw)
- )
- )
- (setvar "cmdecho" svd_cmd)
- (setvar "osmode" svd_os)
- (setq *error* svd_err)
- (princ)
- )
-
|