AutoCAD贴标插件



我需要单独标记多个块。是否有可能在AutoCAD中编写代码它会找到每个单独的块并在上面写一个标签?

在LISP中你可以这样做:

(vl-load-com)
(defun GetThisDrawing ( / ) 
(vla-get-activedocument (vlax-get-acad-object) )
)
(defun GetActivespace ( / space ) 
(setq space (if (zerop (vla-get-activespace (GetThisDrawing)))
(if (= (vla-get-mspace (GetThisDrawing)) :vlax-true)
(vla-get-modelspace (GetThisDrawing))
(vla-get-paperspace (GetThisDrawing)))
(vla-get-modelspace (GetThisDrawing))) )
)
(defun C:MarkBlock (  / BlockName filter blocks sl i % Position msg label )
(setq BlockName "name_of_your_block")
(setq filter (list (cons 0 "INSERT") (cons 2 BlockName) ))
(setq blocks (ssget "X" filter) )
(setq sl (sslength blocks))
(setq i 0)
(repeat sl
(setq % (vlax-ename->vla-object(ssname blocks i) ))
(vlax-get-property  % 'InsertionPoint )
(setq Position (vlax-get-property  % 'InsertionPoint ) )
(setq msg (vlax-get-property  % 'Name ) )
(setq label (vlax-invoke-method (GetActivespace) 'AddMText Position 0 msg ) )
(setq i (1+ i ) )
)
)

最新更新