Cannot write to directory:??? autolisp

Cannot write to directory:??? autolisp

DC-MWA
Collaborator Collaborator
2,089 Views
7 Replies
Message 1 of 8

Cannot write to directory:??? autolisp

DC-MWA
Collaborator
Collaborator

My quick export routine is bombing on certain folder names...

Cannot write to directory: F:\MWA Work\PROJECTS\Project 2- CONDOCS - 14468\CAD-CONDOC\CAD EXPORTS

 

I think  "Project 2- CONDOCS - 14468" is the issue.

 

Is there a way to make it deal with long random spaces etc in folder names?

0 Likes
Accepted solutions (2)
2,090 Views
7 Replies
Replies (7)
Message 2 of 8

ВeekeeCZ
Consultant
Consultant

(command ".exporttoautocad2007" "c:\\Users\\***\\***\\Project 2- CONDOCS - 14468\\CAD EXPORTS\\test.dwg")

 

This worked for me (C3D 2016). Must be something else.

0 Likes
Message 3 of 8

_gile
Consultant
Consultant

Hi,

 

Despite the fact there's a useless strcat, you should not add a directory separator before "CAD EXPORTS\\".

(vl-mkdir (strcat (strcat (getvar 'DWGPREFIX)) "\\CAD EXPORTS\\"))

should have been:

(vl-mkdir (strcat (getvar 'DWGPREFIX) "CAD EXPORTS\\"))



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 4 of 8

ronjonp
Mentor
Mentor

I see an issue here:

(vl-mkdir (strcat (strcat (getvar 'dwgprefix)) "\\CAD EXPORTS\\"))
;; "C:\\TEST\\FOO\\\\CAD EXPORTS\\"

Oops .. too slow. 

0 Likes
Message 5 of 8

dbhunia
Advisor
Advisor

Hi,

 

I have gone through your attached Lisp file....

 

there use (command "-ExportToAutocad" "B" "N" "F" "2007" "" file)

instead of (command "-exporttoautocad" "f" "2007" file)

 

(It has been tested in "AutoCAD 2007", hope fully it will work in latest version.)


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
0 Likes
Message 6 of 8

roland.r71
Collaborator
Collaborator
Accepted solution

First of all: Stick to 1 thread per issue, as you have created a duplicate thread, here.

 

...and as I said there: Does the directory get created? Looking at the code, it doesn't.

As there's an issue there with creating it. (as mentioned before, you're creating it with a double \

 

Strangely you do it correctly for the check & the write (but you can't write to a non-existing directory)

 

The check&create is a bit weird too.

You check if a directory exists: (strcat (getvar 'DWGPREFIX) "Quick Plots")

If not, you try to create a different directory (???) (strcat (strcat (getvar 'DWGPREFIX)) "\\CAD EXPORTS\\")

(with the red being obsolete/erroneous)

 

so, it will try to create the folder, even if it does already exist. Just as long as the other one doesn't. (?)

Why not check for "CAD EXPORTS" itself?

 

and...

  (setvar "cmdecho" 1) ;Play nice and put things back
  (setvar "filedia" 1) ;where they came from

You're actually not doing that which the comments say. You are forcing them on, instead of "putting them back". If you realy want to play nice...

At the start add:

(setq cmdecho (getvar 'cmdecho)
         filedia (getvar 'filedia)
)

and change those two into:

  (setvar "cmdecho" cmdecho) ;Play nice and put things back
  (setvar "filedia" filedia) ;where they came from

 

0 Likes
Message 7 of 8

dbhunia
Advisor
Advisor
Accepted solution

@DC-MWA wrote:

My quick export routine is bombing on certain folder names...

Cannot write to directory: F:\MWA Work\PROJECTS\Project 2- CONDOCS - 14468\CAD-CONDOC\CAD EXPORTS

 

I think  "Project 2- CONDOCS - 14468" is the issue.

 

Is there a way to make it deal with long random spaces etc in folder names?


 

Hi,

 

I think this writing problem has been solved.......

 

Because this was due to the line "(command ".exporttoautocad2007" file)" ........... in your "QEXP.lsp".....

And by replacing the line with "(command "-ExportToAutocad" "B" "N" "F" "2007" "" file)", it is working now. 

 

If you go through the solution of your raised query "Help with consultant export routine - autolisp" you will get your answer.........

 

 

And the issue 

My quick export routine is bombing on certain folder names...

Cannot write to directory: F:\MWA Work\PROJECTS\Project 2- CONDOCS - 14468\CAD-CONDOC\CAD EXPORTS.......

 

This is because (what I got from your in your "QEXP.lsp" file) except "CAD EXPORTS" folder one of the other folders is must be in "write protected mode"........that's why your quick export routine failing to write to the certain destination.....

 

For this go through the each folder properties (by right mouse click) & check into the "Security" tab & check the "Permissions for Authenticated" options...... I think you should get your solution........

 

Capture1.PNG


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
0 Likes
Message 8 of 8

roland.r71
Collaborator
Collaborator

I mentioned it, somewhat, with the other thread (is it writeable?)

<snip>

I just wrote a story here about this being unlikely and about the problems with the directory check & create, but... I just discovered it doesn't realy matter. So, yes, not having write access could be the issue.

</snip>

It has been noted a few times, the makedir command is wrong:

(vl-mkdir (strcat (strcat (getvar 'dwgprefix)) "\\CAD EXPORTS\\"))

 should have been:

(vl-mkdir (strcat (getvar 'dwgprefix) "CAD EXPORTS"))

(the trailing backslash is obsolete (but not wrong, the rest is)

 

BUT: Using the "faulty" code, the directory still does get created.

Pasting it with a new drawing it returns T, and i now have a: C:\Users\xXx\Documents\CAD EXPORTS

 

The biggest issue here, why it doesn't work, is the check for another directory as the one created.

Illustrated by @DC-MWA issue that it doesn't work AFTER the quick plot. (as that very directory is created there and the cad export only gets created if it (the quick plot) doesn't exist)

0 Likes