Answer: Release at the end of your loop.
Answer: Release at the end of your loop.
My ACAD2002 help says if I include flag 16 it will allow me to select a directory, but it doesn't work that way.
Might it work in newer releases so I can avoid having to use dos_getdir?
Don't get me wrong. I love DOSLIB, but you seem to need a different version installed for almost every AutoCAD release.
John F. Uhden
Solved! Go to Solution.
This works for me:
(getfiled "Select Block" "" "dwg" 16))
Yes, this is about BKEEPER, but I don't think you're getting it. Part of the issue is being able to select a directory (folder) not a file.
John F. Uhden
*delete*
Alternatively to dos_getdir, you can use acet-ui-pickdir which come with ExpressTools
(acet-ui-pickdir [<message> [<start-dir> [<title>]]])
@john.uhden wrote:
My ACAD2002 help says if I include flag 16 it will allow me to select a directory, but it doesn't work that way.
Might it work in newer releases so I can avoid having to use dos_getdir?
Don't get me wrong. I love DOSLIB, but you seem to need a different version installed for almost every AutoCAD release.
What about "Shell.Application"
(setq sh (vla-getInterfaceObject (vlax-get-acad-object) "Shell.Application"))
(setq folder (vlax-invoke sh 'browseforfolder 0 "Browse" "&H10" ))
(vlax-release-object sh)
BIF_RETURNONLYFSDIRS = &H1 ' For finding a folder to start document searching
BIF_DONTGOBELOWDOMAIN = &H2 ' For starting the Find Computer
BIF_STATUSTEXT = &H4 ' Top of the dialog has 2 lines of text for BROWSEINFO.lpszTitle and one line if
' this flag is set. Passing the message BFFM_SETSTATUSTEXTA to the hwnd can set the
' rest of the text. This is not used with BIF_USENEWUI and BROWSEINFO.lpszTitle gets
' all three lines of text.
BIF_RETURNFSANCESTORS = &H8
BIF_EDITBOX = &H10 ' Add an editbox to the dialog
BIF_VALIDATE = &H20 ' insist on valid result (or CANCEL)
BIF_NEWDIALOGSTYLE = &H40 ' Use the new dialog layout with the ability to resize
' Caller needs to call OleInitialize() before using this API
BIF_USENEWUI = (BIF_NEWDIALOGSTYLE Or BIF_EDITBOX)
BIF_BROWSEINCLUDEURLS = &H80 ' Allow URLs to be displayed or entered. (Requires BIF_USENEWUI)
BIF_UAHINT = &H100 ' Add a UA hint to the dialog, in place of the edit box. May not be combined with BIF_EDITBOX
BIF_NONEWFOLDERBUTTON = &H200 ' Do not add the "New Folder" button to the dialog. Only applicable with BIF_NEWDIALOGSTYLE.
BIF_NOTRANSLATETARGETS = &H400 ' don't traverse target as shortcut
BIF_BROWSEFORCOMPUTER = &H1000 ' Browsing for Computers.
BIF_BROWSEFORPRINTER = &H2000 ' Browsing for Printers
BIF_BROWSEINCLUDEFILES = &H4000 ' Browsing for Everything
BIF_SHAREABLE = &H8000 ' sharable resources displayed (remote shares, requires BIF_USENEWUI)
HTH
That's cool, but all I get is a folder object without a name/path property.
Maybe this is a shortcoming of ACAD2002?
John F. Uhden
Here you can find a script from @Lee_Mac 's that uses "Shell application" to return selected directory.
Use this link for samples and detailed explanation
;; Browse for Folder - Lee Mac
;; Displays a dialog prompting the user to select a folder.
;; msg - [str] message to display at top of dialog
;; dir - [str] [optional] root directory (or nil)
;; bit - [int] bit-coded flag specifying dialog display settings
;; Returns: [str] Selected folder filepath, else nil.
(defun LM:browseforfolder ( msg dir bit / err fld pth shl slf )
(setq err
(vl-catch-all-apply
(function
(lambda ( / app hwd )
(if (setq app (vlax-get-acad-object)
shl (vla-getinterfaceobject app "shell.application")
hwd (vl-catch-all-apply 'vla-get-hwnd (list app))
fld (vlax-invoke-method shl 'browseforfolder (if (vl-catch-all-error-p hwd) 0 hwd) msg bit dir)
)
(setq slf (vlax-get-property fld 'self)
pth (vlax-get-property slf 'path)
pth (vl-string-right-trim "\\" (vl-string-translate "/" "\\" pth))
)
)
)
)
)
)
(if slf (vlax-release-object slf))
(if fld (vlax-release-object fld))
(if shl (vlax-release-object shl))
(if (vl-catch-all-error-p err)
(prompt (vl-catch-all-error-message err))
pth
)
)
(LM:browseforfolder "Select folder" nil 0)
Miljenko Hatlak
It's sort of an abbreviated looking dialog, but it works!
Thanks to you and @Lee_Mac.
I'll have to study why.
John F. Uhden
I always used the one from Tony T.
(defun BrowseForFolder ( str / sh folder folderobject result)
;;
;; From: Tony Tanzillo
;; Newsgroups: autodesk.autocad.customization
;;
;; (setq folder (BrowseForFolder "Select Folder"))
;;
(vl-load-com)
(setq sh
(vla-getInterfaceObject
(vlax-get-acad-object) "Shell.Application"))
(setq folder (vlax-invoke-method sh 'BrowseForFolder 0 str 0))
(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, John
That one has a little better flavor. Tony T. is/was a very wise fellow.
John F. Uhden
Modified a Tony T. function? That's blasphemy!
Although I am still wondering if it's necessary to release local objects.
Do you recall if Tony had done that?
John F. Uhden