Jump to content

Recommended Posts

Posted

Hi all

 

I'm trying to use lisp to create a new directory in my homedrive - but it's not working.

 

The routine is this one by the awesome Lee Mac.

 

So the code to call the function is

 

(LM:createdirectory "%HOMEDRIVE%\\AutoCAD2013\\Support")

 

...which doesn't work, and returns nil

 

If I use this code

 

(LM:createdirectory "C:\\AutoCAD2013\\Support")

 

...it works.

 

I have full control permissions on the home drive. Is there something else about the home drive that is stopping the creation of the folders?

 

HomeDrive_zpsoxeopuv4.png

 

Thanks

Paul

Posted
What does this return (getenv "Homedrive") for me "c:"

 

I get "G:" which is where I can see my home drive so assume correct?

Posted (edited)

Sometimes networks need the \\baracudda\users rather than G:

 

Play with (vl-mkdir dir) try different options for dir

 

Other way is old fashioned DOS using a bat file called from Autocad. G: CD..... MD.... etc

 

This worked for me (vl-mkdir "P:\\temp\\alan") 
so try  
(vl-mkdir (strcat (getenv "homedrive") "\\temp\\alan"))

Edited by BIGAL
Posted

I got an error message

; error: bad argument type: stringp nil

Posted

Fixed when posting "\\mydrive is converted to a URL address did not notice removes quotes ", edited code now working needs in quotes "c:\\Temp\\Alan" etc

Posted

You will first need to convert the environment variable %HOMEDRIVE% to a UNC path, e.g.:

;; Expand Environment String  -  Lee Mac

(defun LM:expenvstr ( str / res wsh )
   (if (setq wsh (vlax-create-object "wscript.shell"))
       (progn
           (setq res (vl-catch-all-apply 'vlax-invoke (list wsh 'expandenvironmentstrings str)))
           (vlax-release-object wsh)
           (if (null (vl-catch-all-error-p res))
               res
           )
       )
   )
)

(LM:createdirectory (LM:expenvstr "%HOMEDRIVE%\\AutoCAD2013\\Support"))

Or using:

(LM:createdirectory (strcat (getenv "HOMEDRIVE") "\\AutoCAD2013\\Support"))

Posted
Fixed when posting "\\mydrive is converted to a URL address did not notice removes quotes ", edited code now working needs in quotes "c:\\Temp\\Alan" etc

 

Thanks Alan. I saw that and typed it in manually - still didn't work. I have a feeling there is something a bit strange with the permissions.

Posted
You will first need to convert the environment variable

 

Thanks so much Lee! That worked perfectly. Much appreciated

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...