wannabe Posted January 5, 2009 Posted January 5, 2009 There is a chance the error may be related to the format of the .txt file I tried to use. I'll update when confirmed. Quote
wannabe Posted January 5, 2009 Posted January 5, 2009 Definitely a problem with the .txt file. I have tried everything, but only on list of coordinates works. Ive even tried to replicate the structure of that file but to no avail. Quote
wannabe Posted January 5, 2009 Posted January 5, 2009 Ok, I have some good news. Basically, to make the coordinates text file readable to the lisp they need to be saved as an rtf in word and then saved as a plain text .txt file format, with a comma separating the coordinates. As for the automatic identification entry, it just asks me to manually type in the information to populate this attribute for the block. Which is a slight problem in the fact I don't know which order they are inserted. Any help appreciated. Quote
eldon Posted January 5, 2009 Posted January 5, 2009 Basically, to make the coordinates text file readable to the lisp they need to be saved as an rtf in word and then saved as a plain text .txt file format, with a comma separating the coordinates. A little hint to make things more simple, would be to open your coordinate file in Excel, then you can save as a CSV file format, and commas are inserted automatically between the coordinates and the file is in a format that can be read in Lisp. Quote
Lee Mac Posted January 5, 2009 Posted January 5, 2009 The way my posted LISP works is that it reads alternate coords and attributes., then assuming the attribute is prompted for, it will submit the attirbute value. (defun c:ITREE (/ *error* file file1 blk blkfile pts) (defun *error* (msg) (setvar "cmdecho" 1) (if (= msg "") (princ (strcat (itoa blk) " Blocks Inserted.")) (princ (strcat "\n" (strcase msg))) ) ;_ end if ) ;_ end defun (selfile) (blocksel) (setvar "cmdecho" 0) (setq file1 (open file "r") blk 0 ) ;_ end setq (while (or (/= (setq pts (read-line file1)) nil) ; [color=Red]READING COORDINATE[/color] (/= (setq atrib (read-line file1)) nil) ; [color=Red]READING ATTRIBUTE[/color] ) ;_ end or (command "-insert" blkfile pts "1" "1" "0" atrib) ; [color=Red]PASTING ATTRIBUTE TO COMMAND LINE[/color] (setq blk (1+ blk)) ) ;_ end while (*error* "") (close file1) (princ) ) ;_ end defun (defun selfile () (setq file (getfiled "Select a Text File" "C:\\" "txt" 8 ) ;_ end getfiled ) ;_ end setq ) ;_ end defun (defun blocksel () (setq blkfile (getfiled "Select a Block" "C:\\" "dwg" 8 ) ;_ end getfiled ) ;_ end setq ) ;_ end defun Quote
Lee Mac Posted January 5, 2009 Posted January 5, 2009 Maybe someone else could work out how to do it - I'm stumped. Quote
eldon Posted January 5, 2009 Posted January 5, 2009 What is it that is not working? Is it not getting to the coordinated point, or is it not inserting the block with the correct attribute, or what? Quote
Lee Mac Posted January 5, 2009 Posted January 5, 2009 I'm assuming its something to do with the attribute, seeing as you could get the block inserted without the addition of the attribute codeing. Quote
eldon Posted January 5, 2009 Posted January 5, 2009 When I tried to insert the block, it needed the attribute, then it needed the attribute to be verified. So the attribute must be entered twice or the attribute should be edited so that it doesn't need verification. Quote
wizman Posted January 5, 2009 Posted January 5, 2009 I'm assuming its something to do with the attribute, seeing as you could get the block inserted without the addition of the attribute codeing. what is the value of your attreq? One note for inserting blocks with attributes in a lisp routine, you must ensure your attreq system variable is set to 1 Quote
Lee Mac Posted January 5, 2009 Posted January 5, 2009 Excellent point Wizman, I did not know of that variable - thanks for pointing that out. Quote
Lee Mac Posted January 5, 2009 Posted January 5, 2009 Here is an updated LISP, including setting the attreq to 1: (defun c:ITREE (/ *error* file file1 blk blkfile pts atrib) (defun *error* (msg) (mapcar 'setvar varlist oldvars) (if (= msg "") (princ (strcat (itoa blk) " Blocks Inserted.")) (princ (strcat "\n" (strcase msg))) ) ;_ end if ) ;_ end defun (setq varlist (list "CMDECHO" "ATTREQ") oldvars (mapcar 'getvar varlist) ) ;_ end setq (selfile) (blocksel) (setvar "CMDECHO" 0) (setvar "ATTREQ" 1) (setq file1 (open file "r") blk 0 ) ;_ end setq (while (or (/= (setq pts (read-line file1)) nil) ; READING COORDINATE (/= (setq atrib (read-line file1)) nil) ; READING ATTRIBUTE ) ;_ end or (command "-insert" blkfile pts "1" "1" "0" atrib) ; PASTING ATTRIBUTE TO COMMAND LINE (setq blk (1+ blk)) ) ;_ end while (*error* "") (close file1) (princ) ) ;_ end defun (defun selfile () (setq file (getfiled "Select a Text File" "C:\\" "txt" 8 ) ;_ end getfiled ) ;_ end setq ) ;_ end defun (defun blocksel () (setq blkfile (getfiled "Select a Block" "C:\\" "dwg" 8 ) ;_ end getfiled ) ;_ end setq ) ;_ end defun Quote
eldon Posted January 5, 2009 Posted January 5, 2009 Have you tried to insert wannabe's block manually? It needs an extra return at the end, because the attribute needs verification. Quote
wannabe Posted January 5, 2009 Posted January 5, 2009 Thanks for the comments and effort. Learnt a few new things and got myself a really handy LISP. I can chat up the receptionist all day when I should be manually inserting blocks and changing the attributes. P.S I better check it at work before I get too carried away. Quote
Lee Mac Posted January 5, 2009 Posted January 5, 2009 I can chat up the receptionist all day when I should be manually inserting blocks and changing the attributes. LISP is good for something then... Quote
Lee Mac Posted January 5, 2009 Posted January 5, 2009 I see what you mean Eldon, Wannabe's Block has a double prompt for attribs - may need to double the LISP input: (defun c:ITREE (/ *error* file file1 blk blkfile pts atrib) (defun *error* (msg) (mapcar 'setvar varlist oldvars) (if (= msg "") (princ (strcat (itoa blk) " Blocks Inserted.")) (princ (strcat "\n" (strcase msg))) ) ;_ end if ) ;_ end defun (setq varlist (list "CMDECHO" "ATTREQ") oldvars (mapcar 'getvar varlist) ) ;_ end setq (selfile) (blocksel) (setvar "CMDECHO" 0) (setvar "ATTREQ" 1) (setq file1 (open file "r") blk 0 ) ;_ end setq (while (or (/= (setq pts (read-line file1)) nil) ; READING COORDINATE (/= (setq atrib (read-line file1)) nil) ; READING ATTRIBUTE ) ;_ end or (command "-insert" blkfile pts "1" "1" "0" atrib atrib) ; PASTING ATTRIBUTE TO COMMAND LINE (setq blk (1+ blk)) ) ;_ end while (*error* "") (close file1) (princ) ) ;_ end defun (defun selfile () (setq file (getfiled "Select a Text File" "C:\\" "txt" 8 ) ;_ end getfiled ) ;_ end setq ) ;_ end defun (defun blocksel () (setq blkfile (getfiled "Select a Block" "C:\\" "dwg" 8 ) ;_ end getfiled ) ;_ end setq ) ;_ end defun Quote
wizman Posted January 6, 2009 Posted January 6, 2009 please try.....:-): (defun c:ITREE (/ *error* file1 blk blkfile pts atrib file_link) (defun *error* (msg) (mapcar 'setvar varlist oldvars) (princ (strcat "\n" (strcase msg))) ) ;_ end defun (setq varlist (list "ATTREQ" "CMDECHO" "OSMODE") oldvars (mapcar 'getvar varlist) ) ;_ end setq (selfile) (blocksel) (setvar "CMDECHO" 0) (setvar "ATTREQ" 1) (setvar "OSMODE" 0) (setq file1 (open file "r") blk 0 ) ;_ end setq (while (and (setq file_link (read-line file1)) (setq atrib (vl-princ-to-string (car (read (strcat "(" file_link ")"))) ) ;_ end_VL-PRINC-TO-STRING ) ;_ end_setq (setq pts (read (strcat "(" (read-line file1) ")"))) ) ;_ end or (command "-insert" blkfile pts "1" "1" "0" atrib ATRIB) (setq blk (1+ blk)) ) ;_ end while (princ (strcat (itoa blk) " Blocks Inserted.")) (close file1) (*error* "") (princ) ) ;_ end defun (defun selfile () (setq file (getfiled "Select a Text File" "C:\\" "txt" 8 ) ;_ end getfiled ) ;_ end setq ) ;_ end defun (defun blocksel () (setq blkfile (getfiled "Select a Block" "C:\\" "dwg" 8 ) ;_ end getfiled ) ;_ end setq ) ;_ end defun Quote
wannabe Posted January 6, 2009 Posted January 6, 2009 The last routine gives the error: "NO FUNCTION DEFINITION: BLOCKSEL" as soon as the text file is selected. EDIT: The last routine from Lee. Quote
wannabe Posted January 6, 2009 Posted January 6, 2009 What format will the text file need to be in Wizzman? I.e, where will I need to place the text that will be used to populate the attribute? By default it comes out as attribute,coordx,coordy. Quote
wizman Posted January 6, 2009 Posted January 6, 2009 same as posted samppy.txt, i had a quick ran at it, too tight sched right now, try to come back later Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.