cad自动进行桩位编号 - kmliang

时间:2024-02-20 15:55:49

cad自动进行桩位编号

加载AutoLabelAttributesV1-0.lsp

;;-----------------=={ AutoLabel Attributes }==---------------;;
;;                                                            ;;
;;  Automatically labels a specific attribute in a set of     ;;
;;  blocks, renumbering if blocks are added, copied or        ;;
;;  erased.                                                   ;;
;;------------------------------------------------------------;;
;;  Author: Lee Mac, Copyright ?2011 - www.lee-mac.com       ;;
;;------------------------------------------------------------;;
;;  Version 1.0    -    14-09-2011                            ;;
;;------------------------------------------------------------;;

;;------------------------------------------------------------;;
;;                         Settings                           ;;
;;------------------------------------------------------------;;

;; [Note: Block names and Attribute Tags are *not* case-sensitive]

(setq *blockname* "c1"  ;; Name of Block to be Updated
      *blocktag*  "1"    ;; Attribute Tag to be Updated
)

;;------------------------------------------------------------;;
;;                      Main Program                          ;;
;;------------------------------------------------------------;;

(defun ObjectReactorCallback:RenumberBlocks ( object reactor params )
    (setq *reactor* reactor)
    (vlr-command-reactor "temp" \'((:vlr-commandended . CommandReactorCallback:RenumberBlocks)))
    (vlr-remove  reactor)
    (princ)
)

;;------------------------------------------------------------;;

(defun CommandReactorCallback:RenumberBlocks ( reactor params / e f i l n s )
    (if reactor (vlr-remove reactor))
    (if
        (and
            (not *undoflag*)
            (setq s (ssget "_X" *filter*))
        )
        (progn
            (setq n 0)
            (repeat (setq i (sslength s))
                (if (eq *blockname*
                        (AutoLabel:EffectiveName
                            (setq o (vlax-ename->vla-object (setq e (ssname s (setq i (1- i))))))
                        )
                    )
                    (progn
                        (setq e (entnext e)
                              l (entget  e)
                              f nil
                        )
                        (while (and (not f) (eq "ATTRIB" (cdr (assoc 0 l))))
                            (if (eq *blocktag*  (strcase (cdr (assoc 2 l))))
                                (setq f (entmod (subst (cons 1 (itoa (setq n (1+ n)))) (assoc 1 l) l)))
                            )
                            (setq e (entnext e)
                                  l (entget  e)
                            )
                        )
                        (if (and *reactor* (not (member o (vlr-owners *reactor*))))
                            (vlr-owner-add *reactor* o)
                        )
                    )
                )
            )
        )
    )
    (if *reactor*
        (progn (vlr-add *reactor*) (setq *reactor* nil))
    )
    (princ)
)

;;------------------------------------------------------------;;

(defun CommandReactorCallback:UndoCheck ( reactor params )
    (setq *undoflag* (wcmatch (strcase (car params)) "*U,*UNDO"))
    (princ)
)

;;------------------------------------------------------------;;

(defun CommandReactorCallback:BlockInserted ( reactor params / e l )
    (if
        (and
            (not *undoflag*)
            (wcmatch (strcase (car params)) "*I,*INSERT,*EXECUTETOOL")
            (setq e (entlast))
            (setq l (entget e))
            (eq "INSERT" (cdr (assoc 0 l)))
            (= 1 (cdr (assoc 66 l)))
            (eq *blockname* (AutoLabel:EffectiveName (vlax-ename->vla-object e)))
        )
        (AutoLabel:GetNewNumber e)
    )
    (princ)
)

;;------------------------------------------------------------;;

(defun AutoLabel:GetNewNumber ( ent / e f i l n r s )
    (if (setq s (ssget "_X" *filter*))
        (progn
            (setq n 0)
            (repeat (setq i (sslength s))
                (if (eq *blockname*
                        (AutoLabel:Effectivename
                            (vlax-ename->vla-object (ssname s (setq i (1- i))))
                        )
                    )
                    (setq n (1+ n))
                )
            )
            (setq e (entnext ent)
                  l (entget e)
            )
            (while (and (not f) (eq "ATTRIB" (cdr (assoc 0 l))))
                (if (eq *blocktag*  (strcase (cdr (assoc 2 l))))
                    (setq f (entmod (subst (cons 1 (itoa n)) (assoc 1 l) l)))
                )
                (setq e (entnext e)
                      l (entget  e)
                )
            )
            (if
                (setq r
                    (vl-some
                        (function
                            (lambda ( r ) (if (eq *reacdata* (vlr-data r)) r))
                        )
                        (cdar (vlr-reactors :vlr-object-reactor))
                    )
                )
                (vlr-owner-add r (vlax-ename->vla-object ent))
            )                            
        )
    )
    (princ)
)

;;------------------------------------------------------------;;

(defun AutoLabel:EffectiveName ( obj )
    (strcase
        (if (vlax-property-available-p obj \'effectivename)
            (vla-get-effectivename obj)
            (vla-get-name obj)
        )
    )
)

;;------------------------------------------------------------;;
;;                   Loading Expressions                      ;;
;;------------------------------------------------------------;;

(vl-load-com)

(
    (lambda ( / i s l o )
        (setq
            *blocktag*  (strcase *blocktag*)
            *blockname* (strcase *blockname*)
            *reacdata*  "AutoBlockLabel"
            *reactor*   nil
            *undoflag*  nil
        )
        (foreach r1 (vlr-reactors)
            (foreach r2 (cdr r1)
                (if (eq *reacdata* (vlr-data r2)) (vlr-remove r2))
            )
        )
        (if
            (setq s
                (ssget "_X"
                    (setq *filter*
                        (list
                           \'(0 . "INSERT")
                           \'(66 . 1)
                            (cons 2 (strcat "`*U*," *blockname*))
                            (cons 410 (getvar \'CTAB))
                        )
                    )
                )
            )
            (progn
                (repeat (setq i (sslength s))
                    (if (eq *blockname*
                            (AutoLabel:EffectiveName
                                (setq o (vlax-ename->vla-object (ssname s (setq i (1- i)))))
                            )
                        )
                        (setq l (cons o l))
                    )
                )
                (CommandReactorCallback:RenumberBlocks nil nil)
                (vlr-object-reactor l *reacdata*
                    (list
                        (cons :vlr-erased   \'ObjectReactorCallback:RenumberBlocks)
                        (cons :vlr-copied   \'ObjectReactorCallback:RenumberBlocks)
                        (cons :vlr-unerased \'ObjectReactorCallback:RenumberBlocks)
                    )
                )
                (vlr-command-reactor *reacdata*
                    (list
                        (cons :vlr-commandwillstart \'CommandReactorCallback:UndoCheck)
                        (cons :vlr-commandended     \'CommandReactorCallback:BlockInserted)
                    )
                )
            )
        )
    )
)

(princ)

;;------------------------------------------------------------;;
;;                         End of File                        ;;
;;------------------------------------------------------------;;

 教程:

基坑支护桩位编号及坐标提取插件应用

一、支护桩桩位编号

第一步:首先CAD内使用定义属性命令att,如图:

 

 

标记位置输入任意数字,此处以“1”为列子,确认后将1放于即将编号的桩位旁。

第二步:找到绘图-块-创建块命令,如图:

 

注:此处名称后面会应用,且多次编号的名称不能重复。

名称输入任意数字,此处以“123”为例子,点击选择对象,选取刚创建的数字1空格。弹出新对话框,直接确认,如图:

 

注:此处标记的数字为即将编号的起始数字,后面会应用。

此处以数字“1”作为例子,然后确认。

第三步:打开插件,如图:

 

将前面设置的名称和标记输入对应位置并保存,如图:

 

第四步:找到工具-加载应用程序,选择插件加载,如图:

 

第五步:CP复制数字1按顺序往后,空格后会自动生成编号。如图:

 

 

 

 

二、桩位坐标拾取

第一步:使用PL多线段命令,对象捕捉修改为仅捕捉圆心,将所有要拾取坐标的桩位中心点进行连线。如图:

 

第二步:选中刚画出的多段线,输入LI命令,空格,将弹出窗口内的内容复制到Excel工作表。如图:

 

 

第三步:工作表内找到数据-分列,选中分隔符号-下一步,设置“空格和=分列”,继续下一步完成,如图:

 

 

第四步:调整板式。如图:

 

三、有用得上的请保留,用不上的请勿喷,谢谢。教程有写得不清楚的地方请致电15288211020。

附赠办公室无天正软件时,CAD坐标标注插件。

 (详细后附压缩包)