Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Folder selection dialogue box

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
bgingerich
5539 Views, 9 Replies

Folder selection dialogue box

I'm working on a lisp that goes through a whole list of files and does different things to those files.  I've been racking my brain for a way to select just a folder via a dialogue box, but haven't found a way.  I'm sure it can be done with dcl, but I don't know where to start. 

 

This would not be the standard "file" selection box, but would only list the folders and let me select one even if there are others "under" them.  This is what I'd like it to look like. 

 

I'm not sure if there is a standard AutoCAD box that I could call for this or not, but if someone knows of one that would help a lot. 

 

Thanks

─────────────────────────────────────────────────────────────────────────────────────────────
Brandon Gingerich
9 REPLIES 9
Message 2 of 10
scot-65
in reply to: bgingerich

Give credit to Lee Mac who helped me out on this one a while back.

DCL cannot do the browse for file, but this will.

 

If you cannot make sense of the attached file, I'll

post my snippet - which is a derivative of Lee Mac's.

 

Be careful with the flags. If you preset a path, you cannot do a previous

folder above the beginning of the path (my only downside findings).

 

Also, Lee Mac did not include the following in the code:

(VL-LOAD-COM)

 

???


Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.


Message 3 of 10
Jason.Piercey
in reply to: scot-65

Funny how things get rewritten over the years and proper credit is rarely given.

 

https://groups.google.com/forum/?fromgroups#!msg/autodesk.autocad.customization/-SHIm7gQK9c/Vz9U3tLc...

 

 

Then there was this revision added at a later time.

 

; Arguments:
; [title] - string, title of dialog box.  Can be a null string
; [options] - integer, see notes
; [rootFolder] - string, path to folder
; revisions
; - 11/14/2005
;   added (vla-get-hwnd (vlax-get-acad-object))
;   in place of passing a zero for dual monitor
;   support per a suggestion from Tim Willey.
(defun browseForFolder (title options rootFolder / sh folder folderobject result)
 (vl-load-com)
 (setq
  sh
  (vla-getInterfaceObject
   (vlax-get-acad-object)
   "Shell.Application"
   )
  )

 (setq
  folder
  (vlax-invoke-method
   sh
   'BrowseForFolder
   (vla-get-hwnd (vlax-get-acad-object))
   title
   options
   rootFolder
   )
  )
 (vlax-release-object sh)

 (if folder
  (progn
   (setq
    folderobject
    (vlax-get-property folder 'Self)
    )
   (setq
    result
    (vlax-get-property FolderObject 'Path)
    )
   (vlax-release-object folder)
   (vlax-release-object FolderObject)
   result
   )
  )
 )

 

Message 4 of 10
bgingerich
in reply to: scot-65

Thanks for that code!  Sorry it took so long to get back with you; I've had other things to do and just this weekend tried it out.  Exactly what I was looking for! 

 

Now I just have to go through the code and figure out how it works. Smiley Happy

─────────────────────────────────────────────────────────────────────────────────────────────
Brandon Gingerich
Message 5 of 10
bgingerich
in reply to: bgingerich

Now I'm really curious.  Where is the documentation on this "BrowseForFolder" VBA method?  The closest I can come to it is in exel using:

variable = Application.FileDialog(msoFileDialogFilePicker)

 If someone could explain to me how you would go about writing this code, that would be much appreciated.  I'm trying to teach myself Lisp (Auto and Visual) and this is about as far a my brain is stretching right now.  Just looking for someone to point me in the right direction...

─────────────────────────────────────────────────────────────────────────────────────────────
Brandon Gingerich
Message 6 of 10
devitg
in reply to: bgingerich

How about it? It is not mine ,

 

 

Author is FATTY "TOH"

 

 

;- ---------------------------------------------------------------

(defun select-folder-and-full-name-list (   /
;;;					 COUNT FN FOLD  FULL-NAME-LIST-
					 )
(if   fold-to-save 
(setq to-save fold-to-save)
  (setq to-save " ")
  )
  
(setq	fn	       (getfiled "Select *Any Of .DWG Files* FROM WHERE YOU WANT TO dig on  : "
				 to-save
				 "dwg"
				 4
		       )
	fold	       (vl-filename-directory fn)
	full-name-list- (vl-directory-files fold "*.dwg" 1)
	full-name-list (mapcar (function (lambda (x)
					   (strcat fold "\\" x)
					 )
			       )
			       full-name-list-
		       )
	count (length full-name-list)
  )
(setq fold-to-save (strcat fold  "\\"))
  
  full-name-list
); (select-folder-and-full-name-list)
;;********************************************************************************************************

 It will search at the folder , not sub folders

 

 

 

Message 7 of 10
ucastillo2
in reply to: scot-65

Scot-65: how would you call this function? could you please provide an example?

I'm refering to the Lee Mac one.

 

Thanks.

Message 8 of 10
Lee_Mac
in reply to: ucastillo2

ucastillo2 wrote:

Scot-65: how would you call this function? could you please provide an example?

I'm refering to the Lee Mac one.

 

Thanks.

 

Hi ucastillo2

 

Please refer to the information on my site here - ask if you are still stuck.

 

Lee

Message 9 of 10
dale_fugier
in reply to: bgingerich
Message 10 of 10
rkmcswain
in reply to: Jason.Piercey

Jason.Piercey wrote:

Funny how things get rewritten over the years and proper credit is rarely given.

 

https://groups.google.com/forum/?fromgroups#!msg/autodesk.autocad.customization/-SHIm7gQK9c/Vz9U3tLc...

Thanks for the TonyT flashback and the updated version !

 

 

 

 

 

R.K. McSwain     | CADpanacea | on twitter

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost