Save a copy of DWG file with space in filename

Save a copy of DWG file with space in filename

kris.fabmoos
Explorer Explorer
1,513 Views
10 Replies
Message 1 of 11

Save a copy of DWG file with space in filename

kris.fabmoos
Explorer
Explorer

Hi Fellow forum members.

 

I have made this command in AutoCAD:

 

-wblock;$M=c:/cad_temp/$(getvar,DWGNAME);*;

 

It saves the file fine, but if there are spaces in it then anything from the space gets lost.

 

I.e. "my file1.dwg" becomes "my.dwg"

 

Is it me who is missing something as I can not seem to get it to work.

I need it to work for both LT and standard version of AutoCAD

 

Best regards,

Kris

0 Likes
Accepted solutions (1)
1,514 Views
10 Replies
Replies (10)
Message 2 of 11

rkmcswain
Mentor
Mentor
A space is like pressing ENTER.

Try enclosing the entire string in quotes.

The ".Save" command will also write out a copy or the current drawing without changing the editor to that new copy.


R.K. McSwain     | CADpanacea | on twitter
0 Likes
Message 3 of 11

kris.fabmoos
Explorer
Explorer

I have tried with quotes in serval ways but none of them worked unless it's me...

"-wblock;$M=c:/cad_temp/$(getvar,DWGNAME);*;"

 

-wblock;"$M=c:/cad_temp/$(getvar,DWGNAME)";*;

 

-wblock;$M=c:/cad_temp/"$(getvar,DWGNAME)";*;

 

-wblock;$M=c:/cad_temp/$"(getvar,DWGNAME)";*;

 

-wblock;$M=c:/cad_temp/$(getvar,"DWGNAME");*;

 

But none of the above worked 😞

0 Likes
Message 4 of 11

Kent1Cooper
Consultant
Consultant

@rkmcswain wrote:
....
The ".Save" command will also write out a copy or the current drawing without changing the editor to that new copy.

I agree that's better than using WBLOCK, since you're taking the whole drawing anyway, and also since WBLOCK removes everything so you'd need OOPS to bring it all back.  But there's still the problem that you can't "put quotes around" the name as pulled from the DWGNAME System Variable, in order to feed it to the command with a space in it.

 

Diesel apparently does not have an equivalent to AutoLisp's (strcat) function, or you might be able to wrap the quotes around it using that.

 

Again, since you're taking the whole drawing, can you do it with a SHELL out to a DOS copy operation, rather than using WBLOCK or SAVE?  If so, you would want to build in a QSAVE first, to ensure that the file it copies is the current state of things -- otherwise it will be copied the way it was at when last QSAVEd.

 

 

Kent Cooper, AIA
Message 5 of 11

john.uhden
Mentor
Mentor

From my 2002 help:

 

Script files fail when using long file names and directory names [Support Assistance: ASA]

Script files fail when using long file names and directory names


Issue

Script files do not execute properly when you use long file names or directory names in the script. For example, if you included the path c:\my project\floor plan.dwg in a script, the program would look for a file named floor and ignore the rest of the file name. Spaces in file names are interpreted to be the end of the path.

 

Have you tried:

 

-wblock;$M=c:/cad_temp/$"(getvar,DWGNAME)";*;

 

or maybe ?

 

-wblock;$M="\"c:/cad_temp/$(getvar,DWGNAME)\"";*;

John F. Uhden

0 Likes
Message 6 of 11

kris.fabmoos
Explorer
Explorer

Dear John,

 

Unfortunately none of your suggestions worked 😞

 

Best regards,

Kris

0 Likes
Message 7 of 11

Ranjit_Singh
Advisor
Advisor

Maybe just use lisp function.

0 Likes
Message 8 of 11

kris.fabmoos
Explorer
Explorer

Dear Ranjit Singh,

I wish I could as I need it to work for both LT and standard version 😞

 

Best regards,

Kris

0 Likes
Message 9 of 11

Paul_Gander
Advocate
Advocate
Accepted solution

 

The following should work with both AutoCAD and LT:

 

_.expert;5;_.-wblock;$m=""""c:/cad_temp/$(getvar,dwgname)"""";*;_.expert;0

The expert setting is required in case the file already exists and suppresses the prompt asking if you wish to overwrite the original.

 

Diesel requires quotes to be doubled up and then also enclosed in quotes, hence the groups of 4 quotes at each end of the filename.

 

The save command in LT is identical to qsave and only asks for a filename if the drawing has not already been named/saved. It does not save a copy of the file as it does in AutoCAD.

 

Message 10 of 11

kris.fabmoos
Explorer
Explorer

Paul, you are a rock star, I will give you 6 out of 5 stars ******

 

Cheers and thank you so much for helping here!

 

Kris

0 Likes
Message 11 of 11

rkmcswain
Mentor
Mentor
Paul_Gander wrote:

The save command in LT is identical to qsave and only asks for a filename if the drawing has not already been named/saved. It does not save a copy of the file as it does in AutoCAD.

Yes, you are right. I recall that now that you mention it. I can't fathom why they made that change for LT. Excellent solution!

R.K. McSwain     | CADpanacea | on twitter
0 Likes