Conversion of multiple LISP files to FAS files (requesting change in lsp code)

Conversion of multiple LISP files to FAS files (requesting change in lsp code)

Anonymous
Not applicable
3,943 Views
10 Replies
Message 1 of 11

Conversion of multiple LISP files to FAS files (requesting change in lsp code)

Anonymous
Not applicable

Dear Experts,

 

I got a lisp code that can convert SINGLE lisp file to fas file, which is located in same AutoCAD drawing folder path.

 

But the requirement is to convert MULTIPLE lisp files to fas files, which are existed in so many subfolders in the main folder.

 

The code should ask user to select the main folder path. Then the code should execute all subfolders and then choose only lisp files from all subfolders and then FAS files to be created in subfolder path respectively.

 

Please find the code below:

(defun c:LSP2FAS-Help (/)
(alert (strcat
 "\tLisp (LSP) to Fast and Secure (FAS) Help"
 "\n "
 "\nFile dialog begins in the current directory.   "
 "\nIt is suggested to place and open a drawing (DWG)   "
 "\ninside the input folder you wish to batch process.   "
 "\n "
 "\nOutput file will be in the same folder as the file selected.   "
 "\n "
 "\nThere is no provisional check for an existing FAS file of the same name.   "
))
);end LSP2FAS-Help

(defun c:LSP2FAS ( / a )
(vl-load-com)
(prompt " Lisp to Fast and Secure (FAS). LSP2FAS-Help available. ")
(if (wcmatch (strcase (setq a (getfiled "Convert LSP File to FAS" (getvar "DWGPREFIX") "" 16))) "*.LSP")
 (progn
  (c:vlide)(vlisp-compile 'st a)
  (princ (strcat "\n File " (vl-string-subst ".fas" ".lsp" a) " created. "))
 );progn
 (alert "File extension must be \".LSP\"   ")
);if
(princ)
);end LSP2FAS

Thanks a lot in Advance. 

0 Likes
Accepted solutions (1)
3,944 Views
10 Replies
Replies (10)
Message 2 of 11

pbejse
Mentor
Mentor

@Anonymous wrote:

The code should ask user to select the main folder path. Then the code should execute all subfolders and then choose only lisp files from all subfolders and then FAS files to be created in subfolder path respectively.


 

 

;;; Gilles Chanteau ;;;
(defun allfiles (folder pattern) (apply 'append (cons (if (vl-directory-files folder pattern) (mapcar '(lambda (x) (strcat folder "\\" x)) (vl-directory-files folder pattern) ) ) (mapcar '(lambda (x) (allfiles (strcat folder "\\" x) pattern)) (vl-remove ".." (vl-remove "." (vl-directory-files folder nil -1))) ) ) ) ) (defun c:LSP2FAS (/ a lspFiles) (vl-load-com) (prompt " Lisp to Fast and Secure (FAS). LSP2FAS-Help available. ") (if (and (setq folder (acet-ui-pickdir "Select Lisp Folder" (if folder folder (getvar 'dwgprefix)) ) ) (setq lspFiles (allfiles folder "*.lsp")) ) (foreach a lspFiles (c:vlide) (vlisp-compile 'st a) (princ (strcat "\n File " (vl-string-subst ".fas" ".lsp" a) " created. ")) ) (alert "No \".LSP\" files selected ") ) (princ) )  

HTH

 

0 Likes
Message 3 of 11

Anonymous
Not applicable

Dear Sir,

 

Thanks a lot for responding immediately. The code showing error like below. And the lisp command is not working.

nanaji130285_0-1592546229637.png

Waiting for a solution from your Side. Thanks a lot in advance Sir.

 

0 Likes
Message 4 of 11

pbejse
Mentor
Mentor

copy and paste it again @Anonymous 

 

Earlier it was missing one variable name, I updated the post afterwards

(setq lspFiles (allfiles folder "*.lsp"))

 

0 Likes
Message 5 of 11

Anonymous
Not applicable

It's working Excellent Sir,

 

Please look at below snapshot.

nanaji130285_0-1592549245984.png

 

Actually the lisp code is able to convert one by one lisp file to fas by CLOSING each Visual lisp Window. Otherwise, the code is not able to generate fas files, without closing the lisp window each time.

 

Is there any possibility to update the code without user interfere, each time for each file?

 

Sir, Please try with attached ZIP File, which has some lisp files in each sub folder.

 

 

0 Likes
Message 6 of 11

pbejse
Mentor
Mentor
Accepted solution

@Anonymous wrote:

It's working Excellent Sir,

Is there any possibility to update the code without user interfere, each time for each file?


You are doing it again @Anonymous , that behaviour is part of the code you posted,

 

If you dont want to see VLIDE, Remove this line from the code.

 (c:vlide)

And close VLIDE while you're at it.

 

Message 7 of 11

Anonymous
Not applicable

Sir, Working Fabulously.

 

Thanks a lot, You saved lot of manhours to me.

0 Likes
Message 8 of 11

pbejse
Mentor
Mentor

@Anonymous wrote:

Sir, Working Fabulously.

Thanks a lot, You saved lot of manhours to me.


You are welcome, and please dont call me sir. 

Glad i could help

 

 

 

 

0 Likes
Message 9 of 11

Sea-Haven
Mentor
Mentor

Just a suggestion you can save the fas to another directory if you want so all fas are in one location much easier to manage for end user distribution.

 

(vlisp-compile 'st  fname  (strcat "d:\\alan\\compiled\\" fname ".fas"))

0 Likes
Message 10 of 11

Anonymous
Not applicable

Dear Sir,

 

Thanks for your suggestion. Can you please implement in main code?

 

Thanks a lot in advance Sir.

0 Likes
Message 11 of 11

Sea-Haven
Mentor
Mentor

Change this line

(vlisp-compile 'st a (strcat "c:\\yourdirectory\\etc\\name" a ".fas" ))
0 Likes