明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2155|回复: 3

请问怎样读取属性块中的数据 并修改

[复制链接]
发表于 2004-8-11 15:50:00 | 显示全部楼层 |阅读模式
回答《请问怎样读取属性块中的数据》之高手,请问如何在此基础上修改属性值,我试过ENTMOD,ENTUPD屏幕都没改,但改动属性值中的提示却可以,
发表于 2004-8-11 23:38:00 | 显示全部楼层

回复

我写过Visual Lisp的代码,明天上传.
发表于 2004-8-12 09:01:00 | 显示全部楼层
;;actj2k是块名,L1,L2等是属性标记(Tag)
(vl-load-com) (defun c:mychange ( / ss item blk)
(if (setq ss (vlex-SelectOnScreen-Filter (list 0 2)(list "INSERT" "actj2tk")))
(vlax-For item ss
(if (equal (type item) 'vla-object)
(setq blk (vlax-vla-object->Ename item))
(setq blk item)
)
(vlex-ChangeAttributes (list blk (cons "L1" "a")))
(vlex-ChangeAttributes (list blk (cons "L2" "b")))
(vlex-ChangeAttributes (list blk (cons "R3" "c")))
(terpri)
)
)
) (defun vlex-SSetExists-p (Name)
(not
(vl-Catch-All-Error-p
(vl-Catch-All-Apply
'vla-Item
(list (vla-Get-SelectionSets (vlex-ActiveDocument)) Name)
)
)
)
) (defun vlex-SelectOnScreen-Filter (GroupCodes FilterLists / ss)
(if (vlex-SSetExists-p "%TEMP_SET")
(vla-Delete
(vla-Item
(vla-get-SelectionSets (vlex-ActiveDocument))
"%TEMP_SET"
)
)
)
(setq ss
(vla-Add
(vla-get-SelectionSets (vlex-ActiveDocument))
"%TEMP_SET"
)
)
(vla-Select ss
ACSelectionSetAll nil nil
(vlex-IntList->VarArray GroupCodes)
(vlex-VarList->VarArray FilterLists)
)
ss
) (defun vlex-VarList->VarArray (aList)
(vlax-SafeArray-Fill
(vlax-Make-SafeArray
vlax-vbVariant ;(12) Variant
(cons 0 (- (length aList) 1))
)
aList
)
) (defun vlex-IntList->VarArray (aList)
(vlax-SafeArray-Fill
(vlax-Make-SafeArray
vlax-vbInteger ; (2) Integer
(cons 0 (- (length aList) 1))
)
aList
)
) (defun vlex-ChangeAttributes (lst / blk item atts)
(setq blk (vlax-Ename->vla-Object (car lst))
lst (cdr lst)
)
(if (= (vla-Get-HasAttributes blk) :vlax-true)
(progn
(setq atts (vlax-SafeArray->list
(vlax-Variant-Value (vla-GetAttributes blk))
)
); setq
(foreach item lst
(mapcar
'(lambda (x)
(if (= (strcase (car item)) (strcase (vla-Get-TagString x)))
(vla-Put-TextString x (cdr item))
); endif
)
atts
); mapcar
); foreach
(vla-Update blk)
)
); endif
) (defun vlex-ActiveDocument ()
(vla-Get-ActiveDocument (vlax-get-acad-object))
)
 楼主| 发表于 2004-8-12 12:26:00 | 显示全部楼层
(Defun Si (/ slist sname etbll)
(setq sliST (entget (ssname (ssget) 0)))
(SetQ sname (Cdr (Assoc 2 sliST)) sli (TblSearch "BLOCK" sname) )
(SetQ sname (Cdr (Assoc -2 sliST)))
(While sname
(setq slist (entget sname))
(if (/= (cdr (assoc 3 slist)) nil)
(progn

(SETQ slist(SUBST (cons 1 "bbbb") (assoc 1 slist) slist))

(ENTMOD slist)
(entupd sname)
)
)
(setq sname (EntNext sname))
)
;(entupd sli)
(princ)
)
屏幕没刷新
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-18 21:28 , Processed in 0.163993 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表