Jump to content

Open current folder of drawing.


CadFrank

Recommended Posts

Hi,

 

I started to use this code :

 

(Defun c:foo ()
     (startapp
           (strcat "explorer /select, "
                   (getvar "dwgprefix")
                   (getvar "dwgname")
                   ", /e"))
)

 

to open the folder of my drawing. it was working fine at first.. Now for some reason it opens my documents.

 

Anyone knows why?

Link to comment
Share on other sites

It works fine here, using Windows 7, AutoCAD 2015, in a named drawing.

If you are an unnamed (unsaved) drawing, it defaults to %userprofile%

 

The menu macro I've been using for years (probably starting in AutoCAD 2002 with Win2000) still works today in 2015+Win7

 

^C^C^P(STARTAPP (strcat "EXPLORER /e," (getvar "dwgprefix")))(PRINC)  

Edited by rkmcswain
addition
Link to comment
Share on other sites

Try this...

 

(defun c:exploredwgprefix ( / fn f )
 (setq fn (vl-filename-mktemp "explorer.bat"))
 (setq f (open fn "w"))
 (write-line (strcat "cd " (getvar 'dwgprefix)) f)
 (write-line "EXPLORER ." f)
 (close f)
 (startapp fn)
 (princ)
)

 

HTH, M.R.

Link to comment
Share on other sites

Yes it does work with some drawing.. but not all of them ! it's like it chooses if they work or not!

 

Is there anything common to the location of the drawings where it does not work? Like UNC paths with special characters in it, or a non-Windows NAS, or anything?

Link to comment
Share on other sites

Is there anything common to the location of the drawings where it does not work? Like UNC paths with special characters in it, or a non-Windows NAS, or anything?

 

Well whats UNC and NAS ?

Link to comment
Share on other sites

Try:

(startapp (strcat "explorer /e,\"" (getvar 'dwgprefix) "\""))

 

I'll have to try this tomorrow i'm no longuer at work !

 

So ill give you an answer on how it goes tomorrow :D

 

Thanks !

Link to comment
Share on other sites

Try this...

 

(defun c:exploredwgprefix ( / fn f )
 (setq fn (vl-filename-mktemp "explorer.bat"))
 (setq f (open fn "w"))
 (write-line (strcat "cd " (getvar 'dwgprefix)) f)
 (write-line "EXPLORER ." f)
 (close f)
 (startapp fn)
 (princ)
)

 

HTH, M.R.

 

Marko. good idea. use "CMD" call "EXPLORER".

Link to comment
Share on other sites

(defun c:test ()
 (prinC "opendwgfolder")
 (if (= (getvar "dwgtitled") 0)
   (alert "please save first")
   (startapp (strcat "explorer /select, "
             (getvar "dwgprefix")
             (getvar "dwgname")
             ", /e"
         )
   )
 )
 (princ)
)

Link to comment
Share on other sites

;opendwgfolder
(defun c:gps_opendwgfolder ()
 (if (= (getvar "dwgtitled") 0)
   (alert "Please save first")
   (startapp (strcat "explorer /select, " (getvar "dwgprefix") (getvar "dwgname") ", /e"))
 )
 (princ)
)

Link to comment
Share on other sites

Try:

(startapp (strcat "explorer /e,\"" (getvar 'dwgprefix) "\""))

 

Ok Well Lee once again your code made it :P

 

I've had to modify something so it could open the folder right before the drawing but it works even with the one's that were not working..

Don't know why it works :unsure:

 

(startapp
   (strcat "explorer /select,\"" (getvar 'dwgprefix) "")
 )

 

But Thanks !

Link to comment
Share on other sites

Ok Well Lee once again your code made it :P

 

I've had to modify something so it could open the folder right before the drawing but it works even with the one's that were not working..

Don't know why it works :unsure:

 

(startapp
   (strcat "explorer /select,\"" (getvar 'dwgprefix) "")
 )

But Thanks !

 

Be careful not to miss the trailing double quote:

(startapp (strcat "explorer /select,\"" (getvar 'dwgprefix) "[color=red]\"[/color]"))

As for why it works: enclosing the path in double-quotes ensures that paths containing spaces are interpreted as a single argument for the explorer command switch.

Link to comment
Share on other sites

  • 4 years later...
On 9/4/2014 at 4:32 PM, Lee Mac said:

Try:

 


(startapp (strcat "explorer /e,\"" (getvar 'dwgprefix) "\""))
 

 

OK this has been working perfectly as a little 2 line LISP for years, and just recently stopped - it now sends me to My Documents (worthless for those for those of us working from a server). It works perfectly from the command line but not from a macro or as a LISP. I'm so frustrated! I can see that the code works. Why can't I get a button or LISP to work! If AutoCAD would use a useful file dialog instead of the tree where you have to click everything I could just cut and paste the path. We have very convoluted path names and I hate clicking 20 times for every file. I have the JTB button, but I need to OPEN the current folder, in Explorer, so I can see all files. Can anyone give me a hint as to what I'm doing wrong?

Macro gets this far:

(startapp (strcat "explorer /e,

Here's the exact text of macro:

^C^C(startapp (strcat "explorer /e,\"" (getvar 'dwgprefix) "\"")) 

And here's the LISP (renamed FE simply because it's easier for me to type, but it's the same code as above)

FE.LSP

Link to comment
Share on other sites

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