Creating txt file with required file names (for required extension files only)

Creating txt file with required file names (for required extension files only)

Anonymous
Not applicable
1,111 Views
4 Replies
Message 1 of 5

Creating txt file with required file names (for required extension files only)

Anonymous
Not applicable

Dear Helpers,

 

I need a lisp to create a text file in the given path for required extension files only. I got below code from autodesk website, but it's not exporting the file names to txt file.

(vl-directory-files "T:/MECHANICAL/Sagar/plumbing final cad dwg/single stack" "*.dwg")

Please help me, Thankin you in advance

0 Likes
Accepted solutions (2)
1,112 Views
4 Replies
Replies (4)
Message 2 of 5

dbhunia
Advisor
Advisor
Accepted solution

Try this......

 

(defun C:GFL (/);Put temp Variables
(setq F_list (vl-directory-files "D:/Debashis/AutoCAD_Reff" "*.dwg"));;Source Folder path RED
(setq file (strcat "D:/Debashis/" "Details.txt"));;Destination Text file Path & Nane BLUE
(setq File_Text (open (strcat "D:/Debashis/" "Details.txt") "w"))
(repeat (setq N (length (setq F_list (reverse F_list))))
	(setq Data (nth (setq N (- N 1)) F_list))
	(write-line Data File_Text)
)
(close File_Text)
)

 

Blue lines should be same in both place.......


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
Message 3 of 5

Anonymous
Not applicable

Thank you Sir,

Is there any possibility to update the code to give user input at command prompt for file path and file extensions?.

Advanced thanking you Sir.

0 Likes
Message 4 of 5

dbhunia
Advisor
Advisor
Accepted solution

@Anonymous wrote:

Thank you Sir,

Is there any possibility to update the code to give user input at command prompt for file path and file extensions?.

Advanced thanking you Sir.


 

Try this.....

 

(defun C:GFL (/);Put temp Variables
(vl-load-com)
(setq sh (vla-getInterfaceObject (vlax-get-acad-object) "Shell.Application" ))
(setq folder (vlax-invoke-method sh 'BrowseForFolder 0 "" 0 ))
(vlax-release-object sh)
(setq folderobject (vlax-get-property folder 'Self))
(setq result (vlax-get-property FolderObject 'Path))
(vlax-release-object folder)
(vlax-release-object FolderObject)
(setq extn (getstring "\nEnter The Exten: "))
(setq Fname (getstring T "\nEnter Output Text File Name: "))
(setq Path_T (strcat result "\\" Fname))

(setq F_list (vl-directory-files result (strcat "*." extn)))
(setq File_Text (open Path_T "w"))
(repeat (setq N (length (setq F_list (reverse F_list))))
	(setq Data (nth (setq N (- N 1)) F_list))
	(write-line Data File_Text)
)
(close File_Text)
)

Input should be like.......

 

Capture.PNG

 

Text file would generate at selected folder......

 

 


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
Message 5 of 5

Anonymous
Not applicable

Thank you So much sir

0 Likes