求修剪圆内直线和多段线!
模板上有大小不一样的圆;; ctrim.lspv1.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)
) (defun c:ctrim ( / circ_pts lst ang inc tmp seg pt ent
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
)
(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)
(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)
)
xiaxiang 发表于 2011-11-16 16:41
你好前辈,用了你的方法很实用。非常感谢。但是现实中节点编号都在圆圈里面,能不能只修剪园内的线段,文字保留。非常期待您的指点 xiaxiang 发表于 2011-11-16 15:47 static/image/common/back.gif
您好,能不能改成框选呀,就是框选后,把框选中所有圆内的东东全剪了,谢谢! xiaxiang 发表于 2011-11-16 16:41 static/image/common/back.gif
谢谢您,效果很好 443971181 发表于 2011-11-16 16:47 static/image/common/back.gif
谢谢您,效果很好
非常感谢!怎么给您加分呢? 有没有c#版的? 不错,效果很好。 路过,学习了 xiaxiang 发表于 2011-11-16 16:41 static/image/common/back.gif
修剪多段线出了点故障,请完善一下