这就是我一直在做的。它再次使用了member和assoc的组合。我假设您只想提取文本字符串,而不是替换它?因为如果你想替换它,我通常在同一个while循环中提取对象ID。
;get the attributes for the block(setq tmp1 (member (assoc 344[color=black] elist[/color]) elist))[color=red] ;cut out the irrelevant (and duplicated car) earlier codes[/color](while (setq tmp1 (member (assoc 330 tmp1) tmp1)) (setq attdata (cons (list (cdr (assoc 177 tmp1))[color=red] ;attribute number - this becomes important if the text has fields in it[/color] (cdr (assoc 302 tmp1))[color=red] ;the attribute string itself[/color] (= (cdr (assoc 101 (entget (cdr (assoc 330 tmp1))))) "Embedded Object")[color=red] ;single or multiline attribute - this becomes important if you want to know which formatting strings might be present[/color] ) attdata ) tmp1 (cdr tmp1) ) );while;if attributes(if attdata [color=blue]....process them[/color] )