PDA

View Full Version : Need help to understand spaces in routines


sumulong
2007-06-08, 08:20 PM
Need clarification on what exactly goes into spaces in lisp routines. Are there tips out there on how to determine how to write a routine where part of the routine has to have a regular space on the line. How does one determine which route to take if part of his/ her routine will include regular spaces so that autocad won't read them as returns.

I'm trying to write a routine for importing pagesetups into a drawing. When I type everthing in the command line, it works fine but when I transpose those into a routine, it doesn't because my pagesetups have spaces on them. spaces = returns in the routine.

I can easily just rename the setups to not include space but i'd like to find out what the common practice is for spaces. Do we just avoid spaces on filenames, folder names or anything we can use w/ the file from pagesetups to layout names and layers in general?

Here's what i've tried so far from past suggestions on other routines i've tried out but i think these work w/ attribute fields and not for what i'm trying to use it for which are in the command line prompts. Then again i'm a newbie and i can just be messing this thing up completely. Any suggestions on how to do this line properly or a different way? Any input would help?


(write-line (strcat "-psetupin" "\r" "Q:/DRAFTING_STANDARDS/PAGE_SETUP/PS.DWG" "\r" "CA8306101 - B SIZE 1 TO 1" "\R") SCRFILE)

(write-line "-psetupin Q:/DRAFTING_STANDARDS/PAGE_SETUP/PS.DWG \"CA8306101 - B SIZE 1 TO 1\"" scrfile)

(write-line (strcat "-psetupin Q:/DRAFTING_STANDARDS/PAGE_SETUP/PS.DWG"
"\NCA8306101 - B SIZE 1 TO 1")
scrFile
)

kennet.sjoberg
2007-06-08, 08:54 PM
I started with computers when MS-DOS 3.0 was hot, and I am still allergic to spaces, special characters and filenames that are not in 8.3 formats.

Your problem is NOT lisp, your problem is the script you are using.
If you manually can type the line at the Command prompt it will also work in script, otherwise not.

If you turn it in to Lisp, the problem is no more a problem.

: ) Happy Computing !

kennet

abdulhuck
2007-06-10, 01:23 PM
Any input would help?
I would suggest you to split the lines in the script file. If any prompt is likely to accept spaces, then cover it with double quotes. This is applicable for file names too. The following code shows how to do this. (I removed the underscore from your path, but keep them back if you need it).

(write-line "-psetupin" scrfile)
(write-line (strcat (chr 34) "Q:/DRAFTING STANDARDS/PAGE SETUP/PS.DWG" (chr 34) ) scrfile)
(write-line (strcat (chr 34) "NCA8306101 - B SIZE 1 TO 1" (chr 34)) scrfile)


Regards,
Abdul Huck

kennet.sjoberg
2007-06-11, 09:35 AM
If you still want to use the script file, I recommend you to combine lisp and script like this :

(write-line "(command \42-psetupin\42 \42Q:/DRAFTING STANDARDS/PAGE SETUP/PS.DWG\42 \42NCA8306101 - B SIZE 1 TO 1\42 )" scrfile )

: ) Happy Computing !

kennet

Tom Beauford
2007-06-11, 01:30 PM
Under "File => Plot Utilities => Page Setups" I've added a group of items with macros like:

(command "._-PSETUPIN" "acad.dwt" "755cm B&W Layout")

Just an alternitive to lisp or scripts. Never had a problem with spaces inside of quotes.

sumulong
2007-06-12, 08:58 PM
Thanks to all who responded. All your suggestions work!

Just a quick clarification on somethings. Is \42 a different way to show " " or are the 2 totally different? Seems like \42 just inputs whatever is in-between them into the command line as is. I'm getting the impression that " " do the same thing?

Again thanks a bunch.

kennet.sjoberg
2007-06-13, 10:37 AM
Check my last post once more, you need “outer” and “inner” quotation marks, but sometimes you can’t use them as you are used to. Then you have to use different “outer” and “inner” quotation marks

Here is a few different ways to deceive AutoCAD when needed:

(write-line "(command \"-psetupin\" \"Q:/DRAFTING STANDARDS/PAGE SETUP/PS.DWG\" \"NCA8306101 - B SIZE 1 TO 1\" )" scrfile )

(write-line "(command \42-psetupin\42 \42Q:/DRAFTING STANDARDS/PAGE SETUP/PS.DWG\42 \42NCA8306101 - B SIZE 1 TO 1\42 )" scrfile )

(write-line (strcat "(command "(chr 34)"-psetupin"(chr 34)" "(chr 34)"Q:/DRAFTING STANDARDS/PAGE SETUP/PS.DWG"(chr 34)" "(chr 34)"NCA8306101 - B SIZE 1 TO 1"(chr 34)" )" ) scrfile )

you just describe the same character in different “languages” when needed.


: Happy Computing !

kennet