Anda di halaman 1dari 4

AutoLISP

FromWikipedia,thefreeencyclopedia

AutoLISPisadialectoftheLISPprogramminglanguagebuiltspecificallyforusewiththefullversionof
AutoCADanditsderivatives,whichincludeAutoCADMap3D,AutoCADArchitectureandAutoCAD
Mechanical.[1]NeithertheapplicationprogramminginterfacenortheinterpretertoexecuteAutoLISPcodeare
includedintheAutoCADLTproductline.[2]

Contents
1
2
3
4
5

Features
History
Examples
References
Externallinks

Features
AutoLISPisasmall,dynamicallyscoped,dynamicallytypedLISPdialectwithgarbagecollection,immutablelist
structureandsettablesymbols,lackinginsuchregularLISPfeaturesasmacrosystem,recordsdefinitionfacilities,
arrays,functionswithvariablenumberofargumentsorletbindings.Asidefromthecorelanguage,mostofthe
primitivefunctionsareforgeometry,accessingAutoCAD'sinternalDWGdatabase,ormanipulationofgraphical
entitiesinAutoCAD.ThepropertiesofthesegraphicalentitiesarerevealedtoAutoLISPasassociationlistsin
whichvaluesarepairedwithAutoCAD"groupcodes"thatindicatepropertiessuchasdefinitionalpoints,radii,
colors,layers,linetypes,etc.AutoCADloadsAutoLISPcodefrom.LSPfiles.[3]
AutoLISPcodecaninteractwiththeuserthroughAutoCAD'sgraphicaleditorbyuseofprimitivefunctionsthat
allowtheusertopickpoints,chooseobjectsonscreen,inputnumbersandotherdata.AutoLispalsohasabuiltin
GUIminilanguage,theDialogControlLanguage,forcreatingmodaldialogboxeswithautomatedlayout,within
AutoCAD.[3]

History
AutoLISPwasderivedfromanearlyversionofXLISP,whichwascreatedbyDavidBetz.[4]Thelanguagewas
introducedinAutoCADVersion2.18inJanuary1986,andcontinuedtobeenhancedinsuccessivereleasesupto
Release13inFebruary1995.Afterthat,itsdevelopmentwasneglectedbyAutodeskinfavorofmorefashionable
developmentenvironmentslikeVBA,.NETandObjectARX.However,ithasremainedAutoCAD'sprimaryuser
customizationlanguage.
VitalLISP,aconsiderablyenhancedversionofAutoLISPincludinganIDE,debuggerandcompiler,andActiveX
support,wasdevelopedandsoldbythirdpartydeveloperBasisSoftware.VitalLISPwasasupersetoftheexisting
AutoLISPlanguagethataddedVBAlikeaccesstotheAutoCADobjectmodel,reactors(eventhandlingfor
AutoCADobjects),generalActiveXsupport,andsomeothergeneralLispfunctions.Autodeskpurchasedthis,
renameditVisualLISP,andbrieflysolditasanaddontoAutoCADRelease14releasedinMay1997.Itwas
incorporatedintoAutoCAD2000releasedinMarch1999,asareplacementforAutoLISP.SincethenAutodesk

haschosentohaltmajorenhancementstoVisualLISPinfavoroffocusingmoreeffortonVBAand.NETand
C++.AsofJanuary31,2014,AutodesknolongersupportsversionsofVBAolderthan7.1.Thisispartofalong
termprocessofswitchingoverfromVBAto.NETforcustomization.[5][6]
AutoLISPhassuchastrongfollowingthatotherCADapplicationvendorsaddittotheirownproducts.Bricscad,
IntelliCADandothershaveAutoLISPfunctionality,sothatAutoLISPuserscanconsiderusingthemasan
alternativetoAutoCAD.MostdevelopmentinvolvingAutoLISPsinceAutoCAD2000isactuallyperformed
withinVisualLISPsincetheoriginalAutoLISPenginewasreplacedwiththeVisualLISPengine.Thereare
thousandsofutilitiesandapplicationsthathavebeendevelopedusingAutoLISPorVisualLISP(distributedas
LSP,FASandVLXfiles).[7][8]

TimelineofLispdialects(edit(http://en.wikipedia.org/w/index.php?title=Template:Lisp&action=edit))
1955 1960 1965 1970 1975 1980 1985 1990 1995 2000 2005 2010 2015
Lisp1.5

Lisp1.5

Maclisp

Maclisp

Interlisp
ZetaLisp

Interlisp
LispMachineLisp

Scheme
NIL

Scheme
NIL

CommonLisp
T

CommonLisp
T

EmacsLisp

EmacsLisp

AutoLISP

AutoLISP

ISLISP
EuLisp
Racket
Arc

ISLISP
EuLisp
Racket
Arc

Clojure

Clojure

LFE

LFE

Hy

Hy

Examples
AsimpleHelloworldprograminAutoLispwouldbe:
1(defunhello()
2(princ"\nHelloWorld!")
3(princ)
4)

Notethefinallineinsidethefunctiondefinition:Theprincfunction,whennotpassedanargument,doesnotreturn
avalue.AstheAutoCADcommandlinefunctionsasaREPL,thiswouldnormallyprint"HelloWorld!"tothe
commandline,followedimmediatelybythereturnvalueofthecalltoprinc.Withoutthefinalcalltotheprinc
function,theresultofthiswouldbe:
HelloWorld!"\nHelloWorld!"

Amorecomplexexamplemightbe:
1(defunc:pointlabel(/pnt)
2(if(setqpnt(getpoint"\nSpecifypoint:"))
3(progn
4(entmake
5(list
6'(0."POINT")
7(cons10(transpnt10))
8)
9)
10(entmake
11(list
12'(0."TEXT")
13(cons10(trans(cons(+(carpnt)0.6)(cdrpnt))10))
14(cons40(getvar'textsize))
15(cons1(strcat"X:"(rtos(carpnt))"Y:"(rtos(cadrpnt))))
16)
17)
18)
19)
20(princ)
21)

TheabovecodedefinesanewfunctionwhichgeneratesanAutoCADpointobjectatagivenpoint,withasingle
linetextobjectdisplayingtheXandYcoordinatesbesideit.Thenameofthefunctionincludesaspecialprefix'c:',
whichcausesAutoCADtorecognizethefunctionasaregularcommand.Theuser,upontyping'pointlabel'atthe
AutoCADCommandPrompt,wouldbepromptedtopickapoint,eitherbytypingtheXandYcoordinates,or
clickingalocationinthedrawing.Thefunctionwouldthenplaceamarkeratthatpoint,andcreateasingleline
textobjectnexttoit,containingthexandycoordinatesofthepointexpressedrelativetotheactiveUser
CoordinateSystem(UCS).Thefunctionrequiresnoparameters,andcontainsoneLocalvariable('pnt').
TheaboveexamplecouldalsobewrittenusingbuiltinAutoCADcommandstoachievethesameresult,however
thisapproachissusceptibletochangestothecommandpromptsbetweenAutoCADreleases.

References
1."AutoLISP".Retrieved14April2014.
2."AutoCADLTvs.AutoCAD".Retrieved14April2014.
3."AutoLISPDeveloper'sGuide".Retrieved14April2014.
4.HistoryofAutoLISP(http://ronleigh.com/autolisp/ahistory.htm)
5."MicrosoftVisualBasicforApplicationsModuleFAQ".Retrieved14April2014.
6."VBAsupportinAutoCAD2011".Retrieved14April2014.
7."BricsCADCompareversions".Retrieved14April2014.
8."IntelliCADCADPlatformFeaturesandBenefits".Retrieved14April2014.

Externallinks
AutoLISPFAQ(http://www.faqs.org/faqs/CAD/autolispfaq/)
Retrievedfrom"https://en.wikipedia.org/w/index.php?title=AutoLISP&oldid=710712285"
Categories: AutoCAD Lispprogramminglanguagefamily Computeraideddesignsoftware
Scriptinglanguages

Thispagewaslastmodifiedon18March2016,at16:24.
TextisavailableundertheCreativeCommonsAttributionShareAlikeLicenseadditionaltermsmayapply.
Byusingthissite,youagreetotheTermsofUseandPrivacyPolicy.Wikipediaisaregisteredtrademark
oftheWikimediaFoundation,Inc.,anonprofitorganization.