本帖最后由 vitalgg 于 2021-1-4 09:59 编辑
新增图框自动编号功能 。就是改图框里的图号,从左到右,从上到下,把图号按顺序改写(不是移动排版,只是改图号)
命令行输入 @U 自动升级到新版
那就给个源码:
- (defun @:get-frames (/ s1 ss-list ename en0 ti% p ml-contents xmax ymin boxscale insp)
- "选取图中的图框"
- (prompt "回车或右键则为所有图框")
- (setq s1 (ssget '((0 . "INSERT"))))
- (setq ss-list '())
- (if (null s1)
- (setq s1 (ssget "x" '((0 . "INSERT")))))
- (setq ti% 0)
- (if (/= s1 nil)
- (progn
- (while
- (<= ti% (- (sslength s1) 1))
- (setq en0 (ssname s1 ti%))
- (if (eq (block:get-effectivename en0) (@:get-config 'vitaltools:tukuang))
- (progn
- (setq ss-list (append ss-list (list en0)))
- ))
- (setq ti% (+ 1 ti%))
- )
- )
- (progn
- (alert (strcat "未选中任何图框,请检查配置文件中你的图框块名是 "
- (@:get-config 'vitaltools:tukuang)))
- (@:edit-config))
- )
- (vl-sort ss-list
- '(lambda (en1 en2)
- (if (> (caddr (assoc 10 (entget en1)))
- (+ 1000 (caddr (assoc 10 (entget en2)))))
- T
- (if (and (< (caddr (assoc 10 (entget en1)))
- (+ 1000 (caddr (assoc 10 (entget en2)))))
- (> (caddr (assoc 10 (entget en1)))
- (- (caddr (assoc 10 (entget en2))) 1000))
- (< (cadr (assoc 10 (entget en1)))
- (cadr (assoc 10 (entget en2)))))
- T
- nil)
- ))))
- (@:add-menu "工程管理" "自动编图号" "(@:set-tuhao (@:get-frames))")
- (defun @:set-tuhao (ss-list / num1 start )
- (setq start (getint "请输入图纸起始编号<1>:"))
- (if (null start) (setq start 1))
- (setq num1 0)
- ;;(print (length ss-list))
- (foreach en0 ss-list
- (block:set-attributes
- en0
- (list (cons "图号"
- (strcat (if (@:get-tubie (block:get-attributes en0))
- (strcat (@:get-tubie (block:get-attributes en0))
- "-")
- "")
- (if (< (+ num1 start) 10) "0" "")
- (itoa (+ num1 start))))))
- (setq num1 (1+ num1))
- ))
|