我从这里得到了下面的大部分代码
我试图做的是从块中读取属性值和标记(块有多个属性)。当我(普林斯)它,它返回零。我做错了什么?
谢谢
- (defun c:sk (/)
- (if (setq ent(entsel "\n Select a Block: ")) ;- Let the user select a block
- (progn
- (setq en(car ent)) ;- Get the entity name of the block
- (setq enlist(entget en)) ;- Get the DXF group codes
- (setq blkType(cdr(assoc 0 enlist))) ;- Save the type of entity
- (if (= blkType "INSERT") ;- If the entity type is an Insert entity
- (progn
- (if(= (cdr(assoc 66 enlist)) 1) ;- See if the attribute flag equals one (if so, attributes follow)
- (progn
- (setq en2(entnext en)) ;- Get the next sub-entity
- (setq enlist2(entget en2)) ;- Get the DXF group codes
- (while (/= (cdr(assoc 0 enlist2)) "SEQEND") ;- Start the while loop and keep
- (princ "\n ") ;-Print a new line
- (princ enlist2) ;- Print the attribute DXF group codes
- (setq en2(entnext en2)) ;- Get the next sub-entity
- (setq enlist2(entget en2)) ;- Get the DXF group codes
- )
- )
- ) ;- Close the if group code 66 = 1 statement
- )
- ) ;- Close the if block type = "ATTRIB" statement
- )
- ) ;- Close the if an Entity is selected statement
- [color=Red](setq att_value (cdr (assoc 1 enlist2)))
- (princ "\nAtt_value : ")
- (princ att_value)
- (setq att_tag (cdr (assoc 2 enlist2)))
- (princ "\nAtt_tag : ")
- (princ att_tag)
- [/color]
- )
|