SuperCAD 发表于 2022-7-6 00:37:36

通气更新(见第10篇)

BIGAL 发表于 2022-7-6 00:39:48

你在跑步吗?由于使用lisp很容易,您只需制作一个布局名称列表,长度为1(模型)=没有选项卡。使用它的唯一规则是不要垃圾布局。不过,您可以删除某些名称的布局,只需稍微复杂一点。

SuperCAD 发表于 2022-7-6 00:47:15

我正在运行2012/2013年ACAD。我不太擅长LISP或宏。我只是从这个开始。

BIGAL 发表于 2022-7-6 00:48:10

读一读这本应该做你想做的事。只需更改块名和标记名。
 
; change the 410 to layout name

;;-------------------=={ Parse Numbers }==--------------------;;
;;                                                            ;;
;;Parses a list of numerical values from a supplied string. ;;
;;------------------------------------------------------------;;
;;Author: Lee Mac, Copyright © 2011 - www.lee-mac.com       ;;
;;------------------------------------------------------------;;
;;Arguments:                                                ;;
;;s - String to process                                     ;;
;;------------------------------------------------------------;;
;;Returns:List of numerical values found in string.       ;;
;;------------------------------------------------------------;;

(defun LM:ParseNumbers ( s )
(
   (lambda ( l )
   (read
       (strcat "("
         (vl-list->string
         (mapcar
             (function
               (lambda ( a b c )
               (if
                   (or
                     (< 47 b 58)
                     (and (= 45 b) (< 47 c 58) (not (< 47 a 58)))
                     (and (= 46 b) (< 47 a 58) (< 47 c 58))
                   )
                   b 32
               )
               )
             )
             (cons nil l) l (append (cdr l) (list nil))
         )
         )
         ")"
       )
   )
   )
   (vl-string->list s)
)
)

;(defun ah:sheetupdate1 (ss1 lay plotabs tabname dwgname)
(defun ah:sheetupdate1 ()
(setq doc (vla-get-activedocument (vlax-get-acad-object)))

(vlax-for lay (vla-get-Layouts doc)
(setq plotabs (cons (vla-get-name lay) plotabs))
)

(setq len (length plotabs))
(setq tabsqty (- len 1)) ; remove model from number of layouts
(setq x 0)
(setq bname "DA1DRTXT") ; title block name
(repeat len
(setq tabname (nth x plotabs))
(if (/= tabname "Model")
   (progn
   (setvar "ctab" tabname)

   (setq ss1 (ssget "x"(list (cons 0 "INSERT") (cons 2 bname)(cons 410 tabname))))
   (setq dwgnum (Lm:parsenumbers tabname))
   (setq sheetnum (car dwgnum))
   (setq oldtag1 "SHT_NO") ;attribute tag name
   (setq newstr1 (rtos sheetnum 2 0))

   (setq oldtag3 "SHT_QTY") ;attribute tag name
   (setq newstr3 tabsqty)

; if less than 10
(if (< (car dwgnum) 10.0)
   (setq newstr2 (strcat dwgname "-D0"(rtos sheetnum 2 0)))
   (setq newstr2 (strcat dwgname "-D"(rtos sheetnum 2 0)))
)
   (foreach att (vlax-invoke (vlax-ename->vla-object (ssname SS1 0 )) 'getattributes)
       (if (= oldtag1 (strcase (vla-get-tagstring att)))
       (vla-put-textstring att newstr1) ; change attribute value
       ) ; end if

      (if (= oldtag3 (strcase (vla-get-tagstring att)))
       (vla-put-textstring att newstr3) ; change attribute value
       ) ; end if

      ) ; end foreach
   ) ; end progn
) ; end if
(setq x (+ x 1))
) ; end repeat
(setq ss1 nil)
) ; end defun ah

(ah:sheetupdate1)

(princ)
页: 1 [2]
查看完整版本: 使用AutoLISP进行图纸编号,