AutoLISP

AutoLISP [ ɑ ː ˌ toʊ lɪsp ] is a dialect of the LISP programming language and part of the popular CAD program AutoCAD.

Features may be added with the help of AutoLisp in an AutoCAD system, deleted and modified. To ensure this, there are specific AutoLISP routines that can directly access the AutoCAD database. These are functions for handling inputs of coordinates whose drawing implementation in CAD ​​elements, such as line, circle, etc. With the help of AutoLISP, complex environments allow for handling AutoCAD, for example, as regards the application of standard parts, essentially create.

Hello World

( defun c: HelloWorld ()       ( princ "\ nHello World") ) For example, to draw a rectangle

( defun c: law2 ( / p1 p2 p3 p4 len wide w )     ( setq p1 ( getpoint "\ nEinfügepunkt :") )     ( setq len ( getdist p1 "\ nLength :") )     ( setq width ( getdist p1 "\ nWidth :") )     ( setq w ( GetAngle p1 "\ nEinfügewinkel :") )     ( setq p2 (polar p1 w len) )     ( setq p3 (polar p2 ( ( / pi 2) w) width) )     ( setq p4 (polar p3 ( pi w) len) )     (command "line" p1 p2 p3 p4 "s" )     ( princ )   ) Example: Determination of a distance in Autolisp

( defun c: distance ( )    ( setq old_osmode ( getvar " osmode " ) )    ( setvar " osmode " 1)    ( setq P01 ( getpoint "\ nErster point :") )    ( setq distance ( getdist P01 "\ nZweiter point :") )    ( princ "\ nDistanzwert :")    ( princ distance)    ( princ "\ n, with access to AutoCAD! DISTANCE " )    ( setvar " osmode " old_osmode )   ) Example: Rotate objects in Autolisp

( defun c: torsionally ( / pivot point radius selection Erster_Punkt )    ( setq fulcrum ( getpoint "\ nDrehen with the circle of :") )   (if fulcrum    ( progn     ( setq radius ( abs ( getdist fulcrum "\ nRadius for : ")))     (if radius      (command " circle " pivot radius)     ) end if radius    ) end progn fulcrum   ) end if fulcrum   (if radius    ( setq selection ( ssget ) ); Choose the elements to rotate   ) end if radius   (if selection    ( progn     ( setq Erster_Punkt ( getpoint fulcrum "\ nAusgangspunkt of rotation [ intersection ] with the :") )     (if Erster_Punkt      ( progn       (command " rotate " ( ssget "V") " " pivot point "B" fulcrum Erster_Punkt break nil)       (command " Delete" "L " "")       ) end progn Erster_Punkt      ) end if Erster_Punkt     ) end progn selection    ); end if selection   ); End of the function torsionally   ( princ "\ nVERDREH.LSP loaded .. " )   ( princ "\ nPlease with torsionally \ n")   ( princ ) Example: set objects on the current layer in AutoLisp

; Sets selected objects to the current layer   ( defun c: selayer ( / ak_layer )   ( setq ak_layer ( getvar " CLAYER " ) )   ( princ "\ nObjekte set to: <" )   ( princ ak_layer )   ( princ " > all the properties of the layer are taken. " )   (command " _change " ( ssget ) "" " _p " " _LA " ak_layer " _LT " " _bylayer " " _C " " _bylayer " " _S " " 1 " "")   ) Web Links

  • AutoLisp FAQ ( eng.)
  • CADwiesel.de - Lisp for ACAD code snippet and Downloads
  • Unofficial AutoCAD Help page to cad.de
  • AutoLisp Tutorials ( eng.)
  • Lisp
  • Scripting language
91475
de