AutoLISP Reference Guide - Autodesk

Transcription

AutoCAD 2013AutoLISP Reference GuideJanuary 2012

2012 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:123D, 3ds Max, Algor, Alias, Alias (swirl design/logo), AliasStudio, ATC, AUGI, AutoCAD, AutoCAD Learning Assistance, AutoCAD LT, AutoCADSimulator, AutoCAD SQL Extension, AutoCAD SQL Interface, Autodesk, Autodesk Homestyler, Autodesk Intent, Autodesk Inventor, AutodeskMapGuide, Autodesk Streamline, AutoLISP, AutoSketch, AutoSnap, AutoTrack, Backburner, Backdraft, Beast, Beast (design/logo) Built withObjectARX (design/logo), Burn, Buzzsaw, CAiCE, CFdesign, Civil 3D, Cleaner, Cleaner Central, ClearScale, Colour Warper, Combustion,Communication Specification, Constructware, Content Explorer, Creative Bridge, Dancing Baby (image), DesignCenter, Design Doctor, Designer'sToolkit, DesignKids, DesignProf, DesignServer, DesignStudio, Design Web Format, Discreet, DWF, DWG, DWG (design/logo), DWG Extreme,DWG TrueConvert, DWG TrueView, DWFX, DXF, Ecotect, Evolver, Exposure, Extending the Design Team, Face Robot, FBX, Fempro, Fire, Flame,Flare, Flint, FMDesktop, Freewheel, GDX Driver, Green Building Studio, Heads-up Design, Heidi, Homestyler, HumanIK, IDEA Server, i-drop,Illuminate Labs AB (design/logo), ImageModeler, iMOUT, Incinerator, Inferno, Instructables, Instructables (stylized robot design/logo),Inventor,Inventor LT, Kynapse, Kynogon, LandXplorer, LiquidLight, LiquidLight (design/logo), Lustre, MatchMover, Maya, Mechanical Desktop, Moldflow,Moldflow Plastics Advisers, Moldflow Plastics Insight, Moldflow Plastics Xpert, Moondust, MotionBuilder, Movimento, MPA, MPA (design/logo),MPI, MPI (design/logo), MPX, MPX (design/logo), Mudbox, Multi-Master Editing, Navisworks, ObjectARX, ObjectDBX, Opticore, Pipeplus, Pixlr,Pixlr-o-matic, PolarSnap, PortfolioWall, Powered with Autodesk Technology, Productstream, ProMaterials, RasterDWG, RealDWG, Real-timeRoto, Recognize, Render Queue, Retimer, Reveal, Revit, RiverCAD, Robot, Scaleform, Scaleform GFx, Showcase, Show Me, ShowMotion,SketchBook, Smoke, Softimage, Softimage XSI (design/logo), Sparks, SteeringWheels, Stitcher, Stone, StormNET, Tinkerbox, ToolClip, Topobase,Toxik, TrustedDWG, U-Vis, ViewCube, Visual, Visual LISP, Voice Reality, Volo, Vtour, WaterNetworks, Wire, Wiretap, WiretapCentral, XSI.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.

ContentsChapter 1AutoLISP Functions . . . . . . . . . . . . . . . . . . . . . . . . . 1AutoLISP Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 (add) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1- (subtract) . . . . . . . . . . . . . . . . . . . . . . . . . . . 2* (multiply) . . . . . . . . . . . . . . . . . . . . . . . . . . . 3/ (divide) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 (equal to) . . . . . . . . . . . . . . . . . . . . . . . . . . . 5/ (not equal to) . . . . . . . . . . . . . . . . . . . . . . . . 6 (less than) . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 (less than or equal to) . . . . . . . . . . . . . . . . . . . . 8 (greater than) . . . . . . . . . . . . . . . . . . . . . . . . . 9 (greater than or equal to) . . . . . . . . . . . . . . . . . . 9 (bitwise NOT) . . . . . . . . . . . . . . . . . . . . . . . . 101 (increment) . . . . . . . . . . . . . . . . . . . . . . . . 111- (decrement) . . . . . . . . . . . . . . . . . . . . . . . . . 12A Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12abs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12acad-pop-dbmod . . . . . . . . . . . . . . . . . . . . . . . 13acad-push-dbmod . . . . . . . . . . . . . . . . . . . . . . . 13acad strlsort . . . . . . . . . . . . . . . . . . . . . . . . . . 14acad truecolorcli . . . . . . . . . . . . . . . . . . . . . . . 15acad truecolordlg . . . . . . . . . . . . . . . . . . . . . . . 16acdimenableupdate . . . . . . . . . . . . . . . . . . . . . . 17iii

acet-layerp-mode . . . . . . . . . . . . . . . . . . . . . . . 18acet-layerp-mark . . . . . . . . . . . . . . . . . . . . . . . 19alert . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20alloc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21and . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21angle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22angtof . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23angtos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24append . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25apply . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26arx . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26arxload . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27arxunload . . . . . . . . . . . . . . . . . . . . . . . . . . . 28ascii . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28assoc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29atan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30atof . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31atoi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31atom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32atoms-family . . . . . . . . . . . . . . . . . . . . . . . . . 33autoarxload . . . . . . . . . . . . . . . . . . . . . . . . . . 33autoload . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34B Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35Boole . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35boundp . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37C Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38caddr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38cadr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38car . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39cdr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40chr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41close . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41command . . . . . . . . . . . . . . . . . . . . . . . . . . . 42command-s . . . . . . . . . . . . . . . . . . . . . . . . . . 43cond . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48cons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49cos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50cvunit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50D Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52defun . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52defun-q . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53defun-q-list-ref . . . . . . . . . . . . . . . . . . . . . . . . 54defun-q-list-set . . . . . . . . . . . . . . . . . . . . . . . . 55dictadd . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56dictnext . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58dictremove . . . . . . . . . . . . . . . . . . . . . . . . . . 59iv Contents

dictrename . . . . . . . . . . . . . . . . . . . . . . . . . . 60dictsearch . . . . . . . . . . . . . . . . . . . . . . . . . . . 61distance . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62distof . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63dumpallproperties . . . . . . . . . . . . . . . . . . . . . . . 64E Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67entdel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67entget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68entlast . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69entmake . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70entmakex . . . . . . . . . . . . . . . . . . . . . . . . . . . 72entmod . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73entnext . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75entsel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77entupd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78eq . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80equal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81*error* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82eval . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83exit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84exp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84expand . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85expt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86F Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86findfile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86fix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87float . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88foreach . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89G Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90gc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90gcd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91getangle . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91getcfg . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93getcname . . . . . . . . . . . . . . . . . . . . . . . . . . . 94getcorner . . . . . . . . . . . . . . . . . . . . . . . . . . . 94getdist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95getenv . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96getfiled . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97getint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99getkword . . . . . . . . . . . . . . . . . . . . . . . . . . . 100getorient . . . . . . . . . . . . . . . . . . . . . . . . . . . 101getpoint . . . . . . . . . . . . . . . . . . . . . . . . . . . 102getpropertyvalue . . . . . . . . . . . . . . . . . . . . . . . 103getreal . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104getstring . . . . . . . . . . . . . . . . . . . . . . . . . . . 105Contents v

getvar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106graphscr . . . . . . . . . . . . . . . . . . . . . . . . . . . 106grclear . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107grdraw . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107grread . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108grtext . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110gr vecs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112H Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114handent . . . . . . . . . . . . . . . . . . . . . . . . . . . 114I Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115if . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115initcommandversion . . . . . . . . . . . . . . . . . . . . 116initdia . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117initget . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118ispropertyreadonly . . . . . . . . . . . . . . . . . . . . . . 123inters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124itoa . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125L Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126lambda . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126last . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127layoutlist . . . . . . . . . . . . . . . . . . . . . . . . . . . 127layerstate-addlayers . . . . . . . . . . . . . . . . . . . . . 128layerstate-compare . . . . . . . . . . . . . . . . . . . . . . 129layerstate-delete . . . . . . . . . . . . . . . . . . . . . . . 130layerstate-export . . . . . . . . . . . . . . . . . . . . . . . 130layerstate-getlastrestored . . . . . . . . . . . . . . . . . . . 131layerstate-getlayers . . . . . . . . . . . . . . . . . . . . . . 131layerstate-getnames . . . . . . . . . . . . . . . . . . . . . 132layerstate-has . . . . . . . . . . . . . . . . . . . . . . . . . 132layerstate-import . . . . . . . . . . . . . . . . . . . . . . . 133layerstate-importfromdb . . . . . . . . . . . . . . . . . . . 133layerstate-removelayers . . . . . . . . . . . . . . . . . . . 134layerstate-rename . . . . . . . . . . . . . . . . . . . . . . 134layerstate-restore . . . . . . . . . . . . . . . . . . . . . . . 135layerstate-save . . . . . . . . . . . . . . . . . . . . . . . . 135length . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136list . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137listp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138load . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139log . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140logand . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141logior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141lsh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142M Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143mapcar . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143max . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144vi Contents

mem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145member . . . . . . . . . . . . . . . . . . . . . . . . . . . 146menucmd . . . . . . . . . . . . . . . . . . . . . . . . . . 147min . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147minusp . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148N Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149namedobjdict . . . . . . . . . . . . . . . . . . . . . . . . 149nentsel . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149nentselp . . . . . . . . . . . . . . . . . . . . . . . . . . . 151not . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152nth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153null . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153numberp . . . . . . . . . . . . . . . . . . . . . . . . . . . 154O Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155open . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155or . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156osnap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157P Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157polar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157prin1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158princ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160print . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161progn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161prompt . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162Q Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163quit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163quote . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163R Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164read . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164read-char . . . . . . . . . . . . . . . . . . . . . . . . . . . 165read-line . . . . . . . . . . . . . . . . . . . . . . . . . . . 166redraw . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167regapp . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168rem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168repeat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169reverse . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170rtos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171S Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172setcfg . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173setenv . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174setpropertyvalue . . . . . . . . . . . . . . . . . . . . . . . 175setq . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176setvar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177setview . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179sin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179Contents vii

snvalid . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180sqrt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182ssadd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183ssdel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184ssget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185ssgetfirst . . . . . . . . . . . . . . . . . . . . . . . . . . . 188sslength . . . . . . . . . . . . . . . . . . . . . . . . . . . 189ssmemb . . . . . . . . . . . . . . . . . . . . . . . . . . . 189ssname . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190ssnamex . . . . . . . . . . . . . . . . . . . . . . . . . . . 191sssetfirst . . . . . . . . . . . . . . . . . . . . . . . . . . . 194startapp . . . . . . . . . . . . . . . . . . . . . . . . . . . 196strcase . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197strcat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198strlen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198subst . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199substr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200T Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201tblnext . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201tblobjname . . . . . . . . . . . . . . . . . . . . . . . . . . 203tblsearch . . . . . . . . . . . . . . . . . . . . . . . . . . . 204terpri . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205textbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205textpage . . . . . . . . . . . . . . . . . . . . . . . . . . . 206textscr . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206trace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207trans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210U Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213V Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213ver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213vl-acad-defun . . . . . . . . . . . . . . . . . . . . . . . . 214vl-acad-undefun . . . . . . . . . . . . . . . . . . . . . . . 214vl-bb-ref . . . . . . . . . . . . . . . . . . . . . . . . . . . 215vl-bb-set . . . . . . . . . . . . . . . . . . . . . . . . . . . 215vl-catch-all-apply . . . . . . . . . . . . . . . . . . . . . . 216vl-catch-all-error-message . . . . . . . . . . . . . . . . . . 217vl-catch-all-error-p . . . . . . . . . . . . . . . . . . . . . . 218vl-cmdf . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219vl-consp . . . . . . . . . . . . . . . . . . . . . . . . . . . 221vl-directory-files . . . . . . . . . . . . . . . . . . . . . . . 221vl-doc-ref . . . . . . . . . . . . . . . . . . . . . . . . . . . 222vl-doc-set . . . . . . . . . . . . . . . . . . . . . . . . . . . 223vl-every . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224vl-exit-with-error . . . . . . . . . . . . . . . . . . . . . . . 225vl-exit-with-value . . . . . . . . . . . . . . . . . . . . . . 226viii Contents

vl-file-copy . . . . . . . .vl-file-delete . . . . . . .vl-file-directory-p . . . .vl-file-rename . . . . . .vl-file-size . . . . . . . .vl-file-systime . . . . . .vl-filename-base . . . . .vl-filename-directory . .vl-filename-extension . .vl-filename-mktemp . . .vl-list* . . . . . . . . . .vl-list- string . . . . . . .vl-list-length . . . . . . .vl-load-all . . . . . . . .vl-mkdir . . . . . . . . .vl-member-if . . . . . . .vl-member-if-not . . . . .vl-position . . . . . . . .vl-prin1-to-string . . . . .vl-princ-to-string . . . . .vl-propagate . . . . . . .vl-registry-delete . . . . .vl-registry-descendents .vl-registry-read . . . . . .vl-registry-write . . . . .vl-remove . . . . . . . .vl-remove-if . . . . . . .vl-remove-if-not . . . . .vl-some . . . . . . . . . .vl-sort . . . . . . . . . .vl-sort-i . . . . . . . . . .vl-string- list . . . . . . .vl-string-elt . . . . . . . .vl-string-left-trim . . . .vl-string-mismatch . . . .vl-string-position . . . .vl-string-right-trim . . . .vl-string-search . . . . . .vl-string-subst . . . . . .vl-string-translate . . . .vl-string-trim . . . . . . .vl-symbol-name . . . . .vl-symbol-value . . . . .vl-symbolp . . . . . . . .vports . . . . . . . . . .W Functions . . . . . . . . . . 227. 228. 229. 230. 230. 231. 232. 233. 233. 234. 235. 236. 237. 238. 238. 239. 240. 241. 242. 242. 243. 244. 244. 245. 246. 247. 247. 248. 249. 250. 251. 253. 253. 254. 254. 256. 257. 257. 258. 260. 260. 261. 262. 262. 263. 264Contents ix

wcmatch .while . . .write-charwrite-line .X Functions . .xdroom . .xdsize . . .Z Functions . . .zerop . . .Chapter 2. 264. 267. 268. 268. 269. 269. 270. 271. 271Externally Defined Commands . . . . . . . . . . . . . . . . . 273Externally Defined Commands . . . . . . . . . . . . . . . . . . . . . 273align . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273cal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274mirror3d . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275rotate3d . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275solprof . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277x Contents

1AutoLISP FunctionsAutoLISP Functions The following is a catalog of the AutoLISP functions available in AutoCAD .The functions are listed alphabetically.In this chapter, each listing contains a brief description of the function's useand a function syntax statement showing the order and the type of argumentsrequired by the function.Note that any functions, variables, or features not described here or in otherparts of the documentation are not officially supported and are subject to changein future releases.For information on syntax, see AutoLISP Function Syntax in the AutoLISPDeveloper's Guide.Note that the value returned by some functions is categorized as unspecified.This indicates you cannot rely on using the value returned from this function.Operators (add)Returns the sum of all numbers.( [number number].)1

Argumentsnumber A number.Return ValuesThe result of the addition. If you supply only one number argument, thisfunction returns the result of adding it to zero. If you supply no arguments,the function returns 0.Examples( 1 2)returns3( 1 2 3 4.5)returns10.5( 1 2 3 4.0)returns10.0- (subtract)Subtracts the second and following numbers from the first and returns thedifference([number number].)Argumentsnumber A number.Return ValuesThe result of the subtraction. If you supply more than two number arguments,this function returns the result of subtracting the sum of the second throughthe last numbers from the first number. If you supply only one numberargument, this function subtracts the number from zero, and returns a negativenumber. Supplying no arguments returns 0.Examples2 Chapter 1 AutoLISP Functions

(- 50 40)returns10(- 50 40.0)returns10.0(- 50 40.0 2.5)returns7.5(- 8)returns-8* (multiply)Returns the product of all numbers(*[number number].)Argumentsnumber A number.Return ValuesThe result of the multiplication. If you supply only one number argument,this function returns the result of multiplying it by one; it returns the number.Supplying no arguments returns 0.Examples(* 2 3)returns6(* 2 3.0)returns6.0(* 2 3 4.0)AutoLISP Functions 3

returns24.0(* 3 -4.5)returns-13.5(* 3)returns3/ (divide)Divides the first number by the product of the remaining numbers and returnsthe quotient(/[number number].)Argumentsnumber A number.Return ValuesThe result of the division. If you supply more than two number arguments,this function divides the first number by the product of the second throughthe last numbers, and returns the final quotient. If you supply one numberargument, this function returns the result of dividing it by one; it returns thenumber. Supplying no arguments returns 0.Examples(/ 100 2)returns50(/ 100 2.0)returns50.0(/ 100 20.0 2)returns4 Chapter 1 AutoLISP Functions

2.5(/ 100 20 2)returns2(/ 4)returns4 (equal to)Compares arguments for numerical equality( numstr [numstr].)Argumentsnumstr A number or a string.Return ValuesT, if all arguments are numerically equal; otherwise nil . If only one argumentis supplied, returns T.Examples( 4 4.0)returnsT( 20 388)returnsnil( 2.4 2.4 2.4)returnsT( 499 499 500)returnsnil( "me" "me")returnsAutoLISP Functions 5

T( "me" "you")returnsnilSee also:The eq (page 80) and equal (page 81) functions./ (not equal to)Compares arguments for numerical inequality(/ numstr [numstr].)Argumentsnumstr A number or a string.Return ValuesT, if no two successive arguments are the same in value; otherwise nil. If onlyone argument is supplied, / returns T.Note that the behavior of / does not quite conform to other LISP dialects.The standard behavior is to return T if no two arguments in the list have thesame value. In AutoLISP, / returns T if no successive arguments have the samevalue; see the examples that follow.Examples(/ 10 20)returnsT(/ "you" "you")returnsnil(/ 5.43 5.44)returns6 Chapter 1 AutoLISP Functions

T(/ 10 20 10 20 20)returnsnil(/ 10 20 10 20)returnsTNOTE In the last example, although there are two arguments in the list with thesame value, they do not follow one another; thus / evaluates to T. (less than)Returns T if each argument is numerically less than the argument to its right;otherwise nil( numstr [numstr].)Argumentsnumstr A number or a string.Return ValuesT, if each argument is numerically less than the argument to its right; otherwisereturns nil . If only one argument is supplied, returns T.Examples( 10 20)returnsT( "b" "c")returnsT( 357 33.2)returnsnil( 2 3 88)AutoLISP Functions 7

returnsT( 2 3 4 4)returnsnil (less than or equal to)Returns T if each argument is numerically less than or equal to the argumentto its right; otherwise returns nil( numstr [numstr].)Argumentsnumstr A number or a string.Return ValuesT, if each argument is numerically less than or equal to the argument to itsright; otherwise returns nil. If only one argument is supplied, returns T.Examples( 10 20)returnsT( "b" "b")returnsT( 357 33.2)returnsnil( 2 9 9)returnsT( 2 9 4 5)returnsnil8 Chapter 1 AutoLISP Functions

(greater than)Returns T if each argument is numerically greater than the argument to itsright; otherwise returns nil( numstr [numstr].)Argumentsnumstr A number or a string.Return ValuesT, if each argument is numerically greater than the argument to its right;otherwise nil. If only one argument is supplied, returns T.Examples( 120 17)returnsT( "c" "b")returnsT( 3.5 1792)returnsnil( 77 4 2)returnsT( 77 4 4)returnsnil (greater than or equal to)Returns T if each argument is numerically greater than or equal to theargument to its right; otherwise returns nilAutoLISP Functions 9

( numstr [numstr].)Argumentsnumstr A number or a string.Return ValuesT, if each argument is numerically greater than or equal to the argument toits right; otherwise nil. If only one argument is supplied, returns T.Examples( 120 17)returnsT( "c" "c")returnsT( 3.5 1792)returnsnil( 77 4 4)returnsT( 77 4 9)returnsnil (bitwise NOT)Returns the bitwise NOT (1's complement) of the argument( int)Arguments10 Chapter 1 AutoLISP Functions

int An integer.Return ValuesThe bitwise NOT (1's complement) of the argument.Examples( 3)returns-4( 100)returns-101( -4)returns31 (increment)Increments a number by 1(1 number)Argumentsnumber Any number.Return ValuesThe argument, increased by 1.Examples(1 5)returns6(1 -17.5)returns-16.5AutoLISP Functions 11

1- (decrement)Decrements a number by 1(1number)Argumentsnumber Any numb

Note that the behavior of / does not quite conform to other LISP dialects. The standard behavior is to return T if no two arguments in the list have the same value. In AutoLISP , / returns T if no successive arguments have the same value; see the examples that follow. Examples (/ 10 20) returns T (/ "you" "you") returns nil (/ 5.43 5.44 .