本帖最后由 Gu_xl 于 2012-3-31 14:40 编辑
回复 dai
dong013 的帖子
改进版:
- ;;;明经通道 编制 By Gu_xl 2011年7月5日
- (defun c:DtrimIn(/ p1 p3 p4 dis pl s1 en w enpline pline1 pline1 ss ssbj kd ss1 ss2 ss3 ss4 pl1 pl2 removesel)
- (setq os (getvar 'osmode))
- (setq cmd (getvar 'cmdecho))
- (mapcar 'setvar (list 'osmode 'cmdecho) '(0 0))
- (if *w*
- (progn
- (setq w (getdist (getvar "viewctr") (strcat "\n 双线宽度<" (rtos *w* 2 2) ">: ")))
- (if (null w) (setq w *w*) (setq *w* w))
- )
- (progn
- (setq w (getreal (strcat "\n 双线宽度<1.0>: ")))
- (if (null w) (setq w 1.0 *w* w) (setq *w* w))
- )
- )
- (initget 7 "Yes No ")
- (setq kd (getkword "\n 是否删除双线[Yes/No]<No>:"))
- (setq en (entlast))
- (princ "\n 请绘制双线中线: ")
- (setvar 'osmode 3071)
- (vl-cmdf "_pline")
- (while (= 1 (getvar "cmdactive"))
- (vl-cmdf pause)
- )
- (setvar 'osmode 0)
- (setq enpline (entlast))
- (if (not (equal en enpline))
- (progn
- (vla-Offset (vlax-ename->vla-object enpline) (/ w 2.0))
- (setq pline1 (entlast))
- (vla-Offset (vlax-ename->vla-object enpline) (/ w -2.0))
- (setq pline2 (entlast))
- (setq ssbj (ssadd pline1))
- (ssadd pline2 ssbj)
- (setq pl (mapcar 'cdr (vl-remove-if '(lambda (x) (/= 10 (car x))) (entget pline1))))
- (setq pl (append pl (reverse (mapcar 'cdr (vl-remove-if '(lambda (x) (/= 10 (car x))) (entget pline2))))))
- (setq p1 (apply 'mapcar (cons 'min pl))
- p3 (apply 'mapcar (cons 'max pl))
- )
- (command "_.Zoom" "_Window" p1 p3 "._Zoom" "0.95x")
- (setq dis (* 0.15 w))
- (vla-Offset (vlax-ename->vla-object enpline) (- (/ w 2.0) dis))
- (setq pline3 (entlast))
- (vla-Offset (vlax-ename->vla-object enpline) (+ dis (/ w -2.0)))
- (setq pline4 (entlast))
- (setq pl1 (mapcar 'cdr (vl-remove-if '(lambda (x) (/= 10 (car x))) (entget pline3))))
- (setq pl2 (reverse (mapcar 'cdr (vl-remove-if '(lambda (x) (/= 10 (car x))) (entget pline4)))))
- (entdel pline3)
- (entdel pline4)
- (vla-put-Visible (vlax-ename->vla-object pline1) :vlax-false)
- (vla-put-Visible (vlax-ename->vla-object pline2) :vlax-false)
- (setq ss1 (ssget "f" (list (car pl1) (last pl2))) ss2 (ssget "f" (list (last pl1) (car pl2))))
- (if ss1
- (repeat (setq n (sslength ss1))
- (setq removesel (cons (ssname ss1 (setq n (1- n))) removesel))
- )
- )
- (if ss2
- (repeat (setq n (sslength ss2))
- (setq removesel (cons (ssname ss2 (setq n (1- n))) removesel))
- )
- )
- (mapcar '(lambda (x) (vla-put-Visible (vlax-ename->vla-object x) :vlax-false)) removesel)
- (vla-put-Visible (vlax-ename->vla-object pline1) :vlax-true)
- (vla-put-Visible (vlax-ename->vla-object pline2) :vlax-true)
- (setq pl1 (append pl1 pl2))
- (command "trim" ssbj "" )
- (setq p1 (car pl1))
- (foreach a (cdr pl1)
- (command "f" p1 a "")
- (setq p1 a)
- )
- (command "")
- (mapcar '(lambda (x) (vla-put-Visible (vlax-ename->vla-object x) :vlax-true)) removesel)
- (entdel enpline)
- (setq ss (ssget "wp" pl))
- (if ss (command "erase" ss ""))
- (if (= "Yes" kd)
- (progn
- (entdel pline1)
- (entdel pline2)
- )
- )
- )
- )
- (mapcar 'setvar (list 'osmode 'cmdecho) (list os cmd))
- (princ)
- )
|