上面两项是基本的 Autolisp/Vlisp Lisp 内容,使用 OpenDCL 还要对 OpenDCL Runtime 加载,下面是 Stuido 的 Sample 中的代码,写的比较复杂

- (defun LoadRunTime ( / )
- ;; Demand load the OpenDCL.##.ARX. This requires the OpenDCL Runtime or Studio to be installed on each PC first.
- (cond
- ( (= 'EXRXSUBR (type dcl_getversionex)) )
- ( (= 2 (boole 1 (getvar "DEMANDLOAD") 2))
- (command "OpenDCL")
- (if (/= 'EXRXSUBR (type dcl_getversionex))
- (progn
- (alert "The OpenDCL Runtime module failed to load. Please repair the OpenDCL installation and try again.")
- (exit)
- )
- )
- )
- ( (progn
- (alert "The OpenDCL Runtime module cannot be loaded because demand loading is disabled.\nLoad the OpenDCL ARX file manually, or enable demand loading for commands by setting the DEMANDLOAD system variable to 2 or 3.\nSee the "ManualLoading.lsp" sample for a demonstration.")
- (exit)
- )
- )
- )
- )
- (defun LoadODCLProj (proj / fn)
- ;; Call (dcl_PROJECT_LOAD with the <CONTROL>. No re-load, no ProjectAliasName
- ;; Note that without the re-load flag the ODCL is only loaded once, each time (dcl_PROJECT_LOAD is called it tests first if the sProject is already loaded.
- (cond
- ;; Search the support paths for the .ODCL file & load it.
- ( (if (setq fn (findfile proj))
- (dcl_PROJECT_LOAD fn)
- ))
- ;; Load the .ODCL file from the default installed "Samples" folder.
- ( (if
- (or
- (setq fn (vl-registry-read "HKEY_LOCAL_MACHINE\\SOFTWARE\\OpenDCL" "SamplesFolder")) ;_ 32-bit location
- (setq fn (vl-registry-read "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\OpenDCL" "SamplesFolder")) ;_ 64-bit location
- )
- (dcl_PROJECT_LOAD (strcat fn proj))
- ))
- ;; The project failed to load, so report or log the error exit now (or take corrective action and try again)
- (T (alert (strcat """ proj "" failed to load, you may need to add it to an Acad support path for it to load correctly!"))
- (EXIT)
- )
- )
- )
- (princ)
另外一个手动加载代码

- ;;; ManualLoading.lsp
- ;;; For OpenDCL Ver 4.0
- ;;; Edit kwb 20070225 GMT00:00:00
- ;;; Edit orw 20070518 GMT07:30:xx :: added 64 bit arx file selection
- ;;; returns "OpenDCL.x64.17.ARX"
- ;;; Last Edit kwb as suggested by MichaelP 20070608 GMT00:30:xx
- ;;; :: change location of dcl_GETVERSIONEX test.
- ;;
- ;; This code block loads the OpenDCL.##.arx files if not already loaded
- ;; Note, Loader will return T if loaded or nil otherwise.
- ;;
- ;; If the OpenDCL.##.arx is loaded at startup or demand loaded
- ;; this routine need never run.
- (OR dcl_GETVERSIONEX
- ( (lambda ( / proc_arch arxname arxpath )
- ;; Determine the appropriate arx module for
- ;; the processor and the AutoCAD version.
- (setq arxname
- (strcat "OpenDCL"
- (if
- (and
- (setq proc_arch (getenv "PROCESSOR_ARCHITECTURE"))
- (< 1 (strlen proc_arch))
- (eq "64" (substr proc_arch (1- (strlen proc_arch))))
- )
- ".x64."
- "."
- )
- (substr (getvar "acadver") 1 2)
- ".arx"
- )
- )
- ;; Alert the user of a failure to:
- ;;
- ;; (A) Find the arxfile, or
- ;; (B) Load the arxfile.
- ;;
- ;; and return nil.
- ;;
- ;; Otherwise just quietly return t.
-
- (cond
- ( (null (setq arxpath (findfile arxname)))
- (alert (strcat "Couldn't find " arxname ".\nYou may need to add it to an Acad support path"))
- )
- ( (null (arxload arxpath 'nil))
- (alert (strcat "Failed to load " arxname "."))
- )
- ( t )
- )
- )
- )
- )
这些代码就是自动查找符合 CAD 版本的OpenDCL ARX 并加载,看不懂没关系,下面我们进行简化 |