- ;; ctrim.lsp v1.1
- ;; Modified By Xiaxiang
- (defun c:ctrim ( / circ_pts lst ang inc tmp seg pt ent ss1 num
- ctrim_err x 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 (enm)
- (setq lst (entget enm)
- ang (* pi 2)
- inc (/ ang 64)
- tmp '()
- seg 65
- )
- (repeat seg
- (setq pt (polar(cdr(assoc 10 lst))ang
- (-(cdr(assoc 40 lst))0.01))
- ang (+ inc ang)
- )
- (setq tmp(cons pt tmp))
- )
- tmp
- )
- ;;add ssget function
- (setq num 0)
- (prompt "\nSelect circles: ")
- (setq ss1 (ssget '((0 . "CIRCLE"))))
- (setq ;ent (car(entsel "\nSelect circle: ")) ;;entsel
- svd_err *error*
- *error* ctrim_err
- svd_os (getvar "osmode")
- svd_cmd (getvar "cmdecho")
- )
- (setvar "cmdecho" 0)
- (setvar "osmode" 0)
- (repeat (sslength ss1)
- (setq ent(ssname ss1 num))
- (setq num(1+ num))
- (if(and ent
- (=(cdr(assoc 0(entget ent)))"CIRCLE")
- )
- (progn
- (setq f_pts(circ_pts ent))
- (command "trim" ent "" "f") ;run twice in case the same
- (foreach x f_pts(command x)) ;object intersects circle twice
- (command "" "")
- (command "trim" ent "" "f")
- (foreach x f_pts(command x))
- (command "" "")
- (if(setq x(ssget "wp" f_pts))
- (command "erase" x "")
- )
- )
- )
- )
- (setvar "cmdecho" svd_cmd)
- (setvar "osmode" svd_os)
- (setq *error* svd_err)
- (princ)
- )
|