马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
;;给动态快增加属性定义
 - (defun c:addattribs ( / blk def )
- (while
- (not
- (or (= "" (setq blk (getstring t "\nName of block to update: ")))
- (tblsearch "BLOCK" blk)
- )
- )
- (princ (strcat "\nBlock \"" blk "\" not found."))
- )
- (if (/= "" blk)
- (progn
- (setq def (vla-item (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) blk))
- (vla-addattribute def
- (getvar 'textsize)
- acattributemodelockposition
- "New Attribute 1"
- (vlax-3D-point 0 0)
- "NEW_TAG1"
- "New Value 1"
- )
- (vla-addattribute def
- (getvar 'textsize)
- acattributemodelockposition
- "New Attribute 2"
- (vlax-3D-point 0 (- (* 1.5 (getvar 'textsize))))
- "NEW_TAG2"
- "New Value 2"
- )
- (command "_.attsync" "_N" blk)
- )
- )
- (princ)
- )
- (vl-load-com) (princ)
另一个方法:
[it618postdisplay>0]
 - (defun c:adsk (/ ss pt i ent elist)
- ; Get Entities
- (while (not ss)
- (princ "\nSelect Objects to Convert to Blocks:")
- (setq ss (ssget '((-4 . "<NOT") (0 . "INSERT,POLYLINE,VIEWPORT") (-4 . "NOT>"))))
- ) ;_ end while
- ; Get Block Name and Base Point
- (while (or (not bn)
- (not (snvalid bn))
- ) ;_ end or
- (setq bn (getstring "Specify Block Name: "))
- ) ;_ end while
- (initget 1)
- (setq pt (getpoint "Specify Base Point for Block: "))
- ;;; Create BLOCK Header
- (entmake (list (cons 0 "BLOCK") (cons 10 pt) (cons 2 bn) (cons 70 0)))
- ;;;STEP THRU THE SET
- (setq i (sslength ss))
- (while (>= i (setq i (1- i)) 0)
- (setq ent (ssname ss i)
- elist (entget ent)
- ) ;_ end setq
- (entmake elist)
- ) ;_ end while
- ;;;FINISH THE BLOCK DEFINITION
- (entmake (list (cons 0 "ENDBLK") (cons 8 "0")))
- ;;;Insert the Block & Delete Originals
- (entmake (list (cons 0 "INSERT") (cons 2 bn) (cons 8 "0") (cons 10 pt)))
- (command "_.ERASE" ss "")
- (redraw)
- (AddAttribs)
- (prin1)
- ) ;_ end defun
- ;;
- (defun addattribs ( / blk def)
- (while
- (not
- (or (= "" (setq blk bn))
- (tblsearch "BLOCK" blk)
- )
- )
- (princ (strcat "\nBlock \"" blk "\" not found."))
- )
- (if (/= "" blk)
- (progn
- (setq def (vla-item (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) blk))
- (vla-addattribute def
- (getvar 'textsize)
- acattributemodelockposition
- "New Attribute 1"
- (vlax-3D-point 0 0)
- "NEW_TAG1"
- "New Value 1"
- )
- (vla-addattribute def
- (getvar 'textsize)
- acattributemodelockposition
- "New Attribute 2"
- (vlax-3D-point 0 (- (* 1.5 (getvar 'textsize))))
- "NEW_TAG2"
- "New Value 2"
- )
- (command "_.attsync" "_N" blk)
- )
- )
- (princ)
- )
- (vl-load-com) (princ)
[/it618postdisplay]
|