- 积分
- 15341
- 明经币
- 个
- 注册时间
- 2002-2-4
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2004-3-8 19:26:00
|
显示全部楼层
那樣它的幫助文件就不應把它列出了!
難怪有這個程序!!
;| AutoLoader.lsp Written by: Kevin J. Nehls 3-31-2002 Version: 1.4 6-26-2002 Credits: Thanks to Robert Bell for giving me the idea to do this. Description: Works the same as AutoCAD's autoloader with a few differences. Basically the major difference in calling this routine is that instead of passing a list of strings for the functions/commands you now pass a list of lists of strings. The other difference is that for a command line command you pass it with "C:" where AutoCAD's autoloader assumed this and appended that to your command name. A more deatailed explaination of differences are listed below. ************************************************************************* I think this stuff has to be here, but I'm not sure, I'm definetly not going to be selling this. I just hope some people find it useful.
Copyright (C) 1994 - 2001 by Autodesk, Inc.
Permission to use, copy, modify, and distribute this software for any purpose and without fee is hereby granted, provided that the above copyright notice appears in all copies and that both that copyright notice and the limited warranty and restricted rights notice below appear in all supporting documentation.
AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC. DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE UNINTERRUPTED OR ERROR FREE.
Use, duplication, or disclosure by the U.S. Government is subject to restrictions set forth in FAR 52.227-19 (Commercial Computer Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) (Rights in Technical Data and Computer Software), as applicable. ************************************************************************* Release history
Kevin Nehls 6-26-2002 4:07pm (version 1.4) -Modified "(princ "\nInitalizing....")" string to include the command/function name in uppercase "(princ ""\"\nInitializing.... " (strcase CmdName) "\")" -Updated naming convention for variables
Kevin Nehls 4-30-2002 10:30am (version 1.3) -Added "Initializing...." string to first call of command -Added slightly more documentation
Kevin Nehls 4-30-2002 10:00am (version 1.2) -Added check for CmdFuncArgList and if exist then create ArgList
Kevin Nehls 4-30-2002 9:15am (version 1.1) -Removed testing code
Kevin Nehls 3-31-2002 (version 1.0) Initial release ************************************************************************* Advantages/Differences are: 1) Default support for VLX and FAS files without having to specify the file extension. 2) It can AutoLoad any function with any number of arguments. 3) It won't throw you into an infinite loop if the file loaded doesn't redefine the function/command that is to be called. --AutoCAD's AutoLoader will do this. If this happens you now get a message telling you where the error occured. --AutoCAD's AutoLoader does not do this. 4) If you want to autoload a command line command you have to prefix it with C:, see Example 1. 5) To have multiple fuctions/commands autoloaded from the same file, just add the additional functions as shown in the examples 6) There is no error handling in this AutoLoader. The only reason you would have it is if the file you were loading was "self-executing". I have my functions/routines handle the error handling and don't need the AutoLoader to do this. 7) This AutoLoader currently needs to have AutoCAD 2000 or newer installed to work just becuase of the use of (vl-filename-extension). You can easily add support for just about all previous versions that support the AutoLISP functions used by either removing that or just looking at the last four chars and determining if it's an extension or not. 8) If you want to use this routine in R12 or R13 DOS, you will need to either modify the 2 ARX loading routines, or you will have to create 2 EXE/EXP loading routines. Basically this is a minor mod to (_knai:AutoARXLoad) and (knai:AutoARXLoad). Oh yea, and to make this work in a version of AutoCAD R14 or older you'll have to comment out each of these lines instead of using the commenting style available to 2000 Visual Lisp users.
Usage and Notes:
(knai:AutoLSPLoad "<filename>" '(("<func1_name>" "<arg1>" "<arg2>") ("<func2_name>" "<arg1>"))) (knai:AutoARXLoad "<filename>" '(("<func1_name>" "<arg1>") ("<func2_name>"))) Example 1: (knai:AutoLSPLoad "lspExample1" '(("C:cmd1") ("C:cmd2")))
Example 2: (knai:AutoLSPLoad "lspExample2" '(("knai:EX2" "str1" "str2" "real" "int")))
--knai:AutoARXLoad works exactly the same way as knai:AutoLSPLoad only for ARX files
Just add your knai:AutoxxxLoad statements to the end of this file or have this file load andother file which has these statements.
|;
(defun _knai:AutoLoader (AppType AppFileName CmdFuncArgList / CmdName CmdNameStr ArgList) (setq AppFileName (strcat "\"" AppFileName "\"")) (mapcar (function (lambda (CmdFuncArgList) (setq CmdName (car CmdFuncArgList) CmdFuncArgList (cdr CmdFuncArgList) ArgList "" ) (if CmdFuncArgList (foreach x CmdFuncArgList (setq ArgList (strcat ArgList x " "))) ) (if (not (eval (read CmdName))) (eval (read (strcat "(defun " CmdName " (" ArgList " / tst)" "(princ ""\"\nInitializing.... " (strcase CmdName) "\")" "(setq tst " CmdName ")" "(if (_knai:FindFile " AppFileName ")" "(progn " "(_knai:Auto" AppType "load " AppFileName ")" "(if (/= tst " CmdName ")" "(" CmdName " " ArgList ")" "(_knai:NoReDefun " "\"" AppType "\"" " " "\"" CmdName "\"" ")))" "(_knai:NoFile " AppFileName "))" ")" ) ) ) ) ) ) CmdFuncArgList ) nil )
(defun _knai:AutoLSPLoad (AppFileName) (load AppFileName) )
(defun _knai:AutoARXLoad (AppFileName) (arxload AppFileName) )
(defun _knai:FindFile (AppFileName) (or (findfile (strcat AppFileName ".vlx")) (findfile (strcat AppFileName ".fas")) (findfile (strcat AppFileName ".lsp")) (findfile (strcat AppFileName ".arx")) (findfile AppFileName) ) )
(defun _knai:NoFile (AppFileName) (alert (strcat "The file \"" AppFileName "\"" (if (not (vl-filename-extension AppFileName)) "(.vlx/.fas/.lsp/.arx) " " " ) "was not found in your search path folders.\n" "Check the installation of the support files and try again." ) ) (princ) )
(defun _knai:NoReDefun (AppType CmdName) (alert (strcat "Syntax error in knai:Auto" (strcase AppType) "Load for function/command:\n\n\"" "\"" (strcase CmdName) "\"" ) ) )
(defun knai:AutoLSPLoad (AppFileName CmdFuncArgList) (_knai:AutoLoader "lsp" AppFileName CmdFuncArgList) )
(defun knai:AutoARXLoad (AppFileName CmdFuncArgList) (_knai:AutoLoader "arx" AppFileName CmdFuncArgList) )
;;;************************************************************************* ;;; Add knai:AutoxxxLoad statements here or load another file to house ;;; those calls. ;;;*************************************************************************
;;;(load "<your external file with the autoload statements>")
;;Silent load autoloader (princ) |
|