TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Russ on April 28, 2005, 12:07:32 PM
-
I'm trying to create a routine that will allow me to open up our drawing directory and allow me to select which folder I want and I'm not sure how
to make the routine prompt me to enter the folder name. Our folders are named as such: 2003, 2004, 2005 etc... and Where I'm having trouble is getting the routine to ask for a folder name. I'm no way a Lisper, but was giving it a whirl. I want to be able to do this without selecting with the mouse. Heres what I have so far:
(DEFUN C:OPN ()
(COMMAND "START" "X:\Drawings\\Commercial\\2004" "")
)
Where I have 2004 is where I want to be promt for the folder name. Thanks for all input.
-
Open the folder up with Windows Explorer?
-
This will open Windows Explorer in the current (working) folder:
(startapp "C:/windows/explorer.exe" (getvar "DWGPREFIX"))
Replace the
(getvar "DWGPREFIX")
portion with the absolute path that you want to use. Like this:
(startapp "C:/windows/explorer.exe" "X:\\Drawings\\Commercial\\2004")
And, remember, if you are going to use a backslash (\) then you need to double them up (\\). You can use a forward slash (/) all by itself.
-
You know, I just re-read all of this and I'm betting that the answer I gave is in no way what you were looking for. :)
What you are trying to do (a guess here) is, for instance, create a toolbar button that works just like the "Open" button. Only, instead of opening to the last directory you worked on, you want it to open to a specified folder to save the drafters a few clicks.
Am I right?
-
I'm guessing something like this.
(defun c:opn (/ path dir)
(setq path "C:\\Temp\\Dwgs\\"); <-- change to suit your needs
(if
(not (= (setq dir (getstring "\nEnter Folder Name: ")) ""))
(if (findfile (strcat path dir))
(startapp (strcat "explorer.exe /n,/root," path dir))
; else
(alert "Folder not found")
)
)
(princ)
)
*edited*
missed placed ")"
-
not sure i follow either but if you're trying to open any of these directories from within autocad why not just browse to each then right click in the left bar and add current folder. then you'll have shortcuts to all of those directories (if that's what you meant???).
-
Russ, I changed your title. If you don't like it, feel free to change it. Just make it more descriptive than Lisp Help. Thank you.
Hint: click edit on your original post.
-
No problem Daron.... Thanks, Nivuahc & Mark, for the input. You both gave me the info I needed. Again, Thanks.
-
my (our, I'm sure) pleasure! :)
-
; Example: (ALE_BrowseForFolder "Select drawings folder")
;
; Original BrowseForFolder by Tony Tanzillo
;
(defun ALE_BrowseForFolder (PrmStr / ShlObj Folder FldObj OutVal)
(vl-load-com)
(setq
ShlObj (vla-getInterfaceObject
(vlax-get-acad-object)
"Shell.Application")
Folder (vlax-invoke-method ShlObj 'BrowseForFolder 0 PrmStr 0)
)
(vlax-release-object ShlObj)
(if Folder
(progn
(setq FldObj (vlax-get-property Folder 'Self)
OutVal (vlax-get-property FldObj 'Path)
)
(vlax-release-object Folder)
(vlax-release-object FldObj)
OutVal
)
)
)
-
Here is another, kinda clunky.
(setq path (substr
(setq fakefile
(getfiled "Select a Folder: "
"Pick Save When Done"
"*"
7)) 1 (- (strlen fakefile) 19)))
And another
(setq myfile (getfiled "Choose A Directory" "z. " " " 1))
-
CAB --
Cool idea but ...
I want to be able to do this without selecting with the mouse
:)
-
Ooops, :oops: