我通过lisp例程替换了一系列块。但新街区比旧街区宽。因此,我编写了下面的例程来修剪延伸到块中的线。当块水平时,它间歇性工作。我还没有添加代码来修剪垂直的线条,因为我不明白为什么代码不能始终工作。代码如下,所附的图形文件中有我正在使用的块作为示例。
- (defun trimblocklines ( ent / e d ins ero bw bh pt1 pt2 ss1 cnt sslen )
- (setvar "cmdecho" 0)
- (setq e ent
- d (entget e)
- ins (cdr (assoc 10 d))
- ero (* (dxf 50 d) (/ 180 pi))
- bw 0.25
- bh 0.125
- pt1 (list (- (nth 0 ins) (/ bw 2)) (- (nth 1 ins) (/ bh 2)) (nth 2 ins))
- pt2 (list (+ (nth 0 ins) (/ bw 2)) (+ (nth 1 ins) (/ bh 2)) (nth 2 ins))
- ss1 (ssget "_C" pt1 pt2 '((0 . "line")))
- cnt 0
- sslen (sslength ss1)
- ln_ents (list )
- )
- (command "circle" ins (list (+ (nth 0 ins) (/ bw 2)) (nth 1 ins)))
- (setq cent (entlast))
- (while (< cnt sslen)
- (setq ln_ents (append ln_ents (list (ssname ss1 cnt)))
- cnt (1+ cnt)
- )
- )
- (command "trim" cent ss1 "" (list (- (nth 0 ins) (- (/ bw 2) 0.01)) (nth 1 ins) 0.0) "")
- (command "trim" cent ss1 "" (list (+ (nth 0 ins) (- (/ bw 2) 0.01)) (nth 1 ins) 0.0) "")
- (entdel cent)
- (setvar "cmdecho" 0)
- (princ)
- )
修剪线条。图纸
非常感谢。 |