Jump to content

Macro to open explorer to a specific directory/location...?


Recommended Posts

Posted

Hey guys,

 

I'm sure this has been asked multiple times in the past, but I'm having a peculiar issue with what I though would be a very simple operation.

 

I'm trying to create a bunch of "directory" links to a range of different folders (on my local machine and on the network).

 

I had previously set this us using LISP, but now I would rather incorporate into a CUIX file without the need for a LISP routine.

 

So... I've tried a range of combinations with various ways to trying to get the explorer windows to open to the correct location, unfortunately I have now forgotten what macro I started with.

 

Right now...

 

^C^C(startapp "explorer" "t:")

... Will open T Drive fine.

 

But...

 

^C^C(startapp "explorer" "t:/1068")

... Will open "C:\Users\user_10\Documents"

 

Just wondering if someone could please set me straight on where I am going wrong.

 

Thanks a lot for any help.

Posted

Hi MSasu,

 

Thanks for the reply.

 

I have read that backslash ( \ ) will 'pause' the command/macro - waiting for user input. This does seem to be the case when attempting to run your code from a menu or toolbar button.

 

Is this normal behaviour?

 

Thanks again.

Posted

Lamensterms, meantime I had removed my answer since noticed (late) that you were looking to use that statement into a menu macro and not a routine. Sorry for inconvenience!

Posted

Hi again MSasu,

 

Thanks for that, it does work - but only for directory paths without any spaces. Do you have alternative code which will work for directories which include spaces?

 

Thanks again.

Posted

Maybe define your own function and place it into start-up?

(defun OpenFolderPath( thePath / )
(setq thePath (vl-string-translate "/" "\\" thePath))
(if (vl-file-directory-p thePath)
 (startapp "Explorer" thePath)
 (alert (strcat "Path " thePath " isn't available!"))
)
(princ)
)

After call it into your button's macro:

^C^C^P(if (member (type OpenFolderPath) '(USUBR SUBR)) (OpenFolderPath "T:/My Folder Name With Spaces") (alert "Tool not available!"));^P

Posted

JGA, there is also the GETFILED built-in function, but I'm not sure how this will help for OP's case (open an Explorer window for a given path).

Posted

Hi guys,

 

Thanks a lot for the tips.

 

Mircea, I was thinking something along the lines of calling a universal 'open explorer' LISP and simply altering the directory for each macro call. The code you have submitted is quite a bit more advanced than I had in mind, but thank you very much for providing it and I look forward to testing it out tomorrow.

 

Thanks again.

Posted

The same question was posted elsewhere today but the answer you want

(startapp "explorer /select, P:\autodesk\lisp")

Posted

Hi again Mircea,

 

Just wanted to let you know that your routine and macro work great.

 

Thanks again for all your help.

Posted
Hi again Mircea,

 

Just wanted to let you know that your routine and macro work great.

 

Thanks again for all your help.

Glad I could help; you're entirely welcome!

Posted

Thanks BigAl, I've got a few different plans for menus on the stove at the moment. Finally getting my act together with the MNU stuff as well.

 

Thanks again everyone.

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...