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
Solved! Go to Solution.
Solved by scot-65. Go to Solution.
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.
Funny how things get rewritten over the years and proper credit is rarely given.
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 ) ) )
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.
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...
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
Scot-65: how would you call this function? could you please provide an example?
I'm refering to the Lee Mac one.
Thanks.
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
Funny how things get rewritten over the years and proper credit is rarely given.
Thanks for the TonyT flashback and the updated version !
Can't find what you're looking for? Ask the community or share your knowledge.