请问怎样读取属性块中的数据 并修改
回答《<B>请问怎样读取属性块中的数据》之高手,请问如何在此基础上修改属性值,我试过ENTMOD,ENTUPD屏幕都没改,但改动属性值中的提示却可以,</B>回复
我写过Visual Lisp的代码,明天上传. ;;actj2k是块名,L1,L2等是属性标记(Tag)<BR>(vl-load-com)
(defun c:mychange ( / ss item blk)<BR> (if (setq ss (vlex-SelectOnScreen-Filter (list 0 2)(list "INSERT" "actj2tk")))<BR> (vlax-For item ss<BR> (if (equal (type item) 'vla-object)<BR> (setq blk (vlax-vla-object->Ename item))<BR> (setq blk item)<BR> )<BR> (vlex-ChangeAttributes (list blk (cons "L1" "a")))<BR> (vlex-ChangeAttributes (list blk (cons "L2" "b")))<BR> (vlex-ChangeAttributes (list blk (cons "R3" "c")))<BR> (terpri)<BR> )<BR> )<BR>)
(defun vlex-SSetExists-p (Name)<BR> (not<BR> (vl-Catch-All-Error-p<BR> (vl-Catch-All-Apply<BR> 'vla-Item<BR> (list (vla-Get-SelectionSets (vlex-ActiveDocument)) Name)<BR> )<BR> )<BR> )<BR>)
(defun vlex-SelectOnScreen-Filter (GroupCodes FilterLists / ss)<BR> (if (vlex-SSetExists-p "%TEMP_SET")<BR> (vla-Delete<BR> (vla-Item<BR> (vla-get-SelectionSets (vlex-ActiveDocument))<BR> "%TEMP_SET"<BR> )<BR> )<BR> )<BR> (setq ss<BR> (vla-Add<BR> (vla-get-SelectionSets (vlex-ActiveDocument))<BR> "%TEMP_SET"<BR> )<BR> )<BR> (vla-Select ss<BR> ACSelectionSetAll nil nil <BR> (vlex-IntList->VarArray GroupCodes)<BR> (vlex-VarList->VarArray FilterLists)<BR> )<BR> ss<BR>)
(defun vlex-VarList->VarArray (aList)<BR> (vlax-SafeArray-Fill<BR> (vlax-Make-SafeArray<BR> vlax-vbVariant ;(12) Variant<BR> (cons 0 (- (length aList) 1))<BR> )<BR> aList<BR> )<BR>)
(defun vlex-IntList->VarArray (aList)<BR> (vlax-SafeArray-Fill<BR> (vlax-Make-SafeArray<BR> vlax-vbInteger ; (2) Integer<BR> (cons 0 (- (length aList) 1))<BR> )<BR> aList<BR> )<BR>)
(defun vlex-ChangeAttributes (lst / blk item atts)<BR> (setq blk (vlax-Ename->vla-Object (car lst))<BR> lst (cdr lst)<BR> )<BR> (if (= (vla-Get-HasAttributes blk) :vlax-true)<BR> (progn<BR> (setq atts (vlax-SafeArray->list<BR> (vlax-Variant-Value (vla-GetAttributes blk))<BR> )<BR> ); setq<BR> (foreach item lst<BR> (mapcar<BR> '(lambda (x)<BR> (if (= (strcase (car item)) (strcase (vla-Get-TagString x)))<BR> (vla-Put-TextString x (cdr item))<BR> ); endif<BR> )<BR> atts<BR> ); mapcar<BR> ); foreach<BR> (vla-Update blk)<BR> )<BR> ); endif<BR>)
(defun vlex-ActiveDocument ()<BR> (vla-Get-ActiveDocument (vlax-get-acad-object))<BR>) (Defun Si (/ slist sname etbll)<BR> (setq sliST (entget (ssname (ssget) 0)))<BR> (SetQ sname (Cdr (Assoc 2 sliST)) sli (TblSearch "BLOCK" sname) )<BR> (SetQ sname (Cdr (Assoc -2 sliST)))<BR> (While sname<BR> (setq slist (entget sname))<BR>
(if (/= (cdr (assoc 3 slist)) nil)<BR> (progn<BR> <BR> (SETQ slist(SUBST (cons 1 "bbbb") (assoc 1 slist) slist))<BR> <BR> (ENTMOD slist)<BR> (entupd sname)<BR> )<BR> )<BR> (setq sname (EntNext sname)) <BR> )<BR> ;(entupd sli)<BR>
(princ)<BR> )<BR>屏幕没刷新
页:
[1]