Reputation: 7619
I have a huge LISP
project, I've made a prv
file that permits to the VLIDE
to compile this project into a single vlx
file (it compiles also the fas
file). The problem is that it is not possible to compile the project from outside the autocad or from command prompt so I cannot automate the vlx
building using a script.
The question is: is there any way to do this? Can I compile fas-vlx
from outside the autocad? Or can I launch autocad giving a script that compiles the prv
and then closes the autocad?
Upvotes: 6
Views: 2787
Reputation: 11
After some tests here I could finally make it a bit more faster and easy to use.
At command line, call autocad with some startup switches. You'll need an empty drawing, call it dummy.dwg. The /b
stands for the script you'll run:
"C:\Program Files\Autodesk\AutoCAD 2019\acad.exe" "C:\somefolder\dummy.dwg" /nologo /nossm /b "C:\somefolder\CompileLispProjects.scr"
Inside .scr file:
;;MAKE VLISP OPEN BUT LET AUTOCAD ACTIVE. YOU NEED VLISP OPEN TO LOAD VLISP-* FUNCTIONS
(C:VLIDE T)
;; TRY TO RUN VLISP-MAKE-PROJECT FUNCTION
(setq errobj (vl-catch-all-apply 'function-which-will-use-vlisp-make-project-fas))
;; IF ANY ERROR COMES OUT, STOP AND ALERT
(if (vl-catch-all-error-p errobj)
(progn
(princ "\n***ERROR COMPILING SOMETHING***\n")
(princ (vl-catch-all-error-message errobj))
(princ)
);_progn
;; ALL GOOD, QUIT AUTOCAD
(progn
;; THERE'S A SAFE LOCK IN QUIT COMMAND, SO SAVE A DUMMY FILE AND QUIT AGAIN WITH IT SAVED
(command-s "._QUIT" "_N" "")
(command-s "._QUIT" "")
);_progn
);_if
;; IT'S IMPORTANT TO HAVE THE LAST LINE EMPTY (<ENTER>)
The trick in that code is the (C:VLIDE T)
. It's not documented and I've found it because I know AutoLISP has a lot of undocumented functions. Try it with nil
too, you'll see that VisualLISP will be the active window, locking your AutoCAD to execute the next commands (and so you'll need to click somewhere in AutoCAD to activate its window and make the code to run properly).
Note: When AutoCAD is closing, maybe your VisualLISP window will hold for a while, don't try to activate it. Let it be for few seconds and it'll close by itself.
Upvotes: 1
Reputation: 410
Be warned this is a bit of a Rube Goldberg. but it works!
I will be demonstrating with Autocad 2014.
First you will need to make an Autocad Script file that contains some undocumented commands. I named mine build.scr
(Note that vlisp-compile-list
is not documented anywhere. If you do find some documentation please let me know!)
vlide
(
vlisp-compile-list
'st
(
list
(strcat (getenv "UserProfile") "\\Documents\\AutocadFiles\\gui.lsp"))
...
)
(strcat (getenv "UserProfile") "\\Documents\\AutocadFiles\\CompiledLisp.fas")
)
Then make a batch file that contains this:
@echo off
cd c:\Program Files\Autodesk\AutoCAD 2014
start acad.exe /b build.scr
It starts AutoCAD and runs the specified script
next you will need to Download and install AutoHotKey
and build a script like this for it:
Run, BuildLisp.bat
sleep, 30000
WinActivate, Autodesk AutoCAD 2014 - [Drawing1.dwg]
WinActivate, Visual LISP for AutoCAD <Drawing1.dwg>
WinActivate, Autodesk AutoCAD 2014 - [Drawing1.dwg]
sleep, 10000
WinClose, Autodesk AutoCAD 2014 - [Drawing1.dwg]
When you activate this script. It should open AutoCAD and build all of your LSP files into a single .FAS then close.
Somethings to Note. The Visual LISP editor must be open to compile, The compile will only happen when window activation occurs.
If anyone finds a better way. PLEASE Let me know!
Upvotes: 1
Reputation: 1628
You have to launch AutoCAD, but even so it gets tricky as it requires the use of undocumented functions.
Upvotes: 1