本帖最后由 htlaser 于 2022-3-28 15:45 编辑
- (defun c:test4 (/ ang cmd e ent ep i pts sp ss ssa ssin ssle sss width)
- (setq cmd (getvar "cmdecho"))
- (setvar "cmdecho" 0)
- (command "_undo" "be")
- (setq ssa (ssadd))
- (if (null *width)
- (setq *width 1.00)
- )
- (if (setq width(getdist (strcat "\n输入宽度 <" (rtos *width) ">:")))
- (setq *width width)
- (setq width *width)
- )
- (setq sss (ssget))
- (progn
- (setq ssin (ssget "p" (list (cons 0 "INSERT")( cons 6 "CENTER2"))))
- (command "select" sss "")
- (setq ssle (ssget "p" '((-4 . "<OR") (-4 . "<AND")(0 . "LWPOLYLINE")(90 . 2)(42 . 0)(-4 . "AND>") (0 . "LINE")(-4 . "OR>"))))
- (if (= nil ssin) (setq ss ssle) ;判断INSERT
- (if (= nil ssle) (setq ss (trtr ssin)) ;判断LINE
- (setq ss (ss_sum ssle (trtr ssin))))))
- (repeat (setq i (sslength ss))
- (setq e (ssname ss (Setq i (1- i))))
- (setq ent (entget e)
- ang (angle (setq sp (vlax-curve-getStartPoint e))
- (setq ep (vlax-curve-getendPoint e))
- )
- )
- (setq pts (mapcar '(lambda (pt)
- (list (setq p_ (polar pt (+ ang (/ pi 2.0)) (* 0.5 width)))
- (polar p_ (+ ang (* pi 1.5)) width)
- )
- )
- (list sp ep)
- )
- pts (apply 'append (list (car pts) (reverse (cadr pts))))
- )
- (entmakex (append (list (cons 0 "LWPOLYLINE")
- (cons 100 "AcDbEntity")
- (assoc 8 ent)
- (cons 100 "AcDbPolyline")
- (cons 90 (length pts))
- (cons 70 1)
- )
- (mapcar (function (lambda (p) (cons 10 p))) pts)
- )
- )
- (setq ssa (ssadd (entlast) ssa))
- (entdel e)
- )
-
- (if (> (sslength ssa) 0)
- (command "_group" "C" "*" "*" ssa "")
- )
- (command "_undo" "e")
- (setvar "cmdecho" cmd)
- (princ)
- )
- (defun ss_sum (ss1 ss2)
- (setq i 0)
- (repeat (sslength ss1)
- (ssadd (ssname ss1 i) ss2)
- (setq i (1+ i))
- )
- ss2
- )
- (defun trtr (ss / ent n ss1)
- (progn
- (setq n -1 ss1 (ssadd))
- (repeat (sslength ss)
- (setq ent (ssname ss (setq n (1+ n))))
- (command "QAFLAGS" 1 "_.EXPLODE" ent "" "QAFLAGS" 0)
- (ssadd (entlast) ss1)
- )
- )
- (if (zerop (sslength ss1)) nil ss1)
- )
|