CadFrank Posted September 4, 2014 Share Posted September 4, 2014 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? Quote Link to comment Share on other sites More sharing options...
rkmcswain Posted September 4, 2014 Share Posted September 4, 2014 (edited) 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 September 4, 2014 by rkmcswain addition Quote Link to comment Share on other sites More sharing options...
CadFrank Posted September 4, 2014 Author Share Posted September 4, 2014 Yes it does work with some drawing.. but not all of them ! it's like it chooses if they work or not! Quote Link to comment Share on other sites More sharing options...
StevJ Posted September 4, 2014 Share Posted September 4, 2014 This works for me: (Windows 7 and Autocad 2014) ^C^C(startapp "explorer" (getvar "dwgprefix")) Steve Quote Link to comment Share on other sites More sharing options...
CadFrank Posted September 4, 2014 Author Share Posted September 4, 2014 I think theirs something wrong with my pc lol! Quote Link to comment Share on other sites More sharing options...
marko_ribar Posted September 4, 2014 Share Posted September 4, 2014 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. Quote Link to comment Share on other sites More sharing options...
CadFrank Posted September 4, 2014 Author Share Posted September 4, 2014 Well this one opens in System32 :S Quote Link to comment Share on other sites More sharing options...
rkmcswain Posted September 4, 2014 Share Posted September 4, 2014 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? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 4, 2014 Share Posted September 4, 2014 Try: (startapp (strcat "explorer /e,\"" (getvar 'dwgprefix) "\"")) Quote Link to comment Share on other sites More sharing options...
CadFrank Posted September 4, 2014 Author Share Posted September 4, 2014 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 ? Quote Link to comment Share on other sites More sharing options...
CadFrank Posted September 4, 2014 Author Share Posted September 4, 2014 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 Thanks ! Quote Link to comment Share on other sites More sharing options...
liuhaixin88 Posted September 5, 2014 Share Posted September 5, 2014 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". Quote Link to comment Share on other sites More sharing options...
liuhaixin88 Posted September 5, 2014 Share Posted September 5, 2014 (defun c:test () (prinC "opendwgfolder") (if (= (getvar "dwgtitled") 0) (alert "please save first") (startapp (strcat "explorer /select, " (getvar "dwgprefix") (getvar "dwgname") ", /e" ) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
liuhaixin88 Posted September 5, 2014 Share Posted September 5, 2014 ;opendwgfolder (defun c:gps_opendwgfolder () (if (= (getvar "dwgtitled") 0) (alert "Please save first") (startapp (strcat "explorer /select, " (getvar "dwgprefix") (getvar "dwgname") ", /e")) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
CadFrank Posted September 5, 2014 Author Share Posted September 5, 2014 Try: (startapp (strcat "explorer /e,\"" (getvar 'dwgprefix) "\"")) Ok Well Lee once again your code made it 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 (startapp (strcat "explorer /select,\"" (getvar 'dwgprefix) "") ) But Thanks ! Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 5, 2014 Share Posted September 5, 2014 Ok Well Lee once again your code made it 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 (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. Quote Link to comment Share on other sites More sharing options...
CadFrank Posted September 7, 2014 Author Share Posted September 7, 2014 Well thx for the information Lee always great help Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 8, 2014 Share Posted September 8, 2014 You're welcome Quote Link to comment Share on other sites More sharing options...
Julesagain Posted May 29, 2019 Share Posted May 29, 2019 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 Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 30, 2019 Share Posted May 30, 2019 Try the following instead: (startapp "explorer" (strcat "/e,\"" (vl-string-right-trim "\\" (getvar 'dwgprefix)) "\"")) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.