Help required on AutoLISP
Help required on AutoLISP
(OP)
I am writing an AutoLISP program to read a text file and write the whole text on to AutoCAD graphics screen exactly as it would've appeared in the text file. Here is the code: (setq f1 (open f_name "r"))
(setq str 1)
(setq block (read-line f1))
(while (/= str nil)
(setq str (read-line f1))
(if (/= str nil)
(setq block (strcat block str (chr 10)))
(princ)
)
)
(command "text" pause 10 0 block)
(close f1)
(princ)
But the text command does not print it the way it appears in the text file. Instead, it offsets each line. Can anybody tell what's wrong with my code?
(setq str 1)
(setq block (read-line f1))
(while (/= str nil)
(setq str (read-line f1))
(if (/= str nil)
(setq block (strcat block str (chr 10)))
(princ)
)
)
(command "text" pause 10 0 block)
(close f1)
(princ)
But the text command does not print it the way it appears in the text file. Instead, it offsets each line. Can anybody tell what's wrong with my code?





RE: Help required on AutoLISP
Good luck,
Carl
RE: Help required on AutoLISP
(defun c:asctext ()
(setq a (getfiled "Select File" "" "txt;lsp" 8))
(if a
(if (setq fn (open a "r"))
(progn
(setq ip (getpoint "\nStart point: "))
(setvar "texteval" 1)
(setq val (read-line fn))
(command "._text" ip "0" val)
(while (setq val (read-line fn))
(command "._text" "" val)
)
(close fn)
)
(alert "File cannot be opened")
)
)
)
Just try this command on any text file, making sure you have a text style already defined.
Cheers.....
RE: Help required on AutoLISP
Thanks once again to CarlB & Striker for the help.
rakes
RE: Help required on AutoLISP
Have a nice day.....
RE: Help required on AutoLISP
RE: Help required on AutoLISP
RE: Help required on AutoLISP
6 different viewports on the same layoutare showing different areas of a floor plan containing different colours of dense hatching. In order to dodge duplicating the model and making the file size huge, I'm trying to set up certain hatches shown through certain viewports... i don't know if its possible.... and I don't know how well I explained it.
please help.
-work guy
RE: Help required on AutoLISP