Hi guys,
I am currently using this code to get the folder name containing the current drawing.
FolderName = Dir(ThisDrawing.path, vbDirectory)
What would I use if I wanted to get the foldername one level up (third)?
ex. C:\FIRST\SECOND\THIRD\FOURTH
Any help is greatly appreciated.
Shawn
@XIJIANGWOO wrote:....
What would I use if I wanted to get the foldername one level up (third)?
ex. C:\FIRST\SECOND\THIRD\FOURTH
....
I don't know about that kind of code, but in AutoLISP terms:
If
(setq filepath (getvar 'dwgprefix))
returns
"K:\\FIRST\\SECOND\\THIRD\\FOURTH\\"
then you can trim off after the next-to-last \ character:
(substr
filepath
1
(1+
(vl-string-position
(ascii "\\")
(vl-string-right-trim "\\" filepath)
nil T
); vl-string-position
); 1+
); substr
returns
"K:\\FIRST\\SECOND\\THIRD\\"
@XIJIANGWOO wrote:Hi guys,
I am currently using this code to get the folder name containing the current drawing.
FolderName = Dir(ThisDrawing.path, vbDirectory)What would I use if I wanted to get the foldername one level up (third)?
ex. C:\FIRST\SECOND\THIRD\FOURTH
Any help is greatly appreciated.
Shawn
FolderName = Dir(ThisDrawing.path, vbDirectory) FolderArray = Split(FolderName, "\") DesiredFolderName = FolderArray(FolderArray.length() - 2)
I haven't tested it, but it should work as is.