MFish Posted April 8, 2009 Posted April 8, 2009 I did a search for a similar thread but with no luck. Anyway... I was hoping to find a thread that talked about whether or not it is possible to create a lisp that will open up a specific folder. Kind of like a command that has within it a search path. Now when I want to go to this folder I have to browse through several others before I get to the one I want. I would like to be able to type in a command and it would magically open up to the folder I need... Unfortunately I have no idea how in depth of a routine this has to be or how to even begin writing it. Something that may help, is that it is always the same folder that I need... So since it is always the same folder I am hoping it doesn't have to be as complex. Thank you in advance for any advice/help any of you have Quote
Se7en Posted April 8, 2009 Posted April 8, 2009 How about? (if (= (getvar 'dwgtitled) 1) (startapp "explorer" (getvar 'dwgprefix)) ) Quote
MFish Posted April 8, 2009 Author Posted April 8, 2009 How about? (if (= (getvar 'dwgtitled) 1) (startapp "explorer" (getvar 'dwgprefix)) ) That makes good sense... I am having trouble remembering exactly what I need to get the routine going though. Like the command I would use to get it started once it is loaded. Sorry about my lack of knowledge I am still in the basic stages of using Lisp routines and such. Quote
Se7en Posted April 8, 2009 Posted April 8, 2009 Here it is. Ive taken the liberty to name the command `OPENEX' but you can name it anything you want by changing it (leave the "c:" and the "( / )" parts). (defun c:OpenEX ( / ) (if (= (getvar 'dwgtitled) 1) (startapp "explorer" (getvar 'dwgprefix)) ) ) Quote
MFish Posted April 8, 2009 Author Posted April 8, 2009 Here it is. Ive taken the liberty to name the command `OPENEX' but you can name it anything you want by changing it (leave the "c:" and the "( / )" parts). (defun c:OpenEX ( / ) (if (= (getvar 'dwgtitled) 1) (startapp "explorer" (getvar 'dwgprefix)) ) ) Oh okay! I will give that a shot, thank you very much! Quote
PS_Port Posted April 8, 2009 Posted April 8, 2009 Once you get it going, dont forget to drop it in your appload startupsuite so you can access it from any drawing. Also I would shorten the OpenEx to OEX just to make it quicker to type at the command line... nice S8. Quote
Se7en Posted April 8, 2009 Posted April 8, 2009 > Oh okay! I will give that a shot, thank you very much! Your welcome very much. Quote
MFish Posted April 8, 2009 Author Posted April 8, 2009 Once you get it going, dont forget to drop it in your appload startupsuite so you can access it from any drawing. Also I would shorten the OpenEx to OEX just to make it quicker to type at the command line... nice S8. That is a nice suggestion, thank you! > Oh okay! I will give that a shot, thank you very much!Your welcome very much. Okay, I tried using it and the first time I received back a nil response... Then I tried inserting the file path into the routine and it came back with error bad argument. Here is the file path that I inserted, I am sure you will know what I did wrong... (defun c:OEX ( / ) (if (= (getvar 'G:\Automation\Drawing Patterns\AutoCAD STD\Library\Panel\Square D\PLC) 1) (startapp "explorer" (getvar 'G:\Automation\Drawing Patterns\AutoCAD STD\Library\Panel\Square D\PLC)) ) ) Quote
Lee Mac Posted April 8, 2009 Posted April 8, 2009 The code will only follow through when the drawing has been saved - i.e. when dwgtitled = 1. If it is the same thing you need everytime - maybe this: (defun c:OEX ( / ) (startapp "explorer" "G:\\Automation\\Drawing Patterns\\AutoCAD STD\\Library\\Panel\\Square D\\PLC") ) Quote
Lee Mac Posted April 8, 2009 Posted April 8, 2009 Otherwise perhaps this? (defun c:getfile (/ file) (setq file (if load_file (getfiled "Select File" load_file "" 2) (getfiled "Select File" "" "" 2))) (or (not file) (setq load_file file))) Quote
Se7en Posted April 8, 2009 Posted April 8, 2009 1. Paths have to have either double slashes like: "C:\\Temp\\My Dir\\" or a forward slash like: "C:/Temp/My Dir/" Yes that will only work if the drawing has been saved. And you should have a problem with it. I dont know why it would give you an error. 2. Lee Mac's last code: I can see that stupid `IF this then that then OR' has infected this forum as well. ...I'll have to correct that. Quote
Lee Mac Posted April 8, 2009 Posted April 8, 2009 1. Paths have to have either double slashes like: "C:\\Temp\\My Dir\\" or a forward slash like: "C:/Temp/My Dir/" Yes that will only work if the drawing has been saved. And you should have a problem with it. I dont know why it would give you an error. Can't believe I missed the single backslash - nice spot Se7en... 2. Lee Mac's last code: I can see that stupid `IF this then that then OR' has infected this forum as well. ...I'll have to correct that. Haha - whats wrong with a use of a good ol' OR... either that or its (if (not this), then this...) Quote
Se7en Posted April 8, 2009 Posted April 8, 2009 > Haha - whats wrong with a use of a good ol' OR... Nothing when preforming a boolean check. (defun c:getfile (/ file) (setq file ;; bind variable FILE to results from GETFILED (if load_file ;; where did this var come from? ;; Are you using a global var called load_file? (getfiled "Select File" load_file "" 2) (getfiled "Select File" "" "" 2)) ;; the IF statement will return the results from GETFILED ) (or ; Run boolean; stop on first non nil statement (not file) ;; 1. if the variable FILE is bound to nil then ;; 2. if the variable is bound then (setq load_file file) ;; 1. bind the variable LOAD_FILE to nil ;; 2. never evaluate this statement ) ) Sorry, I dont really follow your logic in this one. Quote
Lee Mac Posted April 8, 2009 Posted April 8, 2009 Hmmm... I followed it like this: (defun c:getfile (/ file) (setq file ;; bind variable FILE to results from GETFILED (if load_file ;; where did this var come from? [b][color=Blue]<<-- Using it as a global Variable[/color][/b] ;; Are you using a global var called load_file? [b][color=Blue]<<-- Yes[/color][/b] (getfiled "Select File" load_file "" 2) (getfiled "Select File" "" "" 2)) ;; the IF statement will return the results from GETFILED ) (or ; Run boolean; stop on first non nil statement (not file) [color=Red][b] ;; 1. if the variable FILE is bound to nil then (not file) returns T ;; 2. if the variable is bound then (not file) returns nil[/b][/color] (setq load_file file) [color=Red][b] ;; 1. don't evaluate this statement ;; 2. bind its value to the global variable[/b][/color] ) ) Quote
MFish Posted April 8, 2009 Author Posted April 8, 2009 1. Paths have to have either double slashes like: "C:\\Temp\\My Dir\\" or a forward slash like: "C:/Temp/My Dir/" Yes that will only work if the drawing has been saved. And you should have a problem with it. I dont know why it would give you an error. 2. Lee Mac's last code: I can see that stupid `IF this then that then OR' has infected this forum as well. ...I'll have to correct that. That's good to know, I wasn't aware of the backslash issue. And just an update, both of the routines work flawlessly! And I must tip my hat to you both! That's a great help, and thank you for being so quick about everything Quote
russell84 Posted April 9, 2009 Posted April 9, 2009 Not sure what you require but if this helps well and good. (defun c:JOB () (setq jobnumber (getstring "\nTYPE JOB NUMBER")) (setq first2chars (substr jobnumber 1 2)) (setq jobfolder (strcat "[url="file://\\Jobs"]\\Jobs[/url] 20" first2chars)) (setq path1 (strcat "R:")) (setq path2 (strcat "\\")) (setq FullPath (Strcat path1 jobfolder path2 jobnumber)) (startapp "Explorer" FullPath) (princ) ) Quote
Lee Mac Posted April 9, 2009 Posted April 9, 2009 Not sure what you require but if this helps well and good. (defun c:JOB () (setq jobnumber (getstring "\nTYPE JOB NUMBER")) (setq first2chars (substr jobnumber 1 2)) (setq jobfolder (strcat "[url="file://%5C%5CJobs"]\\Jobs[/url] 20" first2chars)) (setq path1 (strcat "R:")) (setq path2 (strcat "\\")) (setq FullPath (Strcat path1 jobfolder path2 jobnumber)) (startapp "Explorer" FullPath) (princ) ) Russell, I think that code is quite specific for your purpose - but thanks for the post all the same Quote
CADkitt Posted June 2, 2010 Posted June 2, 2010 I'm trying to make a command for in toolpallets so you can open the folder of the current tool pallet. but this doesn't work: ^c^c(startapp "explorer" "I:\\Engineering\\Equipment\\name\\01010") ^c^c(startapp "explorer" "I:\Engineering\Equipment\name\01010") ^c^c(startapp "explorer" "I://Engineering//Equipment//name//01010") ^c^c(startapp "explorer" "I:/Engineering/Equipment/name/01010") I rather not use a lisp because the tool pallets get distributed true the network. Found this similar thread: http://www.eng-tips.com/viewthread.cfm?qid=13388&page=207 Doesn't really have an solution except using your internet browser. Quote
MarcoW Posted June 2, 2010 Posted June 2, 2010 For a macro, what about this: _.browser;"I:/Engineering/Equipment/name/01010" I would like to hear if it works! Quote
CADkitt Posted June 2, 2010 Posted June 2, 2010 For a macro, what about this: _.browser;"I:/Engineering/Equipment/name/01010" I would like to hear if it works! Browser works fine only if you use internet explorer if you have chrome you get the dir in chrome and I guess the same results in fire-fox. I now use this and have the chrome ie tab extension set up to automatically load file://. It works but not without extra work. Maybe there is a way to force IE on open? Quote
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.