从属性中提取数据
我收到了一个包含许多属性的图形,如附件中的属性。dxf文件。我用以下代码提取了cutnam标记:
(cdr (assoc 2 (entget (car (entsel))))但我找不到提取房间面积标签数据的方法(在图纸中为“10.90m”)。
属性dxf 你可以用这样的东西:
(defun vanilla_getatts ( e / enx L )
(cond
( (not (eq 'ENAME (type e))) (prompt "\nNo ename selected.") )
( (not (member '(0 . "INSERT") (setq enx (entget e)))) (prompt "\nNo block selected.") )
( (/= 1 (logand 1 (cdr (assoc 66 enx)))) (prompt "\nBlock is not attributed.") )
( (setq e (entnext e)) (setq enx (entget e))
(while (= "ATTRIB" (cdr (assoc 0 enx)))
(setq L (cons (cons (cdr (assoc 2 enx)) (cdr (assoc 1 enx))) L))
(setq e (entnext e)) (setq enx (entget e))
)
L
)
)
); defun vanilla_getatts
例子:
(vanilla_getatts (car (entsel "\nPick attributed block: ")))
应该返回
(("DUMMY_103" . "2") ("cutnam" . "Szoba") ("pbn" . "lam.park.") ("ROOM_AREA" . "10,90 m") ("ROOM_NUMBER" . "A.203"))
那么你只需要使用(cdr(assoc“ROOM\u AREA”…)以获得所需的标签值。
已经有一段时间了,因为我完全练习香草了。
编辑:我将提到李·麦克的这些属性函数。 再多一点
(defun c:test ( / lst ans)
(setq lst (vanilla_getatts (car (entsel "\nPick attributed block: ")))))
(setq tagname (getstring "Please enter tag name"))
(setq x 0)
(repeat (length lst)
(if (= (nth 0 (nth x lst)) tagname)(setq ans (cdr (assoc tagname lst))))
(setq x (+ x 1))
)
(alert (strcat "Value is = " ans))
)
谢谢你们俩!
页:
[1]