(defun Directory-Dia ( Message / sh folder folderobject result)
;; By Tony Tanzillo
;; Modified by Tim Willey
;; 16 Will let you type in the path
;; 64 Will let you create a new folder
(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))
Message
0 ; This is the bit number to change.
)
)
(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)
(if (/= (substr result (strlen result)) "\\")
(setq result (strcat result "\\"))
result
)
)
)
)
;;;==================================================================
;;; (JustPath cFileName)
;;; Returns the path portion of a complete path and file name.
;;;------------------------------------------------------------------
;;; Parameters:
;;; cFileName str to check
;;;------------------------------------------------------------------
;;; Returns:
;;; [STR]
;;; Example: (setq a "C:\\MyFolder\\MyFile.txt")
;;; (JustPath a) ; returns "C:\MyFolder"
;;;------------------------------------------------------------------
(defun JustPath (cFileName / bsLoc)
(setq bsLoc (rat "\\" cfileName))
(if (> bsLoc 0)
(substr cFilename 1 (1- bsLoc))
""
) ;_ end of if
) ;_ end of defun
Thanks Tim, I had needed this in the past, but never had time/success in creating/finding something similar. Looks like I'll be digging into some old projects. Fun, fun, fun...Digging in old routines is MAJOR FUN! :wink: Glad I don't have to do it. You're welcome ...... I guess.
:lol:
(vl-filename-directory "c:\\MyFolder\\MyFile.txt")
"C:\\MyFolder
Command: (JustPath Path)
; error: no function definition: RAT
Matt,Code: [Select](vl-filename-directory "c:\\MyFolder\\MyFile.txt")
"C:\\MyFolder
Matt,
You would also need to share the function 'Rat'.QuoteCommand: (JustPath Path)
; error: no function definition: RAT
;;;===========================================================================
;;; (Rat cSearchExpression cExpressionSearched)
;;; Returns the numeric position of the last (rightmost)
;;; occurrence of a character string within another character string.
;;;---------------------------------------------------------------------------
;;; Parameters:
;;; cSearchExpression [STR] - String to search for
;;; cExpressionSearched [STR] - String to search
;;;---------------------------------------------------------------------------
;;; Returns:
;;; [INT] - Posistion of the string
;;; Example: (setq a "A Lot of Text.")
;;; (Rat "Text" a) ; returns 10
;;;===========================================================================
(defun Rat (cSearch cSearchIn / return SearchFor cont n)
;; We need to escape for special characters
(cond
(
(= cSearch "\\")
(setq SearchFor "*`\\*")
)
(
(= cSearch ".")
(setq SearchFor "*`.*")
)
(
(= cSearch "#")
(setq SearchFor "*`#*")
)
(
(= cSearch "*")
(setq SearchFor "*`**")
)
(
(= cSearch "~")
(setq SearchFor "*`~*")
)
(
(= cSearch "-")
(setq SearchFor "*`-*")
)
(
(= cSearch ",")
(setq SearchFor "*`,*")
)
(
(= cSearch "`")
(setq SearchFor "*``*")
)
(
T
(setq SearchFor (strcat "*" cSearch "*"))
)
) ;_ end of cond
(cond
(
;; Make sure there is a match
(not (wcmatch cSearchIn SearchFor))
(setq return 0)
)
(
T
(setq n (strlen cSearchIn))
(setq TestStr (substr cSearchIn n))
(setq cont T)
(while Cont
(if (wcmatch TestStr SearchFor)
(progn
(setq Cont nil)
(setq return n)
) ;_ end of progn
(progn
(setq n (1- n))
(setq TestStr (substr cSearchIn n))
) ;_ end of progn
) ;_ end of if
) ;_ end of while
)
) ;_ end of cond
return
) ;_ end of defun
--------------------------------------------------------------------------------
Method BrowseFolder as String
This method will prompt the user with a dialog box that allows the selection of directory folders only.
AutoLISP Syntax:
(Setq rValue (dcl_BrowseFolder
Caption [as String]
[Optiona]/DefaultDirectory [as String]
[Optional]/RootFolder [as String]
[Optional]/Flags [as String]))
<Flags> is a bit flag, and its default value is 1 (to return only file system folders). The following values used for <Flags> are from the Windows SDK header file in hexadecimal:
BIF_RETURNONLYFSDIRS 0x0001
BIF_DONTGOBELOWDOMAIN 0x0002
BIF_STATUSTEXT 0x0004
BIF_RETURNFSANCESTORS 0x0008
BIF_EDITBOX 0x0010
BIF_VALIDATE 0x0020
BIF_NEWDIALOGSTYLE 0x0040
BIF_USENEWUI (BIF_NEWDIALOGSTYLE | BIF_EDITBOX)
BIF_BROWSEINCLUDEURLS 0x0080
BIF_UAHINT 0x0100
BIF_NONEWFOLDERBUTTON 0x0200
BIF_NOTRANSLATETARGETS 0x0400
BIF_BROWSEFORCOMPUTER 0x1000
BIF_BROWSEFORPRINTER 0x2000
BIF_BROWSEINCLUDEFILES 0x4000
BIF_SHAREABLE 0x8000 (remote shares, requires BIF_USENEWUI)
See MSDN for information about each flag.
With the new combination of arguments, the flag argument will not be necessary for duplicating the original behavior and more, but it might still be fun to check out the new style UI (flag value decimal 81).
https://forum.dwg.ru/showthread.php?t=81587
Can anyone help me or edit it. Lisp is perfect but can't export the layer to any file. I can't find the .txt .csv file in the selected export folder.
https://forum.dwg.ru/showthread.php?t=81587
Can anyone help me or edit it. Lisp is perfect but can't export the layer to any file. I can't find the .txt .csv file in the selected export folder.
...After VERY QUICK look, that looks a lot like Design center (-i.e. what motivation is there for someone to use that tool vs design center or their current solution)? Meaning, the end-user is having problems editing current lisp, they may not be up for adding another solution instead of just editing their current tool--or adopting a built-in solution.
http://lee-mac.com/steal.html