Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

cant read plot settings from variable in txt file

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
The_Caddie
383 Views, 5 Replies

cant read plot settings from variable in txt file

I’m trying to create a plot command that reads settings in from a variable stored in a text file but its becoming muddled up somewhere.

(defun c:MYPLOT ()

;Setting nessesary variables...

				(setq fname "C:/ICT/AutoCAD_Architecture_Suite_2012/CUSTOM/TREADSTONE/PEN/MYOUTPUTDEVICE.PEN")
				(if(setq f(open fname "r"))
				(while (setq MYOUTPUTDEVICE (read-line f))
				(close)))

				(setq fname "C:/ICT/AutoCAD_Architecture_Suite_2012/CUSTOM/TREADSTONE/PEN/MYPAPERSIZE.PEN")
				(if(setq f(open fname "r"))
				(while (setq MYPAPERSIZE (read-line f))
				(close)))

				(setq fname "C:/ICT/AutoCAD_Architecture_Suite_2012/CUSTOM/TREADSTONE/PEN/MYPAPERORIENTATION.PEN")
				(if(setq f(open fname "r"))
				(while (setq MYPAPERORIENTATION (read-line f))
				(close)))

				(setq fname "C:/ICT/AutoCAD_Architecture_Suite_2012/CUSTOM/TREADSTONE/PEN/MYPAPERPLOTSTYLE.PEN")
				(if(setq f(open fname "r"))
				(while (setq MYPAPERPLOTSTYLE (read-line f))
				(close)))

				(setq fname "C:/ICT/AutoCAD_Architecture_Suite_2012/CUSTOM/TREADSTONE/PEN/MYPAPERLINEWEIGHTS.PEN")
				(if(setq f(open fname "r"))
				(while (setq MYPAPERLINEWEIGHTS (read-line f))
				(close)))

;this line works...
;(Command "-Plot" "Y" X "\\\\dcmar02\\A03P17A4ZW" "A4 (210 x 297 mm)" "Millimeters" "Landscape" "No" "layout" "1:1" "0.00,0.00" "n" "" "Yes" "No" "Yes" "No" "No" "No" "yes")

;this line dosnt..
(command "-Plot" "Yes" X MYOUTPUTDEVICE MYPAPERSIZE MYPAPERUNITS MYPAPERORIENTATION "no" "Layout" "Fit" "0.00,0.00" "Yes" MYPAPERPLOTSTYLE "No" "No" MYPAPERLINEWEIGHTS "yes" "yes"  "no" "no" "no" "yes")

)
)

 

5 REPLIES 5
Message 2 of 6

 

Try (close f) instead of (close).

 

- The debug>Break on Error setting in VLIDE would help in finding these.

 

--

 

Message 3 of 6

After correcting the CLOSE bug you'll notice the program has further problems:

 

- closing the file inside the loop doesn't make much sense.

- doing a SETQ to the final variable in the test of the WHILE loop isn't useful, as the value after the loop will always be NIL. Use a temporary variable in the test and set the final variable in the loop body:

 

(if (setq f (open fname "r"))
    (while (setq temp (read-line f))
      (setq MYOUTPUTDEVICE temp)))

(close f)

- Also, make sure you don't have an empty last line in your file: that loop reads every line in the file, saving the last one as value.

 --

 

Message 4 of 6

yes how stuipid of me BTW I'm custom to ussing ust notepad to write all my lisp, i did however seek the use of Vlide after a while but because of my unfamiliaraty with the Vlide program I was unable to locate the problem

 

Thankyou for your help

Message 5 of 6

actually I see where the whole problem is occurring its when the plot device is being selected the plot device we have is named \\dcmar02\A03P19 in lisp I tried it as \\\\dcmar02\\A03P19 though that didnt work either

 

i have a more simple way to demonstrait this lasve the following lisp and you will see exactly wher my problem lies qua the slashes in the MYOUTPUTDEVICE variable.

 

(defun C:test ()

(setq MYOUTPUTDEVICE (getstring "\\dcmar02\a03p19"))
(alert MYOUTPUTDEVICE )
)

  how do I manage to include the slashes?

Message 6 of 6


@The_Caddie wrote:

actually I see where the whole problem is occurring its when the plot device is being selected the plot device we have is named \\dcmar02\A03P19 in lisp I tried it as \\\\dcmar02\\A03P19 though that didnt work either

 

i have a more simple way to demonstrait this lasve the following lisp and you will see exactly wher my problem lies qua the slashes in the MYOUTPUTDEVICE variable.

 

(defun C:test ()

(setq MYOUTPUTDEVICE (getstring "\\dcmar02\a03p19"))
(alert MYOUTPUTDEVICE )
)

  how do I manage to include the slashes?


The rule of thumb is: whenever you are using explicit quotation marks, you need to use doubled backslashes - and only then.

 

GETSTRING  uses PRINC to output its prompt, so your example shows as \dcmar02a03p19,

and reads your answer without quotation, so you don't need to use the Lisp-style doubled backslashes yourself here.

The ALERT call also uses PRINC, so it shows only the actual data, not the escape characters.

 

--

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost