- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I have a lisp that we use for a detail library. Keeping the txt file it references up to date as we add and remove details is time consuming to say the least.
This morning I've been trying to peice together something to make this easier. A way to process the folders and creating txt files in the folder that I could cut and paste in to the master control file.
The program reads a text file that is formatted like this:
("Folder Name" "Drawing Name" "Drawing Name" "Description")
Sample:
("10 SITE" "10-01" "10-01" "Detail 10-01")
("10 SITE" "10-02" "10-02" "Detail 10-02")
("10 SITE" "10-03" "10-03" "Detail 10-03")
("10 SITE" "10-04" "10-04" "Detail 10-04")
("10 SITE" "10-05" "10-05" "Detail 10-05")
So the user selects a folder,
The list of drawings (.dwg files) is created,
The list and folder name are used to create a .txt file formatted as described above.
I started "franken-lisping" this morning and this is what I have so far.
(defun c:parts (/ )
(setq getfolderpath (strcat (acet-ui-pickdir "Select Detail Folder to Process" "F:\\MWA Work\\PRODUCTION\\Details")"\\"))
(setq
foldername (vl-string-left-trim "\\" getfolderpath)
foldername (substr foldername 1 (vl-string-position (ascii "\\") foldername 0 T))
penultimatefolder (substr foldername (+ 2 (vl-string-position (ascii "\\") foldername 0 T)))
)
(setq Files_Folder (vl-directory-files getfolderpath "*.dwg"))
(setq text "")
(if (/= (length Files_Folder) 0)
(repeat (setq N (length Files_Folder))
(setq e (nth (setq N (- N 1)) Files_Folder))
(setq e (vl-filename-base e))
(setq text (strcat text "\(\"" penultimatefolder "\" " e "\" " "\"" e "\" " "\"Detail " e "\"\)" "\\P"));;;good
);repeat
(princ "\nDoes not containing any *.DWG File.")
)
(if (/= (length Files_Folder) 0)
(command "_.MTEXT" pause pause text "")
)
(princ)
)
I had planned on changing the mtext portion to write to a txt file instead.
My lisp skills are limited so I apologize for the crappy autolisping.
Thank you in advance for any assistance received.
Solved! Go to Solution.