TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Russ on April 28, 2005, 12:07:32 PM

Title: startapp opening folders getfiled? I dunno... help
Post 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.
Title: startapp opening folders getfiled? I dunno... help
Post by: Mark on April 28, 2005, 12:31:11 PM
Open the folder up with Windows Explorer?
Title: startapp opening folders getfiled? I dunno... help
Post by: nivuahc on April 28, 2005, 12:41:28 PM
This will open Windows Explorer in the current (working) folder:

Code: [Select]
(startapp "C:/windows/explorer.exe" (getvar "DWGPREFIX"))

Replace the
Code: [Select]
(getvar "DWGPREFIX")

portion with the absolute path that you want to use. Like this:

Code: [Select]
(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.
Title: startapp opening folders getfiled? I dunno... help
Post by: nivuahc on April 28, 2005, 12:45:01 PM
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?
Title: startapp opening folders getfiled? I dunno... help
Post by: Mark on April 28, 2005, 12:49:31 PM
I'm guessing something like this.

Code: [Select]

(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 ")"
Title: startapp opening folders getfiled? I dunno... help
Post by: ELOQUINTET on April 28, 2005, 12:53:31 PM
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???).
Title: startapp opening folders getfiled? I dunno... help
Post by: daron on April 28, 2005, 01:17:56 PM
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.
Title: startapp opening folders getfiled? I dunno... help
Post by: Russ on April 28, 2005, 01:24:10 PM
No problem Daron.... Thanks, Nivuahc & Mark, for the input. You both gave me the info I needed. Again, Thanks.
Title: startapp opening folders getfiled? I dunno... help
Post by: nivuahc on April 28, 2005, 06:27:54 PM
my (our, I'm sure) pleasure! :)
Title: startapp opening folders getfiled? I dunno... help
Post by: CAB on April 28, 2005, 07:15:37 PM
Code: [Select]
; 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
      )
   )
)
Title: startapp opening folders getfiled? I dunno... help
Post by: CAB on April 28, 2005, 07:21:14 PM
Here is another, kinda clunky.
Code: [Select]
(setq path (substr
             (setq fakefile
                (getfiled "Select a Folder: "
                          "Pick Save When Done"
                          "*"
                          7)) 1 (- (strlen fakefile) 19)))

                         
And another
Code: [Select]
(setq myfile (getfiled "Choose A Directory" "z. " " " 1))
Title: startapp opening folders getfiled? I dunno... help
Post by: Mark on April 28, 2005, 08:15:46 PM
CAB --

Cool idea but ...
Quote from: Russ
I want to be able to do this without selecting with the mouse


:)
Title: startapp opening folders getfiled? I dunno... help
Post by: CAB on April 28, 2005, 10:26:18 PM
Ooops, :oops: