© 2011 Autodesk, Inc. All Rights Reserved. Except as otherwise permitted by Autodesk, Inc., this publication, or parts thereof, may notbe reproduced in any form, by any method, for any purpose.Certain materials included in this publication are reprinted with the permission of the copyright holder.TrademarksThe following are registered trademarks or trademarks of Autodesk, Inc., and/or its subsidiaries and/or affiliates in the USA and other countries:3DEC (design/logo), 3December, 3December.com, 3ds Max, Algor, Alias, Alias (swirl design/logo), AliasStudio, Alias|Wavefront (design/logo),ATC, AUGI, AutoCAD, AutoCAD Learning Assistance, AutoCAD LT, AutoCAD Simulator, AutoCAD SQL Extension, AutoCAD SQL Interface,Autodesk, Autodesk Envision, Autodesk Intent, Autodesk Inventor, Autodesk Map, Autodesk Map<strong>Guide</strong>, Autodesk Streamline, <strong>AutoLISP</strong>, AutoSnap,AutoSketch, AutoTrack, Backburner, Backdraft, Built with ObjectARX (logo), Burn, Buzzsaw, CAiCE, Civil 3D, Cleaner, Cleaner Central, ClearScale,Colour Warper, Combustion, Communication Specification, Constructware, Content Explorer, Dancing Baby (image), DesignCenter, DesignDoctor, Designer's Toolkit, DesignKids, DesignProf, DesignServer, DesignStudio, Design Web Format, Discreet, DWF, DWG, DWG (logo), DWGExtreme, DWG TrueConvert, DWG TrueView, DXF, Ecotect, Exposure, Extending the Design Team, Face Robot, FBX, Fempro, Fire, Flame, Flare,Flint, FMDesktop, Freewheel, GDX Driver, Green Building Studio, Heads-up Design, Heidi, HumanIK, IDEA Server, i-drop, ImageModeler, iMOUT,Incinerator, Inferno, Inventor, Inventor LT, Kaydara, Kaydara (design/logo), Kynapse, Kynogon, LandXplorer, Lustre, MatchMover, Maya,Mechanical Desktop, Moldflow, Moonbox, MotionBuilder, Movimento, MPA, MPA (design/logo), Moldflow Plastics Advisers, MPI, MoldflowPlastics Insight, MPX, MPX (design/logo), Moldflow Plastics Xpert, Mudbox, Multi-Master Editing, Navisworks, ObjectARX, ObjectDBX, OpenReality, Opticore, Opticore Opus, Pipeplus, PolarSnap, PortfolioWall, Powered with Autodesk Technology, Productstream, ProjectPoint, ProMaterials,RasterDWG, RealDWG, Real-time Roto, Recognize, Render Queue, Retimer,Reveal, Revit, Showcase, ShowMotion, SketchBook, Smoke, Softimage,Softimage|XSI (design/logo), Sparks, SteeringWheels, Stitcher, Stone, StudioTools, ToolClip, Topobase, Toxik, TrustedDWG, ViewCube, Visual,Visual LISP, Volo, Vtour, Wire, Wiretap, WiretapCentral, XSI, and XSI (design/logo).All other brand names, product names or trademarks belong to their respective holders.DisclaimerTHIS PUBLICATION AND THE INFORMATION CONTAINED HEREIN IS MADE AVAILABLE BY AUTODESK, INC. "AS IS." AUTODESK, INC. DISCLAIMSALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY ORFITNESS FOR A PARTICULAR PURPOSE REGARDING THESE MATERIALS.Published by:Autodesk, Inc.111 McInnis ParkwaySan Rafael, CA 94903, USA
ContentsChapter 1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1<strong>AutoLISP</strong> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1About Related <strong>AutoLISP</strong> Documents . . . . . . . . . . . . . . . . . 2Chapter 2 Using the <strong>AutoLISP</strong> Language . . . . . . . . . . . . . . . . . . . 3<strong>AutoLISP</strong> Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3<strong>AutoLISP</strong> Expressions . . . . . . . . . . . . . . . . . . . . . . . . . 3<strong>AutoLISP</strong> Function Syntax . . . . . . . . . . . . . . . . . . . 5<strong>AutoLISP</strong> Data Types . . . . . . . . . . . . . . . . . . . . . . . . . 6Integers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6Reals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8Selection Sets . . . . . . . . . . . . . . . . . . . . . . . . . . 8Entity Names . . . . . . . . . . . . . . . . . . . . . . . . . . 8File Descriptors . . . . . . . . . . . . . . . . . . . . . . . . . 9Symbols and Variables . . . . . . . . . . . . . . . . . . . . 10<strong>AutoLISP</strong> Program Files . . . . . . . . . . . . . . . . . . . . . . . 11Formatting <strong>AutoLISP</strong> Code . . . . . . . . . . . . . . . . . . 11Comments in <strong>AutoLISP</strong> Program Files . . . . . . . . . . . . 11<strong>AutoLISP</strong> Variables . . . . . . . . . . . . . . . . . . . . . . . . . 12Displaying the Value of a Variable . . . . . . . . . . . . . . 13iii
- Page 1: AutoCAD 2012 for MacAutoLISP Develo
- Page 5 and 6: Selection Set Filter Lists . . . .
- Page 7 and 8: Introduction1IntroductionFor years,
- Page 9 and 10: Using the AutoLISPLanguage2AutoLISP
- Page 11 and 12: A common mistake is to omit the clo
- Page 14 and 15: StringsA string is a group of chara
- Page 16 and 17: Symbols and VariablesAutoLISP uses
- Page 18 and 19: ■Make notes to yourself during de
- Page 20 and 21: NOTE You can change the value of th
- Page 22 and 23: (setq filnam "bigfile.txt")"bigfile
- Page 24 and 25: Exiting QuietlyIf you invoke the pr
- Page 26 and 27: Wild-Card MatchingThe wcmatch funct
- Page 28 and 29: Several AutoLISP functions provide
- Page 30 and 31: To assign particular coordinates to
- Page 32 and 33: caaarcadarcdaarcddarcaadarcaddarcda
- Page 34 and 35: Symbol and Function HandlingAutoLIS
- Page 36 and 37: ; error: Invalid attempt to access
- Page 38 and 39: expression can perform some evaluat
- Page 40 and 41: that your applications use the buil
- Page 42 and 43: 1bbb2In addition to ensuring that v
- Page 44 and 45: ■■■■■■■QUOTEREPEATSET
- Page 46 and 47: In this message, text describes the
- Page 48 and 49: (print "Okay, I'll keep going")))(p
- Page 50 and 51: If AutoCAD for Mac is at the Comman
- Page 52 and 53:
WARNING The Radius and Diameter sub
- Page 54 and 55:
Configuration ControlAutoCAD for Ma
- Page 56 and 57:
to display before the function paus
- Page 58 and 59:
The getangle function honors the se
- Page 60 and 61:
methods for abbreviating keywords;
- Page 62 and 63:
AutoLISP Function Synopsis, (page 1
- Page 64 and 65:
"2D") (100 . "AcDbEntity") (67 . 0)
- Page 66 and 67:
functions. The result is correct on
- Page 68 and 69:
(setq fmtval (rtos x 3 2)) ; Mode 3
- Page 70 and 71:
(princ (strcat str2 fmtval)) ;displ
- Page 72 and 73:
)(defun C:ASCII ( / chk out ct code
- Page 74 and 75:
acad.unt are in ASCII format and ar
- Page 76 and 77:
Coordinate System TransformationsTh
- Page 78 and 79:
Coordinate system codesCodeCoordina
- Page 80 and 81:
command line prompt for a file name
- Page 82 and 83:
The following table shows examples
- Page 84 and 85:
SSGET examples using filter listsFu
- Page 86 and 87:
Filtering for Extended DataUsing th
- Page 88 and 89:
■You cannot use the relational op
- Page 90 and 91:
last entities in the current drawin
- Page 92 and 93:
(setq var1 (ssget))(setq var2 (adsf
- Page 94 and 95:
The following code fragment uses ha
- Page 96 and 97:
In the following example, create a
- Page 98 and 99:
The following statement stores the
- Page 100 and 101:
(repeat (length entl)in list:(print
- Page 102 and 103:
ed))(entmod ed); to layer MYLAYER.;
- Page 104 and 105:
The following table identifies the
- Page 106 and 107:
When defining dotted pairs, as in t
- Page 108 and 109:
Entity Data Functions and the Graph
- Page 110 and 111:
Non-Graphic Object HandlingAutoCAD
- Page 112 and 113:
Dictionary ObjectsThe following rul
- Page 114 and 115:
Integer 1070. A 16-bit integer (sig
- Page 116 and 117:
))"\nCan't register XDATA for " app
- Page 118 and 119:
(setq exdata; Sets the variable'((-
- Page 120 and 121:
)(10 1.0 2.0 0.0) (40 . 3.14159) (5
- Page 122 and 123:
(10 9.0 2.0 0.0)(-2 . )As with tbln
- Page 124 and 125:
118
- Page 126 and 127:
Functions are grouped by data type
- Page 128 and 129:
Application-handling functionsFunct
- Page 130 and 131:
Arithmetic functionsFunctionDescrip
- Page 132 and 133:
Equality and conditional functionsF
- Page 134 and 135:
Function-handling functionsFunction
- Page 136 and 137:
List manipulation functionsFunction
- Page 138 and 139:
String-handling functionsFunctionDe
- Page 140 and 141:
Symbol-handling functionsFunctionDe
- Page 142 and 143:
Display Control FunctionsThe follow
- Page 144 and 145:
File-handling functionsFunctionDesc
- Page 146 and 147:
Query and command functionsFunction
- Page 148 and 149:
User input functionsFunctionDescrip
- Page 150 and 151:
Object-handling functionsFunctionDe
- Page 152 and 153:
Symbol Table and Dictionary-Handlin
- Page 154 and 155:
variables in the associated documen
- Page 156 and 157:
Error CodesThe following table show
- Page 158 and 159:
Online program error codesValueMean
- Page 160 and 161:
Online program error codesValueMean
- Page 162 and 163:
156
- Page 164 and 165:
edefining AutoCAD commands 32,34rel
- Page 166 and 167:
polylines (old-style andlightweight
- Page 168 and 169:
string conversions 61, 64synopsis o
- Page 170 and 171:
overview 9file extensionsstripping
- Page 172 and 173:
output functions 16, 21control char
- Page 174 and 175:
object-handling 86, 106selection se
- Page 176 and 177:
quoted stringscontrol characters in
- Page 178:
user comments 69User Coordinate Sys