home *** CD-ROM | disk | FTP | other *** search
- From: rurban@x-ray.at (Reini Urban)
- Newsgroups: comp.cad.autocad,alt.cad.autocad,alt.answers,comp.answers,news.answers
- Subject: comp.cad.autocad AutoLISP FAQ (part 1/2) - general
- Reply-To: rurban@xarch.tu-graz.ac.at (Reini Urban)
- Followup-To: comp.cad.autocad
- Distribution: world
- Organization: TU Graz-Fac.of Architecture & X-RAY Graz
- Approved: news-answers-request@mit.edu
- Keywords: FAQ, AutoLISP, AutoCAD
- Summary: AutoLISP is a scripting language for AutoCAD, a wellknown CAD
- package. This AutoLISP FAQ is posted to comp.cad.autocad, alt.cad.autocad
- and *.answers monthly.
- NNTP-Posting-Host: oma.graz.inode.at
- Message-ID: <40936e25@e-post.inode.at>
- Date: 1 May 2004 11:30:13 +0200
- X-Trace: e-post.inode.at 1083403813 195.58.172.138 (1 May 2004 11:30:13 +0200)
- Lines: 1269
- Path: senator-bedfellow.mit.edu!bloom-beacon.mit.edu!news2.telebyte.nl!newsfeed.stueberl.de!newsfeed.utanet.at!newscore.univie.ac.at!e-post.inode.at!not-for-mail
- Xref: senator-bedfellow.mit.edu comp.cad.autocad:164733 alt.cad.autocad:148002 alt.answers:72708 comp.answers:57013 news.answers:270654
-
- Posted-By: auto-faq 3.2.1.5
- Archive-name: CAD/autolisp-faq/part1
- URL: http://xarch.tu-graz.ac.at/autocad/news/faq/autolisp.html
- Version: 2.28
- Last-modified: 2002-06-25
- Posted-By: Reini Urban <rurban@x-ray.at>
- Posting-Frequency: monthly
- Copyright: see Appendix [A]
-
- Welcome to the comp.cad.autocad AutoLISP FAQ
- by Reini Urban <rurban@x-ray.at>
-
- Autolisp is a scripting language for AutoCAD, a well known CAD package.
- This AutoLISP FAQ is posted to comp.cad.autocad, alt.cad.autocad and
- the *.answers groups monthly. Some AutoCAD FAQ's are at
- http://www.autodesk.com/support/autocad/ but not posted to
- comp.cad.autocad. The contents and the samples apply to all
- releases of AutoLISP since Release 10, including Visual Lisp, Vital Lisp
- and ACOMP. There's no special AutoLISP newsgroup.
- Best are comp.cad.autocad and autodesk.autocad.customization,
- but please don't bother comp.lang.lisp.
- Source code of all functions in this FAQ is in FAQ-CODE.LSP
- (for location see [A.1]), there's also a Winhelp file.
- Thanks to all who have contributed. Corrections and contributions
- always welcome.
- Please see http://xarch.tu-graz.ac.at/acadwiki/RulesToLiveBy
-
- This is part 1/2 of the AutoLISP FAQ v2.28, which consists of:
-
- AutoLISP FAQ (part 1/2) - General
- AutoLISP FAQ (part 2/2) - Samples, code
-
- | changes, + new in items from this version to the last posted version,
- intermediate personal comments and uncertainties in <..>
-
- -----------------
- Table of Contents
- -----------------
- part 1: General
- [0] The Future of AutoLISP? Should I learn it or VB instead?
- [0.1] What changed with AutoCAD 2000?
- [0.2] We cannot create ARX anymore?
- [1] Where can I find AutoLISP routines on the Internet?
- [1.1] Are the comp.cad.autocad articles stored somewhere?
- [1.2] Autodesk's SDK
- [2] What are the best books to learn AutoLISP?
- [2.1] Online AutoLISP documents, Winhelp [deleted]
- [2.2] AutoLISP Coding Style
- [3] How do I debug AutoLISP programs?
- [3.1] Native AutoLISP debuggers
- [3.2] Modular style, TRACE
- [3.3] BREAK function, debug-print
- [4] How can I protect my AutoLISP programs? Security
- [4.1] Kelvinate
- [4.2] Protect
- [4.3] Kelvinate and Protect
- [4.4] Convert
- [4.5] ACOMP
- [4.7] Lisp2C
- [4.6] Vital LISP Professional
- [4.8] Visual Lisp by Autodesk
- [5] AutoLISP compilers
- [5.1] ACOMP
- [5.2] Vital LISP Professional
- [5.3] Visual Lisp by Autodesk
- [5.4] Better ones: Common Lisp and Scheme
- [6] AutoLISP editors and other tools
- [6.1] AutoLISP editors
- [6.2] Analyzers, Packager and Parenthesis checkers
- [6.3] Pretty Printers
- [7] AutoLISP problems and bugs
- [8] Sorting with AutoLISP
- [9] Recursion
- [10] Iteration with MAPCAR,...
- + [11] S::STARTUP, My LISPs aren't loading at startup anymore
- [12] How to AUTOLOAD my programs?
- [13] How can I pass a variable number of
- arguments to a LISP function?
- [14] How can I avoid stack overflows?
- [15] (command "ROTATE3D") does not work! Why?
- [16] Lisp programs operating over multiple drawings
- [17] How to export Visual Lisp functions to AutoLISP/AutoCAD?
- --
- [A] Disclaimer, Notes from the authors
- [A.1] FAQ Locations
-
- part 2: Samples, code
- [20] General Helper functions
- [20.1] List manipulation
- [20.2] String manipulation
- [20.3] symbol->string
- [20.4] AutoCAD entity access
- [21] Sample Lisp programs
- [21.1] Globally change text, polylines, layer utils, date stamp
- [21.2] Plot dialog from within LISP. Using DDE or ActiveX
- [21.3] (entmod),(entmake) Layers, without (command "_LAYER"...)
- [21.4] How to select multiple files in LISP? (as in FILES-Unlock)
- [21.5] Replace multiple blocks
- [21.6] (vports), VIEWPORT entity, pixel conversion
- [21.7] Select all visible objects: zoom coordinates
- [21.8] How to write XYZ data of selected objects to a file?
- [22] Block Attributes
- [22.1] How to access block attributes?
- [22.2] How to MODIFY block attributes? DATESTAMP.LSP
- [22.3] How to UPDATE block attributes?
- [22.4] How to ENTMAKE a Block Complex Entity in AutoLISP
- [23] Polylines
- [23.1] How to access polyline VERTICES?
- [23.2] How to JOIN multiple lines to polylines?
- [23.3] Change WIDTH of multiple polylines
- [23.4] Create a polyline or spline: with (ENTMAKE) or (COMMAND)
- [23.5] How to calculate the LENGTH of polylines?
- [23.6] How to revert the polyline direction?
- [23.7] How to get the CENTER of a polyline?
- [24] Circle/Arc Geometry: BULGE conversion, some trigonometry
- [25] DCL: listboxes with tabs or monotext font
- [26] EED Extended Entity Data: Get and Store
- [26.1] Select objects on their EED with (ssget "X")
- [26.2] Get EED from an object
- [27] How to break a command in LISP?
- [27.1] How to do an unlimited number user prompts?
- [28] How to decode ACIS internal geometry with LISP
- --
- [A] Disclaimer, Notes from the author
- + [A.1] FAQ Locations
- [B] Acknowledgements
- [C] Recent Changes
-
- ----------------------------------------------------------------------
- Subject: [0] The Future of AutoLISP? Should I learn it or VB instead?
-
- AutoLISP will be definitely supported in future releases.
- VB was introduced to simplify Office Automation: ACAD <-> Excel/Access
- Both languages have advantages and disadvantages. You should take a look
- at both. VB seems to be more graphical and AutoLISP more logical. The
- object concept of VBA seems to be easier to learn, but you cannot run
- commands like in AutoLISP. The new VBA (>= R14.01) is extremely fast.
- See also [5.2]
- The future of AutoLISP already is Visual Lisp. For VLISP see [5.3]
- URL's: http://www.autodesk.com/vlisp,
- http://www.autodesk.com/develop/devres/visual/faq.htm, also [0.1] below.
-
- [0.1] What changed with AutoCAD 2000?
-
- The name :) No, there's much more, but you may call it Release 2000, R15
- (though 15 is the version number and not the release number), A2000 or
- abbrevated A2K.
- The new Visual Lisp kernel (formerly "Vital Lisp") replaced the old
- xlisp-based AutoLISP kernel.
-
- What problems should you expect with Visual Lisp in R2000? (only the bad
- news). At http://xarch.tu-graz.ac.at/autocad/docs/r2000-news.txt
- I compiled a white paper. The major points are:
- Stricter error checking on loading, ACAD.LSP vs ACADDOC.LSP,
- You cannot/need not compile to ARX anymore, Incompatibilities
- AutoLISP - Visual LISP: Lisp functions are atoms no lists anymore,
- Protected symbols,
- Better exception handling, Pathname of the loaded VLX?,
- vl-export-symbol -> vl-doc-set, long acad symbol table names: EXTNAMES
- ActiveX automation, Variants and SAFEARRAYs, FAS4 cannot be loaded on R14.
-
- [0.2] Why cannot I create ARX anymore?
-
- With AutoCAD 2000 you cannot do that anymore as with ViLL or VLISP 4.
- Instead you compile to VLX (Visual Lisp Extension), which has basically
- the same functionality as the old Visual Lisp/Vital Lisp ARX, with the
- following differences:
-
- * You'll have to (load) the app. Before you had to (arxload) it.
- - Pro: Initialization is easier. The VLX doesn't abort completely on any
- error while loading. Before the whole ARX crashed with mysterious
- errors.
- - Pro: VLX are much smaller because they don't carry the whole Lisp
- environment, the VLRTS, along. Instead there's only one environment,
- VL.ARX, distributed with acad itself. So you can ship much smaller
- applications.
- - Contra: With loaded VLX there's no easy way to get the pathname of the
- app. Before it was possible with (arx) or (vl-exe-filename)
-
- * VLX has the option of seperate or common namespaces. With seperate
- ARX you had only the option of seperate namespaces (in fact completely
- seperate lisp environments).
- - Pro: This means that you can now choose the fastest and most secure
- compilation mode (LINK, DROP) and still keep common namespaces. (most of
- my apps benefit from this. I seperated my apps into one main module and
- several smaller ones)
- - Pro: ARX is only compatible per release, thus completely incompatible!
- VLX is new and therefore compatible only to newer releases (R16,...) but
- as lisp application it is by far more compatible than a ARX app.
-
- * Loaded ARX apps with (arx) return the pathname, loaded VLX apps with
- (vl-list-loaded-vlx) only a symbol, no path. This is a design flaw.
-
- You don't need ARX modules anymore. This is a feature, no bug.
-
- ------------------------------
-
- Subject: [1] Where can I find AutoLISP routines on the Internet?
-
- The big AutoCAD tools sites with LISPs are:
-
- "AutoCAD Plugin Store" by beyond.com
- http://www.cadplugins.com/
- This is the by AutoDESK "officially recommended" tools site.
- "CADalog" - The AutoCAD Shareware Clearinghouse (Mike Clark)
- http://www.cadalog.com/
- "The CAD Depot", formerly known as "cadsyst" or "Rolling Stock Software",
- (David Whynot) recently bought by TenLinks.com
- http://www.caddepot.com/
-
- They are specialized in AutoCAD related software and have a very
- good AutoLISP collection. Other professional AutoLISP shareware
- sites post their URL's to the newsgroup too.
-
- Other relevant sites are:
- TenLinks (www.tenlinks.com) and the UpFront (www.upfrontezine.com) ezine
- are the best CAD news services. Autodesk also started their portal site
- "Point A" at http://www.autodesk.com/pointa
-
- Some more sites with AutoLISP collections are:
-
- The CAD Users Webring
- http://nav.webring.org/hub?ring=caduser&list
- xarch AutoCAD Info & Tools (Reini Urban)
- http://xarch.tu-graz.ac.at/autocad/ (with search)
- CADalyst magazine code (compiled by "Hot Tip Harry" Art Liddle)
- http://www.cadonline.com/code/ (with search)
- Owen Wengerd
- http://www.manusoft.com/
- Terry Dotson
- http://www.dotsoft.com/
- + AcadX
- + http://www.acadx.com/
- + Paul Turvill
- + http://www.turvill.com/t2/
- Vladimir Nesterovsky
- | http://vnestr.tripod.com/
- Theo L.A. Groenenberg
- http://members.xoom.com/acadvice/autolisp.htm
- The CADshack (Jeff Foster)
- | http://www.cadshack.com/
- Lisp Factory (Jay Garnett)
- http://www.enteract.com/~jgarnett/
- Rakesh Rao - AutoCAD Tech Center
- http://www.4d-technologies.com/techcenter
-
- Older or broken links:
- AutoCAD Tech Journal code (Peter Sheerin)
- http://www.atj.com/ (old)
- CADENCE magazine code (Peter Sheerin)
- | http://www.cadence-mag.com/ (fixed)
- UCCB AutoCAD and AutoLISP page (Paul Standing)
- http://ucad1.uccb.ns.ca/acad/cad.htm (broken)
- McNeel's old lisp archive
- | ftp://ftp.mcneel.com/pub/lisp/ (fixed)
- Dr.Lisp Utilities (Alexander Medwedew)
- http://idt.net/~compvent/ (fixed)
- SimTel - Coast To Coast - Archive (fixed, really very old stuff)
- | http://www.simtel.net/pub/msdos/autocad.html
-
- | At http://support.autodesk.com/ (moved) were documents from the
- Autodesk Product Support answering technical questions. (Their FAQ's)
- + The ASA (Support Assistance, some kind of FAQ) was once at
- + http://www.autodesk.com/support/autocad/asa2000.htm, an improved but
- + slow tool is now at http://support.autodesk.com/KnowledgeBase.asp.
-
- [1.1] Are the comp.cad.autocad articles stored somewhere?
-
- There is no comp.cad.autocad archive or such a thing, but there
- are some search machines which store news articles. In
- particular:
-
- | * http://groups.google.com/ - The biggest news archive
- | formerly known as http://deja.com/usenet
- * http://www.altavista.com/
- http://www.altavista.com/cgi-bin/query?pg=aq&what=news
- * http://www.excite.com/
- http://www.excite.com/search.gw?collection=news
- * Phoaks - People Helping One Another Know Stuff - Automatic Links Extractor
- http://www.phoaks.com/phoaks2/newsgroups/comp/cad/autocad/index.html
-
- The Autodesk discussion forums have also a search feature at
- | http://discussion.autodesk.com
-
- Some specific older news postings are also stored at
- http://xarch.tu-graz.ac.at/autocad/news/contents.html
-
- [1.2] Autodesk's SDK
-
- Up to Release 12 a Software Development Kit was available directly
- at Autodesk. The SDK1-2 was shipped with the international R12 for
- free. It included a lot of ADS and AutoLISP source code and libraries.
-
- From R13 on Autodesk provides a special developers network, comparable
- to Microsoft's, the ADN. The CD's are comparable to the old SDK but
- are more targeted to ObjectARX developers.
- Contact your nearest Autodesk headquarter for becoming a member.
-
- Some LISPs are at http://xarch.tu-graz.ac.at/autocad/code/adesk/SDK2
-
- In the US, ADN membership costs $600.00 per year. The CDs don't include
- any SDK per se, but most of the stuff in the original SDKs is included
- in one form or another. (Owen)
-
- ------------------------------
-
- Subject: [2] What are the best books to learn AutoLISP?
-
- AutoLISP to Visual LISP
- Kevin Standiford, Autodesk Press, ISBN 0-7668-1517
- AutoLISP: Programming for Productivity,
- William Kramer, Autodesk Press, ISBN 0-8273-5832-6
- Essential AutoLISP,
- Roy Harkow, Springer-Verlag, ISBN 0-387-94571-7
- AutoLISP in Plain English, A Practical Guide for Non-Programmers,
- George O. Head, Ventana Press, ISBN 1-566-04140-6
- AutoLISP Reference Manual
- Autodesk Press.
- Up to R12 there was a separate AutoLISP Reference book. Then AutoLISP
- became a part of the Customization Guide for R13. From R14 on this
- guide is compiled as Winhelp.
- Maximizing AutoLISP
- Rusty Gesner, Tony and Mark Middlebrook, Tony Tanzillo.
- A new Maximizing AutoLISP R13/R14 will be published hopefully
- sooner or later. But the R12 book is still worth buying, though it's
- difficult to find. More at http://www.group-a.com/~rusty
-
- There is a lot more AutoLISP books around.
- Recommended general LISP books (not AutoLISP!) are:
- ANSI Common Lisp, (Common Lisp primer)
- Paul Graham, Prentice Hall, ISBN 0-13-370875-6
- Structure and Interpretation of Computer Programs, (high-level Scheme)
- H.Abelson, GJ. Sussman, J. Sussman, MIT Press, ISBN 0-262-01153-0
- "This undoubtedly one of the best general computer books ever written."
- LISP, 3rd Edition,
- Patrick Henry Winston and Berthold Klaus Paul Horn,
- Addison-Wesley Publishing Company, ISBN 0-201-08319-1
- Looking at LISP,
- Tony Hasemer, Addison-Wesley Publishing Company, ISBN 0-201-12080-1
-
-
- [2.1] Online AutoLISP documents, Winhelp [deleted]
-
- [2.2] AutoLISP Coding Style
-
- Most of the samples being published by magazines or at various
- websites are written badly making the AutoLISP learning process even
- harder for newbies. LISP is hard to read anyway because of it's
- briefness and countless parentheses. Everybody is enforced to
- write clear, readable code. Autodesk's samples are quite well written
- but sometimes overdone. :)
-
- Automatic pretty printers, or so called beautifiers (see
- [6.3]) automatically format the code according to some kind of standard.
-
- On the R12 CD-ROM in the SDK2 ACG.DOC or at
- http://xarch.tu-graz.ac.at/autocad/docs/acg.txt is an excellent
- Autodesk documentation about coding, commenting and intentation standards
- to keep lisp code readable.
-
- The most important points are:
- * Comment your code using ";;;" at row 1, ";;" inside the code
- (indented) and ";" for trailing comments (at row 39)
- * Follow the indenting standards as given by the pretty printers
- to be able to write better structured code, which is more readable.
- esp. for SETQ, DEFUN, IF, COND, PROGN
- * Try to avoid global variables. If you use them (for efficiency), to
- clarify, place asterics around them in uppercase, i.e: *GLOBAL*
- * Don't forget to localize your variables (behind "/" in the DEFUN
- parameter list). Only for debugging purposes you may want to
- undefine them temporarly.
- * Name protection: Since AutoLISP provides no protected name space,
- it's easy to overwrite even system functions. Use unique
- short prefixes at least when you publish or give away your code.
- I use UR- for functions and UR: for variables. The ADGE and Autodesk
- forces even 4 letter prefixes. Then your names are safe
- from being overwritten by other kamikaze functions.
- * Always use the leading underscore with any string (commands and
- options) given to COMMAND and OSNAP. There are even enough
- commercial programs which do not work on international versions.
- (command "_PEDIT" ss "_J") is better than (command "PEDIT" ss "J")
- * Don't do too much SETQ's: LISP was originally a functional language,
- without any variables. There are enough constructs which work
- efficiently with lists without the need of storing values
- intermediatly in symbols. (see code samples [22]...)
- But for readability and debugging purposes you should always set
- symbols.
- * An old LISP rule is: Any good function is not longer than 6 lines :)
- (LISP is the second oldest computer language, invented by John
- McCarthy at the MIT in 1958)
- * Prefer CONS over APPEND: three CONS and one REVERSE is better than
- one APPEND. For tricks with APPEND (omitting NIL) see esp. Serge's
- samples: i.e. REMOVE at [11] or the style comparison at [23.1])
- * Try to use English symbols and comments
- * Don't use T, MIN, MAX or LAST as symbols! These are system functions!
-
- ------------------------------
-
- Subject: [3] How do I debug AutoLISP programs?
-
- [3.1] There are some native AutoLISP debuggers:
-
- * Visual Lisp by Autodesk and Vital Lisp Professional support
- it in the IDE (the best),
- * ACOMP for R10 had one, (free)
- you can still use it with R12 DOS, but then you've got only the R10
- LISP functions, i.e. no WCMATCH function,
- * Ld, AutoLISP Debugger for R14, R13c4 and R12/DOS from CZ,
- (free) at http://www.cadstudio.cz/ftp.htm
-
- See "[5] AutoLISP compilers"
-
- [3.2] Modular style, TRACE
-
- The best support you can have for debugging is write your
- code in a well designed, modular style, pulling out distinct
- tasks into separate functions and then liberally using
- nested function calls. This will allow you to use the
- TRACE function as needed to locate any errors.
-
- [3.3] You may include BREAK functions and debug-print into your source
- code.
-
- Examples:
-
- ;;; Debugging functions
- (defun break (s)
- (if *BREAK*
- (progn
- (princ "BREAK>> (stop with <Enter>)\nBREAK>> ")(princ s)
- (while (/= (setq s (getstring "\nBREAK>> ")) "")
- (print (eval (read s)))))))
- (defun dbg-print (s) ;accepts atoms and lists
- (if *DEBUG*
- (if (listp s)
- (MAPCAR 'print s)
- (print s))))
- (defun C:DEBUG () (setq *DEBUG* (not *DEBUG*))) ;switch it on and off
- (defun C:BREAK () (setq *BREAK* (not *BREAK*)))
- (defun CONT () (setq *BREAK* nil)) ;cont. without any interruption
-
- For a usage example see:
- http://xarch.tu-graz.ac.at/autocad/news/break_ex.lsp
-
- ------------------------------
-
- Subject: [4] How can I protect my AutoLISP programs?
-
- "You really have to protect it? If you just want to share routines
- with friends, why not give them the code? Working with others
- can be a great way to get new ideas and lead to a better
- application. Some of the best utilities were improved by my friends
- or I have improved some of my friends utilities." (Dennis)
-
- [4.1] Kelvinate
- with KELV.EXE (on the R12 CD-ROM or at the AutoLISP sites "[1]").
- Free. De-Kelvinate LISP's with any pretty printer, see [6.3].
- Symbol names (functions and variables) will stay garbled and comments
- are lost.
- [4.2] Protect
- with PROTECT.EXE (on the R12 CD-ROM or at the AutoLISP sites "[1]")
- Note that unprotectors exist. Free.
- [4.3] Kelvinate and Protect
- First kelvinate, to make it unreadable, then protect. Free.
- [4.4] Convert
- Shareware LISP En-/Decryptor by Maciej Lukasiewicz, Sweden.
- With Convert encrypted "Protected Lisps" cannot be decrypted by other
- programs, but by Convert it can.
- [4.5] ACOMP
- AutoLISP compiler ACOMP.EXE, on the R12 international release or
- at the AutoLISP sites. Free. More docs about ACOMP are at
- http://xarch.tu-graz.ac.at/autocad/bi4/ See also [5.1]
- [4.6] Vital LISP Professional
- Formerly at http://www.basissoftware.com/vill.htm [broken]
- Say "ViLL". Outdated. See also [5.2]
- [4.7] Lisp2C
- LISP to C converter, for R12/R13/R14 Dos/Win (Watcom, Metaware,
- MSVC Libs). You need to own such a C/C++ compiler. Quite expensive.
- http://www.basic.si
- [4.8] Visual Lisp by Autodesk
- say "VLISP". see [5.3]
-
-
- FAS Security:
- There was recently a lengthy discussion about FAS security at both
- newsgroups. Apparently FAS can be decompiled to readable source code,
- but this tool is not available on the net yet. Rumors say that MNC
- files can also be decompiled for years now but this doesn't exist the
- net either.
- Linked and dropped FAS/VLX (compiled with Optimized/Internal) is
- similar to Kelvination.
- Symbol names, strings and numbers are more insecure than algorithms.
- Summary:
- Serious encryption is only done with Vital LISP and its successors.
- Kelvinating makes LISP files unreadable and load faster.
- Protected lisp files can be easily decrypted. With
- Convert -e$GUARD encrypted LISPs can be unprotected only with Convert.
-
- ------------------------------
-
- Subject: [5] AutoLISP compilers
-
- There are three AutoLISP compilers, better ones could maybe used in the
- future. Some Lisp and Scheme platforms already do or will support ActiveX
- or just a simple FFI.
-
- [5.1] ACOMP
- ACOMP was supported up to R12 for the international releases only.
- It is free, and doesn't work with R13 nor with domestic R12/Win.
- It produces .BI4 files and needs special ACADL.EXP supplied as
- ACADLC.EXP See http://xarch.tu-graz.ac.at/autocad/bi4/
- [5.2] Vital LISP Professional
- by Basis Software Inc. USA.
- Basis doesn't continue developing Vital Lisp anymore.
- License-free runtime modules for R12/R13/R14 DOS/Windows/NT
- See http://www.basissoftware.com/vill.htm
- Some dealers still have it on stock. The latest version was 3.2. The
- R14 version (ViLL 3.x) includes ActiveX (like VB) and reactor
- support. See also [6.1] and [4.6]
- [5.3] Visual Lisp by Autodesk
- VLISP 4 (for R14), the successor of Vital Lisp, is basically the same
- as ViLL 3.2, only the GUI, some function names and the docs changed:
- vill- => vlisp-, the vlx- => vl- prefixes.
- Some vlax- funcs have more hyphens.
- With AutoCAD 2000 VLISP replaced the old AutoLISP engine. See [0.1]
- VLX files are packaged FAS files with optional DCL resources, used
- by R14/R15.
- AutoCAD 2000 FAS/VLX are incompatible with previous releases
- (FAS2 -> FAS4) because of added language features (seperate namespaces)
- [5.4] Better ones: Common Lisp and Scheme
- Native ARX exists for Corman Common Lisp (a simple console),
- COM support for Allegro Common Lisp 5, Lisp Works for Windows and in
- the future for GambitC.
- Via a FFI ("Foreign Function Interface") almost every lisp or scheme
- can communicate with AutoCAD.
- See http://xarch.tu-graz.ac.at/autocad/lisp/ffis.html
- Little work is done with Corman Lisp and ACL5, one commercial product
- uses ACL5 ("Design++" by Design Power http://www.dp.com/)
- See http://xarch.tu-graz.ac.at/autocad/bi4/ for more.
-
- Summary:
- AutoLISP compilers are bytecode compilers needing a runtime system.
- AutoCAD 2000 uses VLISP now, so the runtime system is included.
- You cannot create standalone programs, though ViLL/Vlisp (<=R14)
- creates a stand-alone ARX. The symbols are encrypted.
-
- ------------------------------
-
- Subject: [6] AutoLISP editors and other tools
-
- [6.1] AutoLISP editors
- Visual Lisp by Autodesk
- see [5.3]. The best and most recommended tool. With AutoCAD 2000 it
- is included for free.
- Emacs for NT
- Huge editor and quite hard to learn but it's written and
- customizable in LISP. Free, for all platforms. Comes in two flavors,
- www.xemacs.org or the GNU emacs for NT.
- Check out http://xarch.tu-graz.ac.at/autocad/lsp_tools/ntemacs.html
- Vital LISP
- outdated by Visual Lisp. Not available anymore
- LispLink 2000
- Commercial AutoLISP Editor with Syntax Highlight, Parenthesis
- Checking, Project Manager, Dialog Preview, and Support for Visual
- LISP Functions and FAS Compilation. http://www.caelink.com/
- CodeMagic
- Shareware text editor with AutoLISP syntax highlighting.
-
- Old stuff:
- LispPad
- AutoLISP Editor by Tony Tanzillo.
- Visual LISP by WSSW
- Old small Windows LISP Editor, Version 1.0 was even free. See [1]
- WCEDIT 2.02
- Old ADS editor for DOS R12, can evaluate lisp code from within the
- editor, free. See [1]
- CODEKEY
- Old commercial DOS IDE, internal pretty printer, protect, unprotect,
- kelvinator. Still available?
- ALLY 3.0 and CADET
- Shareware LISP Analyzer and Editor. See [6.2]
- pred
- free, small dos editor which provides parenthesis highlighting.
- At ftp://xarch.tu-graz.ac.at/pub/autocad/lsp_tools/pred.zip
- A similar editor is ADE.
- LSPEDIT from xlisp-stat
- A simple free Windows Lisp editor that supports parenthesis matching and
- code indentation.
- Check out http://www.stat.umn.edu/~luke/xls/xlsinfo/xlsinfo.html
-
- General customizable programming editors like MultiEdit Pro,
- WinEdit, E!, PFE, TextPad, UltraEdit or PFE are widely used also.
- They usually don't provide Lisp syntax checking or pretty printing,
- but (some even regular expression) multi-file search/replace and
- customizable syntax highlighting.
-
- There are others not that good (ADE) nor I don't have a description
- yet.
-
- [6.2] Analyzers, Packagers and Parenthesis checkers
- Parenthesis checkers should not be used anymore. Editors should do the
- job. Analyzers generate a function cross-reference, the calling and the
- reverse callers tree. Packagers are used to generate libraries from
- various source files, copying all the needed functions.
- There's currently no code-walker which can internationalize command
- strings, but with R15 came a lisp analyzer (LCA).
-
- VLISP's [5.3] compiler analyses (compile with full messages) and
- checks parens <Ctrl-Alt-C>
- Reini's AutoLISP Packager
- http://xarch.tu-graz.ac.at/autocad/lsp_tools/#Packager
- Browsable function cross-referencer, reverse calling tree, creates a
- library from source files. ("Packaging" or "Function Shaker")
- PEI Findvars
- Similar to the Packager above, but not only functions, additionally
- detects symbols to be localized. http://www.perceptual-eng.com
- I personally use this.
- RapidLisp v1.0c [new]
- Shareware Lisp analyser fⁿr R14. http://www.cps.de/cad/rapidlisp/
- AVC - AutoLISP Variable Collector [new]
- Freeware, finds all variables to be declared per function.
- http://users.actcom.co.il/sysoft/vc.htm
- LCA - Autodesk's AutoLISP Compatibility Analyzer
- On the Migration CD. Details AutoCAD 2000 compatibility issues found
- in specified AutoLISP (LSP) or Menu LISP (MNL) files. (simple "Code Walker")
-
- ALLY30.ZIP (old)
- Shareware LISP analyser. Checks syntax and prints statistics, function
- dependence tree and used symbols, but no packaging. At [1]
- lck21b.zip (old)
- LCK LISP Checker 2.1b (graphical)
- paran.zip (old)
- Simple
- PARNCH.ZIP (old)
- Simple
- There are also some AutoLISP programs which count parenthesis.
-
- [6.3] Pretty Printers
- External:
- FMT202S.ZIP
- LISP, DCL and FRM source code formatter. Not checked yet.
- LB.EXE
- Autodesk's source code beautifier.
- In the SDK2 or at [1]. Has problems with longer strings,
- and new-style in-line comments.
- PPRINT.LSP
- In the SDK2, see [1.2], or at [1]
- Internal:
- Visual Lisp, Vital LISP, Emacs and Codekey provide internal
- beautifiers as I'm aware of it.
-
- ------------------------------
-
- Subject: [7] AutoLISP problems and bugs
-
- For AutoCAD 2000 and unexperienced VLISP users see [0.1].
- There are almost no known serious AutoLISP bugs. The language
- interpreter itself (ACADL.EXE/.EXP, VLISP) works undoubtedly well.
- Some restrictions are based on the AutoCAD, ActiveX or the Proteus
- (DCL) engine. Some support LISP programs (i.e. DDMODIFY.LSP) are
- faulty sometimes.
- For Visual Lisp see the README.txt which lists all known bugs and
- limitations. Crashes with reactors are ACAD bugs.
-
- Two inofficial buglists are at:
- http://www.cadonline.com/exclusive/bugs/bugwatchlist.htm (the big one)
- http://www.dotsoft.com/buglist.htm (a private and short one)
-
- * LDATA by Tom Berger (VLISP for R14 and A2000)
- In short: Don't use LDATA at all. It may destroy DXF and DWG's
- in A2000. It is also VERY hard to get rid of them.
-
- * List Arguments with DOTTED PAIRS Passed from AutoLISP to
- Visual LISP or back may loose the outer parens.
- See the Visual Lisp README (undocumented in Vital Lisp)
-
- * SINGLE ATOM LISTS returned incorrectly from EXTERNAL APPS
- Visual LISP can not distinguish between a LIST of a single
- atom (element), and a single atom returned from an external
- ObjectARX or ADS application.
-
- * ENTGET used with LWPOLYLINE, HATCH (R14 only)
- The Z coordinate (caddr (getval 10 ele)) is a random number and
- often causes a floating point exception because it may too low or
- too high. Workaround: see part 2, Subject [23.1]
-
- * ENTMAKE VERTEX by Terry Dotson (R14 only)
- A problem can occur during the process of using (entmake) to create
- polylines, you must assign the layer to each of the VERTEX
- definitions (which Autodesk has told us), but you must also assign
- the layer to the ending SEQEND. Absence of this will cause the SEQEND
- to end up on the current layer, which can be later frozen. Attempts to
- move this piece of geometry will then cause a EREGEN error and crash
- in R14 (only).
-
- * ACAD_STRLSORT: Strange sort order in Windows.
- The chars in Windows are not sorted on its ASCII representation!
-
- Windows: (acad_strlsort '("-1" "+1")) -> ("-1" "+1"),
- DOS: (acad_strlsort '("-1" "+1")) -> ("+1" "-1")
- Both: (mapcar 'ascii ("-" "+")) -> (45 43)
- More at http://xarch.tu-graz.ac.at/autocad/docs/strlsort-bug.html
-
- * AI_PROPCHK
- (ai_propchk) was renamed to (C:AI_PROP) in the R13c3 update
- patch. "The AutoLISP function ai_propchk has been changed to c:ai_prop
- so that it behaves similarly to other commands. This allows pressing
- return to bring back DDMODIFY if selected from the toolbar."
-
- * Faulty action callbacks in R13 DCL code crash AutoCAD
- There is a bug in R13 where AutoCAD crashes with a Fatal Error if
- an error occurs in AutoLISP code during an action callback from a
- scroll bar in a dialog box. For instance, if you try to evaluate a
- null function during the callback, AutoCAD crashes instantly.
- Technically, this isn't a bug in the AutoLISP interpreter, but we
- would still call it an AutoLISP bug.
-
- * You cannot rely on bitvalue 64 in flag 70 in symbol tables anymore
- since R13, but in all previous releases. Inserted blocks may have
- 64 not set.
-
- What else? See the unofficial AutoCAD buglist compiled by Steve
- Johnson for more faulty AutoLISP programs and behaviours, at
- http://www.cadonline.com/exclusive/bugs/bugwatchlist.htm
-
- * Protected LISP Files
- In pre-c4a R13 protected LISP files didn't stay protected in
- memory. In our opinion, this problem needs to be made known to all, so
- developers don't inadvertently assume their protected code is
- safe from prying eyes. This FAQ topic caused a major problem in
- moderated CompuServe's AutoCAD Forum.
-
- * Limited number of open selection sets
- They are intermediatly stored in temporary files. Get rid of not
- needed selection sets with setting the symbols to nil and run (gc),
- the garbage collector, which actually closes those files then.
- The maximal number depends on the operating system, i.e. in DOS
- of the FILES= value in CONFIG.SYS. R13 improved the number.
-
- * Numbers: range, accuracy, numerical precision
- Integer numbers are internal long fixnums (signed, 32-bit), but the
- communication from AutoLISP to AutoCAD accepts only 16-bit short
- fixnums, in the range -32768 .. +32767, because AutoCAD needs only
- short fixnums.
- Floating point numbers are doubles (64-bit IEEE). All internal
- AutoLISP and AutoCAD numerical calculations work with this double
- format, which should be sufficient. At least the first 14 decimal
- places are exact.
- A common problem is the confusion betwen the actual number (exact)
- and the rounded string representation. The number which is shown on
- the command-line is always the rounded string which takes care of
- LUPREC and DIMZIN.
- However with geometric comparisons there often occur round off errors,
- so that it's wise to compare points with a small fuzz factor
- [1e-12..1e-6].
- (equal pt1 pt2 1e-6) ; 0.000001 rounding error tolerance
- instead of (equal pt1 pt2), esp. with angles.
- See also http://www.autodesk.com/support/techdocs/td30/td301207.htm
-
- VB: It was also reported lately, that with certain automation
- controllers loaded, numerical accuracy and locale issues (`,┤ vs `.┤)
- had undesirable sideeffects. A solution and explanation of this
- problem is pending. (Mostly in `,┤ as decimal delimiter countries
- such as Germany)
-
- * ACOMP's (EQ) strictness
- With [5.1] ACOMP's compiled code you have to take care that the
- (EQ) behaviour in BI4's is much stricter than in plain AutoLISP. In
- AutoLISP (eq "1" "1") is T where in ACOMP's compiled code it's nil.
-
- The following are not real bugs, that make AutoLISP crash or return
- false results. They are just bad language implementations.
-
- * AND and OR should return the value of the not-NIL argument
- instead of T. See http://xarch.tu-graz.ac.at/autocad/docs/and-bug.html
- * MAX and MIN should handle string types too, because < and >
- accept and process strings types too.
- * see ACAD_STRLSORT above.
- * for stack overflow errors see [14]
-
- ------------------------------
-
- Subject: [8] Sorting with AutoLISP
-
- In short: use VL-SORT (generic) or ACAD_STRLSORT (strings only),
- but beware: VL-SORT removes duplicate entries (which are EQ)!
-
- I've set up a AutoLISP sort overview at
- http://xarch.tu-graz.ac.at/autocad/lisp/#sort
- In LISP the mostly used sort method is merge sort (also used in
- (str-sort) in AutoDesk's TABLES.LSP sample) because that's a natural
- method for linked lists. Normally (e.g. in C) you use heap sort (for
- any data) or qsort (for random data) and insertion sort for the small
- lists (< 7) or sublists within the algorithm.
-
- There is a LISP code for shell-sort, bubble-sort, insertion-sort,
- quick-sort available for any data, lists of lists and indeces to
- lists. In LISP you can pass the predicate function to sort which is
- evaluated at run-time (here called 'method'). That's why you need
- only one sort function for multiple data types (i.e. numbers,
- points on x or y, strings, ...)
-
- (sort data method) ;method: less-than-predicate
- ;default for numbers: '<
-
- Some sample timings from
- http://xarch.tu-graz.ac.at/autocad/lisp/sort/ur_sort.lsp
- sorting 100 elements:
- bubble sort : 13.639008 sec/ 30.08%
- insertion sort: 13.368042 sec/ 29.48% (fast for sorted lists)
- shell sort : 13.478973 sec/ 29.73% (poor implementation)
- merge sort : 2.232971 sec/ 4.92%
- quick sort : 2.433960 sec/ 5.37%
- vl-sort : 0.099976 sec/ 0.22% (Visual/Vital LISP internal)
- acad_strlsort : 0.089996 sec/ 0.20% (AutoLISP internal, strings)
-
- ------------------------------
-
- Subject: [9] Recursion
-
- This is not an often asked question but a very interesting one,
- because LISP itself is defined recursively and it's often the
- easiest way to articulate hard problems.
-
- There some fine documents about recursion at
- http://xarch.tu-graz.ac.at/autocad/lisp/ especially the
- http://xarch.tu-graz.ac.at/autocad/lisp/recursive.html tutorial by
- Dennis Shinn.
-
- It explains in great detail:
-
- (defun fact (n)
- (cond
- ((zerop n) 1)
- (T (* n (fact (1- n))))))
-
- Note: There's also a self-modifying example of this function
- explained at http://xarch.tu-graz.ac.at/autocad/lisp/self-mod.lsp
-
- ------------------------------
-
- Subject: [10] Iteration with MAPCAR,...
-
- Same as with recursion this is not a often asked question, but it's
- quite hard to understand too.
- Iterative statements in AutoLISP are: WHILE, REPEAT, FOREACH and
- MAPCAR. We use them widely in this FAQ code because they allow
- brief code.
-
- There's a short course in LAMBDA, QUOTE, MAPCAR... by Vladimir
- Nesterowsky:
-
- >> "There are 14 paths and 12 pigs.
- >> How can there be 24 ducks?"
- >> Is there a lisp command that will allow me to pick these
- >> lines of text, and recognize the number(s) in each line,
- >> in order to, say, raise each number by two?
- >> Leaving the sentence structure, etc, intact?
- This is one way. (I am sure there are many other ways)
-
- (defun mult2 (strng) ; by Vladimir Nesterowsky
- (strlgather
- (mapcar
- '(lambda (s / n)
- (if (zerop (setq n (atof s)))
- s
- (rtos (* n 2))))
- (strlparse strng " ")) ; parse by spaces
- " ")) ; gather back with spaces
-
- is explained at http://members.tripod.com/~vnestr/mapcar.txt
-
- ;;; flip rows and columns in a matrix
- (defun transpose(l) ; by Doug Wilson
- (apply 'mapcar (cons 'list l)))
-
- is explained at http://xarch.tu-graz.ac.at/autocad/lisp/transpose.002.html
-
- ------------------------------
-
- Subject: [11] S::STARTUP, My LISPs aren't loaded at startup anymore
-
- LISP files can be loaded at the startup using LOAD in ACAD.LSP.
- Some LISPs, required with a menu to work, should be loaded from
- the corresponding <menu>.MNL file. The <menu>.MNL file - if different -
- should load ACAD.MNL
-
- LISP functions calling commands at the startup should be defined in
- S::STARTUP of ACAD.LSP. This function is called at the startup
- after the initialization automatically. Otherwise you'll get the
- "Command list interruption (6 . 2)" errors.
- Note: (command) may be safely called from within MNL files.
- (S::STARTUP) is mainly used to check for partial menus now.
-
- If the file name was provided without an extension the LOAD function
- assumes .LSP. If - without a path prefix, the usual AutoCAD library path
- is used, which is
- 1) The current directory
- 2) The directory containing the current drawing file
- 3) The directories defined in the ACAD environment variable
- (setup in the Preferences box, SUPPORT paths)
- 4) The acad.exe directory
- If your program isn't loaded anymore automatically, check your AutoCAD
- library path settings.
-
- With ACADLC (of ACOMP) and the domestic release of AutoCAD R12 ACAD.LSP
- is not loaded automatically. Therefore you must append (load "ACAD" -1)
- to your ACAD.MNL.
-
- Sample ACAD.LSP:
- ;;;ACAD.LSP
- ;;; Fred the Beaver, 12/12/94
- (load "init" -1) ; this loads some tools of mine
- (defun S::STARTUP ()
- (load "new-end" -1) ; this redefines the END command
- )
-
- The -1 argument provides LOAD from interrupting the startup process, if
- any LOAD failure (causing an AutoLISP error). If a failure at the
- load-time occurs, -1 is returned, but the evaluation does not stop.
- -1 can be any expression as well.
-
- Sample code to enhance S::STARTUP in your code. With Visual LISP
- compiled code this will not work, it must be defined with DEFUN-Q
- instead. Functions are generally no lists anymore! Better than to
- use DEFUN-Q for S::STARTUP is to check for known hooks, a list of
- user-defined functions which are inserted and evaluated at run-time.
-
- (defun MY::STARTUP () ;your startup code goes here
- ;..
- (princ))
-
- (setq S::STARTUP
- (if (and S::STARTUP (listp S::STARTUP)) ;already defined in
- ; ACAD.LSP or elsewhere
- (append S::STARTUP (cdr MY::STARTUP)) ;append your code
- MY:STARTUP)) ;just your code
-
- or a simple one:
-
- (if (and S::STARTUP (listp S::STARTUP)) ;usually called consp
- (setq S::STARTUP (append S::STARTUP (list func '(princ))))
- (setq S::STARTUP (list nil func '(princ))))
-
- + Vladimir Nesterovsky:
- The main difference now in A2K+ versions is that functions defined
- with DEFUN are now a new datatype, USUBRs, and not lists as before.
- But when the function is defined with DEFUN-Q, it is a list still,
- like in previous versions.
-
- Here's the utility function to use that works in both cases:
-
- (defun plug-into-startup (funcname) ;by VladimirNesterovsky
- "to be called with quoted function name"
- (eval (list
- 'defun 's::startup ()
- (if s::startup (list (list 'quote s::startup)))
- (list funcname))))
-
- So if you have all your startup code packed into one routine
-
- (defun my-startup ()
- (alert "My Startup"))
-
- You make it work with the call
-
- (plug-into-startup 'my-startup)
-
- Inside your code that is executed on startup, e.g. acaddoc.lsp
- or whatever.
-
- See also "[12] How to Autoload my programs?"
-
- ------------------------------
-
- Subject: [12] How to Autoload my programs?
-
- How to load my programs automatically? You can either load your
- whole program at startup (see "[11] My LISP doesn't
- load at startup anymore") which needs more time and memory at
- startup time, or you can define them via the autoloading mechanism.
- From R14 on ARX programs use a new autoloading scheme (called
- "demand loading") with some registry settings and not from ACADRxx.LSP
- anymore.
-
- Look at the end of your ACADRxx.LSP how AutoCAD autoloads its programs.
-
- ;;;===== AutoLoad LISP Applications =====
- ...
- (autoload "dline" '("dline" "dl"))
- ...
-
- This defines the commands DLINE and DL in the list to be loaded
- from the file DLINE.LSP when the user first calls the command DLINE
- or DL. Before that the function is simply defined like this one:
-
- (defun C:DL () (load "DLINE")(C:DL))
-
- In fact the definition is more complicated because of error
- handling.
- After the first call the function is overwritten with the
- definition in the program.
-
- Advantages of autoloading:
- * Startup is faster, because you dont have to load all your lisp
- files. You just define the simple *wrapper* definition as above.
- This is done by the (autoload) function.
- * You need less memory.
-
- Disadvantages:
- * On errors in your program you will fall into a never ending
- loop, which will only stop after a stack overflow or Ctrl-C
- Note: with ACOMP compiled code even Ctrl-C is impossible.
- Insert then a call to an uncompiled (princ) somewhere.
- * You have to define and maintain all command names from your
- program in the autoloader definition. Changes to the lisp
- filename or the command name will cause the above error.
-
- Where to put your (autoload) definitions?
-
- * Not to ACADR13.LSP.
- * Well we recommend putting it to an initialization file of yours
- and not to ACAD.LSP because this is often changed by different
- applications and ACAD.LSP should be kept rather small.
- I.e. put it to a AUTOLOAD.LSP or INIT.LSP, which is loaded from
- ACAD.LSP. See "[11] My LISP doesn't load at startup anymore"
- * It should be mentioned that users should *not* modify ACADRxx.LSP.
- Since ACAD.LSP is not overwritten during upgrades, it is guaranteed
- to remain safe. In addition (as we saw with the R13c4a patch) if the
- ACADR13.LSP file has been modified, then the patch process may
- refuse to update it, thus resulting in program malfunctions.
-
- ------------------------------
-
- Subject: [13] How can I pass a variable number of arguments to a lisp
- function?
-
- With plain AutoLISP this is not possible.
- You can either pass all your arguments in a list like this:
-
- ;;; print a variable number of arguments (of any type)
- (defun my-princ (x)
- ;; simple version, for better stuff look at the SDK2: PRINTF.LLB
- (if (listp x)
- (mapcar 'princ x)
- (princ x)))
-
- Or you have to define the function in ADS and export it to
- AutoLISP.
- Then you are free to write:
- (ads-print "Hello " "World " 1 2 3)
- or even
- (ads-printf "Hello %s %i %i" "World" 2 3)
-
- Look at Reini Urban's and Vladimir Nesterovsky's ADS samples at
- http://xarch.tu-graz.ac.at/autocad/ads for implementations of the
- above examples.
-
- Official wishes were pointed to Autodesk regarding &optional as
- AutoLISP language enhancement, but it was not implemented in R14.
-
- ------------------------------
- Subject: [14] How can I avoid stack overflows?
-
- In old AutoLISP the stack size was hardcoded. It couldn't be extended,
- but its size should be sufficient for most purposes. In the Visual
- Lisp IDE the stack overflow is simulated at 984 recursions, on the
- A2000 commandline or loaded programs outside the IDE there's no
- overflow anymore. This is dangerous on recursion errors of yours,
- see [9]. Most stack overflow errors occur on a program error of
- yours, preventing the system from falling into an endless loop, or
- from using recursive functions on large lists. Therefore you are
- limited to quite short lists with recursive functions and old versions.
-
- You cannot decrease your used stack size with using less local
- parameters in your recursive function! However do not use APPLY, EVAL
- or MAPCAR to call your function recursively, because they eat up the
- stack. Using tail recursion doesn't help either.
- You have to convert your recursive function to a iterative one.
- (There is a mathematical theorem that says, that every recursive
- function can be converted to a iterative one, tail-recursive ones
- even automatically.) Iterative versions may use stack-like functions
- like (push) and (pop), but those versions store the stack on the heap
- (autolisp node space), which size is only limited by your amount of
- virtual memory available.
-
- You can test the stack overflow with this simple function:
-
- ;;; create a list of n numbers (zero based)
- (defun intlst (l n)
- (cond ((zerop n) l)
- (T (intlst (cons (1- n) l) (1- n)))))
- and try:
- (setq n 100)(while (intlst nil (setq n (+ 10 n)))(print n))
-
- In AutoLISP of R12/DOS you reach the stack limit with
- (intlst nil 138), in A13/Win with (intlst nil 240), in ACOMP bi4's
- with (intlst nil 1240), in Vital LISP/Visual Lisp IDE with
- (intlst nil 984). With R10c10, the first dos extended lisp version,
- you could enhance the lisp stack size with the environment variable
- LISPSTACK. ACOMP for R10 had COMPSTACK.
- With Vital LISP or Visual LISP RTS or A2000 (outside the IDE) the
- stack size is unlimited.
-
- Conversion to an iterative version yields the required results:
-
- (defun intlst (n / l)
- (repeat n
- (setq l (cons (setq n (1- n)) l)))) ;this looks ugly but it works
-
- ------------------------------
-
- Subject: [15] (command "ROTATE3D") does not work! Why?
-
- Some commands are no internal AutoCAD commands, they are simple
- AutoLISP programs beginning with C: even if they are defined in ADS
- programs. Only native Rx applications (or now with vlax-add-cmd)
- export true commands.
-
- A list of all these commands are found in ACADRxx.LSP in the
- AUTOLOAD section. (see also "[12]")
- All these commands have to be called with (C:ROTATE3D) instead of
- (command "ROTATE3D").
- However ADS functions may take optional arguments. See the
- customization manual for more.
- i.e. (c:rotate3d ss p1 p2 angle) is also valid, even (rotate3d ...)
-
- ------------------------------
-
- Subject: [16] LISP programs operating over multiple drawings
-
- "I am having trouble getting a lisp file that will open a drawing and
- continue running. Once the new drawing is opened the LISP file ceases
- to exist in the Autocads memory. It has to be reloaded to recognise
- the commands."
-
- LISP memory is reloaded on a per drawing basis. There are some
- ways to execute a LISP on multiple drawings:
- 1) via a script that executes on multiple files.
- MYSCRIPT.SCR:
- (load "mylisp")
- _QSAVE _OPEN !nextdwg
- (load "mylisp")
- _QSAVE _OPEN !nextdwg
- ...
- 2) External 3rd party software such as RunLisp, ScriptPro or DDSCRIPT automate
- step 1.
- 3) R14 has a new feature, called 'Persistent LISP'.
- Set it in Preferences-Compatibility-Persistent LISP
- 4) Vital LISP has a built-in variable to act as Persistent LISP:
- (setq *VILL-NEW-FULL-INIT* nil) ;keep symbols between sessions
- 5) same with Visual LISP: (setq *VLISP-NEW-FULL-INIT* nil)
-
- ------------------------------
-
- Subject: [17] How to export Visual Lisp functions to AutoLISP/AutoCAD?
-
- C: functions are automatically exported to AutoLISP. Plain vlisp/vill
- lisp functions must be exported either with (vl-acad-defun funcname) or
- their symbols may be exported with a special compiler pragma, defined
- either in the LSP file or in the GLD (global declarations) file. Better
- use special prefixes for such functions.
-
- .GLD:
- (AUTOEXPORT-to-ACAD-PREFIX
- ;| name prefixes for functions to be autoexported to AutoCAD: (strings) |;
- "myx-*"
- )
- or one by one
- .LSP:
- (pragma '((export-to-acad myx-func1 myx-func2)))
-
- Note: There may exist known bugs in vlisp and vill with lists of atomic
- symbols and dotted pair lists in such functions arguments and return
- values. See [7].
-
- Functions exported by external apps which are used in your application
- must be defined via XDF.
-
- Symbols (variables) whose values are updated in Visual Lisp and which
- values are also used in AutoLISP or AutoCAD (the menu e.g.), first may
- be marked for the compiler to be external with:
- (pragma '((not-localize myx:symbol)))
- but the value must be exported with
- (vlisp-export-symbol 'myx:symbol)
- each time the value is changed in Visual Lisp and control is returned
- to AutoCAD to be able to get the latest value in AutoLISP or in AutoCAD
- with !myx:symbol
-
- You may forget this whole chapter with AutoCAD 2000, however you might
- need to export your function from the protected namespace then with
- VL-DOC-SET.
- See also http://www.autodesk.com/support/techdocs/td17/td175363.htm
-
- ------------------------------
-
- Subject: [A] Disclaimer, Notes from the authors
-
- If you think of questions that are appropriate for this FAQ, or
- would like to improve an answer, please send email to Reini Urban
- <rurban@x-ray.at> but don't expect an reply.
-
- This AutoLISP FAQ is Copyright (c) 1996,97,98,99,2000 by Reini Urban.
-
- This FAQ may be freely redistributed in its entirety without
- modification provided that this copyright notice is not removed. It
- may not be sold for profit or incorporated in commercial documents
- (e.g. published for sale on CD-ROM, floppy disks, books, magazines,
- or other print form) without the prior written permission of the
- copyright holder. Permission is expressly granted for this document
- to be made available for file transfer from installations offering
- unrestricted anonymous file transfer on the Internet and esp. to be
- included into the official AutoCAD FAQ.
-
- The sample code is, if not otherwise stated, (c) 1996,97
- by Reini Urban and may be freely used, but not sold.
- The basic functions in [20] are, if not otherwise stated, (c) 1991-97
- by Reini Urban and may/should be freely used.
-
- If this FAQ is reproduced in offline media (e.g., CD-ROM, print
- form, etc.), a complimentary copy should be sent to Reini Urban,
- X-RAY, Nibelungeng. 3, 8010 Graz, Austria
-
- This article, the contents and the sample code, is provided AS IS
- without any expressed or implied warranty.
-
- [A.1] FAQ Locations
-
- Homepage of the HTML'ified version:
- http://xarch.tu-graz.ac.at/autocad/news/faq/autolisp.html
- + Annotated AcadWiki version:
- + http://xarch.tu-graz.ac.at/acadwiki/AutoLispFaq
- The posted ascii versions (and always latest versions) are at
- http://xarch.tu-graz.ac.at/autocad/news/faq/autolisp.1 and
- http://xarch.tu-graz.ac.at/autocad/news/faq/autolisp.2
- The Winhelp version (zipped with faq and code) is at
- ftp://xarch.tu-graz.ac.at/pub/autocad/news/faq/autolisp.zip
- The FAQ usenet archive is at
- http://www.faqs.org/faqs/CAD/autolisp-faq/ resp.
- ftp://rtfm.mit.edu/pub/usenet-by-hierarchy/comp/cad/autocad/
- The LISP code from this FAQ is at
- ftp://xarch.tu-graz.ac.at/pub/autocad/news/faq/FAQ-CODE.LSP
- See also the cca glossary for common abbrevations at
- http://xarch.tu-graz.ac.at/autocad/news/faq/glossary.html
- Submissions for a new AutoCAD FAQ are stored at
- http://xarch.tu-graz.ac.at/autocad/news/faq/new-acad
- A french translation of the FAQ was made by Roger Rosec
- http://www.newz.net/acadplus/page5101.htm
- A japanese translation of the FAQ was made by MASAMI Chikahiro
- http://www.page.sannet.ne.jp/chestnutsburr/autolisp-j.html
- A russian translation by Igor Orellana at
- http://www.cad.dp.ua/stats/alfaq_ru.htm
- A german translation by myself at
- http://xarch.tu-graz.ac.at/autocad/news/faq/autolisp.html.de
- + A new spanish translation by Eduardo Magdalena
- + http://www.peletash.com/mecanicad/articulos/art02_0002.htm
-
- A greek translation is in progress.
- Relevant AutoDesk FAQ's and TechSupport
- http://www.autodesk.com/support/autocad/
- http://search.autodesk.com/query.html?qt=autocad+faq
- http://www.autodesk.com/support/autocad/asa2000.htm
- AutoDesk news groups
- news://discussion.autodesk.com/autodesk.autocad.customization
- New WebX interface at http://discussion.autodesk.com
- http://groups.google.com/groups?oi=djq&as_ugroup=autodesk.autocad.customization
-
- --
- Reini Urban, Jun 25, 2002
-