Douglas K. Christensen
When passed a block handle, the following function builds 3 lists for attribute data in a block.
1. A list of the attribute Tags, tagLst
2. A list of the attribute Values, datLst
3. A list of the attribute entity Handles, hdlLst
As is, it ignores constants since they are constant and therefore their value should already be known. To retrieve the
value, change to the following;
(IF (= "ATTDEF" (dxfData 0 data))
(SETQ
tagLst(APPEND tagLst(LIST (dxfData 2 data)))
datLst(APPEND datLst(LIST (dxfData 1 data)))
hdlLst(APPEND hdlLst(LIST handle))
)
;=============================================================================
(DEFUN getAttData(handle / data)
(SETQ
tagLst NIL
datLst NIL
hdlLst NIL
)
(IF (/= (dxfData 66 (ENTGET handle)) NIL)
(WHILE (/= "SEQEND" (dxfData 0 (ENTGET (SETQ handle (ENTNEXT handle)))))
(SETQ data(ENTGET handle))
(IF (= "ATTRIB" (dxfData 0 data))
(IF (OR (/= "ATTDEF" (dxfData 0 data))
(/= 0 (LOGAND 2 (dxfData 70 data))))
(PROGN
(SETQ
tagLst(APPEND tagLst(LIST (dxfData 2 data)))
datLst(APPEND datLst(LIST (dxfData 1 data)))
hdlLst(APPEND hdlLst(LIST handle))
)
)
)
)
)
)
)
;============================================================================
(DEFUN dxfData (dxfCode entityData)
(CDR (ASSOC dxfCode entityData))
)
;============================================================================
Cheers,
Lu
;-----------------------------------------------------------------------
; When all else fails, read the book. But there ain't none no more! <g>
; CAD-Tek web site: http://www.cad-tek.com
;-----------------------------------------------------------------------
Hi Douglas! I think if you use ENTNRXT function and go through every
entyty in the drawing checking if it is INSERT than open file ouside
AutoCAD (or create a list inside) and store attribute info like one line
TAG next VALUE and use SEQEND to go through all attributes in each block.
Put it in a loop and you will get a text file (or list) vith all data.
You can find good example of code in one of CADALIST magazine files on
the INTERNET CHAT.LSP I have copy of it but I modified it for my needs.
It is in reverse of what you are doing Reading info into the block. so it
is not original (lost the genuan one) any way I am attaching it blow
Principals are the same (defun C:chat (/ fp att val tg nvl a n i e k e1 d
d1 e5) (setq fp (open "cha.txt" "r")) (while (while (setq ATT
(read-line fp)) (setq VAL (read-line fp)) (setq tg ATT) (setq tg
(strcase tg)) (setq nvl VAL) (setq a (ssget "X" ' ((2 . "samctbe"))))
(setq n (sslength a)) (setq i 0) (repeat n (setq e (entget (ssname a
i))) (setq i (+ i 1)) (if (= (cdr (assoc 0 e)) "INSERT") (progn (setq
k 1) (while k (setq e1 (entget (entnext (cdr (assoc -1 e))))) (if (=
(cdr (assoc 0 e1)) "ATTRIB") (progn (if (= (cdr (assoc 2 e1)) tg)
(progn (setq d (assoc 1 e1)) (setq d1 (cons 1 nvl)) (setq e5 (subst d1
d e1)) (entmod e5) ) ) ) ) (if (= (cdr (assoc 0 e1)) "SEQEND")(setq
k nil)) (setq e e1) ) ) ) ) (princ) ) ) (close fp)
(command"regen") )
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
Douglas,
There is a utility that will do exactly what you need to do. The product
is CADLynx. Go to http://www.cadlynx.com and download a fully functional
copy of CADLynx and try it on your drawings. It works directly against the
AutoCAD .DWG files and extract the attribute information into an ACCESS
database. After you have downloaded a copy and installed it, you should be
up and running in less than 10-15 minutes.
We have used the product against a batch of 100's of drawings with it
extracting each drawing in less than 1 minute each. To do the same in
AutoCAD with AutoLISP took days to get the program to work and over a day
to perform all of the extractions. CADLynx is much, much faster and
easier. Try it out. I think you will like it.
John
Douglas K. Christensen <Douglas.C...@Newnes.com> wrote in article
<65hoi6$2sv$1...@fountain.mindlink.net>...
To an unsuspecting prospect, this message appears to be an independent
testimonial from a satisfied user. Please clarify your relationship to
CADLynx in your messages. :)
--
Owen Wengerd
President, ManuSoft ==> http://www.manusoft.com
VP Americas, CADLock, Inc. ==> http://www.cadlock.com
John H. Jones wrote in article <01bcfbb5$2960e6c0$ed2479a8@april>...
>
>Douglas,
>
>There is a utility that will do exactly what you need to do. The product
>is CADLynx. Go to http://www.cadlynx.com and download a fully functional
>copy of CADLynx and try it on your drawings. It works directly against the
>AutoCAD .DWG files and extract the attribute information into an ACCESS
>database. After you have downloaded a copy and installed it, you should be
>up and running in less than 10-15 minutes.
>
>We have used the product against a batch of 100's of drawings with it
>extracting each drawing in less than 1 minute each. To do the same in
>AutoCAD with AutoLISP took days to get the program to work and over a day
>to perform all of the extractions. CADLynx is much, much faster and
>easier. Try it out. I think you will like it.
>
>John
>[...]