Display full version of the post: Extracting specific text from AutoCAD dwg to txt f

aglasier
28.05.2018, 21:06
I am attempting to extract data from drawings given to me that do not have attributes assigned to certain text blocks. I do know the data I want will contain either "MARK", "ETCH", or "STAMP".I have tried entering (ssget "_X" '((0 . "TEXT,MTEXT")(1 . "ETCH*,MARK*,STAMP*"))) at the "select objects" prompt which will select the text blocks I am looking for but when I run it with my lisp routine I get an error: "; error: bad argument type: stringp nil"I am however able to pick up the text I need with DATAEXTRACTION but I'm not sure if there's a way filter out text with value I do not care about.I am still new to lisp and data extraction so bare with me lolBelow is my current lisp routine which works for data that has attributes, what I did was replace the current ssget command with the one i mentioned above to get that error.(defun c:att-out (/ dn)
(load "attout")
(setq dn (getvar "dwgname"))
(setq fna (strcat "C:/Users/Allan/Desktop/LISP/dump/" dn ".txt"))
(setq ss (ssget '((0 . "INSERT") (66 . 1))))
(bns_attout fna ss)
)
I have also thought of just using DATAEXTRACTION to grab everything and sorting it out in excel but it would be easier if I could avoid that. Any help to put me on the right track would be greatly appreciated.I apologize if i did not include everything you need here, just let me know if you need more information and I will be happy to supply it.

Vladimir Michl
28.05.2018, 21:35
The (ssget) function you are using is correct. Only the "Select objects:" prompt should come from a standard editing command, not from an add-on application. LISP calls cannot be nested.

aglasier
28.05.2018, 21:51
Thank you for the reply Valdimir, So I'm on the right track to selecting the objects I need, how would I go about writing a lisp routine to extract that specific data? Or is there another route that would be better to take with this?Some background might be useful, the reason I'm doing this is to verify all of the data on the drawings are correct. I can get most of it with the Data extraction tool but as far as i'm aware you cannot specify which text to grab like I can with the ssget function. Once this is working it will be used on many different drawings at once so i'm trying to write something to automate that process a bit.