jpsheader.jpg (29354 bytes)

 

Back to AutoLisp Tutorial HomePage

Back to AutoLisp HomePage

Back to JefferyPSanders.com HomePage

 

 

 

The AutoLisp Intermediate Tutorial


    Welcome to the Intermediate Tutorial.   You know the beginners steps to writing an AutoLisp program.   You don't? See the Beginner's Tutorial.   Now all you need to know is what to write.  What functions are available?    How do you manipulate entities inside of AutoCAD?   What is a "car of a cdr"?

   I believe that you not only need to know what a function returns if it is successful, but also what the function will return if it fails.  This will help you troubleshoot your programs.  That is why I believe this will become the Ultimate AutoLisp Tutorial.  In the examples of the functions below, I've included the most common reasons why AutoLisp programs crash along with the error message you will receive.  Remember, when AutoLisp has an error, execution is aborted. 


Let's begin with Data Types:

Data Types:

String

A string is an AutoLisp data type consisting of alphanumeric characters inside quotes.  

      eg.    "Jeff" "Sanders"      "1245r"        "3" 

Integers

An integer is a number without a decimal place. 

     eg. 1  23    456  67890  -5   -687

Real

A real number is a number that has a decimal place. 

     eg.  1.0    23.034   456.2   -56.345

List

   A list is an AutoLisp data type that has parenthesis around it.   Multiple data types can reside inside one list.   This will also unravel the mystery behind the car and the cdr.

     eg.   (1 2 3)       ("Jeff" 156.0  45.0 3  "Sanders")       (1)     ()       ( (1 2 3) (4 5 6)("A" "B" "C") ) 

Variables or Symbols 

  We covered these in the Beginner's Tutorial.   A variable is a symbol that is created by you, the user.  eg. (setq a 1) (setq pt1(getpoint "\n Select Point: "))   -   a and pt1 are the variables.

Associated List

   An associated list is a list that has a value associated with it.   The assocation and the data are seperated by a period.  eg.  (1 . 455)  (34 . "Sanders")  You can find "Sanders" by looking up group code 34.  We will get more into this when we take a look at the DXF Group Codes later in this Tutorial. 


   Let's get started with the basic functions.  Remember, you don't need to know all of this.  You don't need to memorize all of this.  This is a reference.   It will help you to read through it once to see what functions are available.  When you are writing a program and get stuck, come back here to find the correct function to solve your problem. 

String Functions    substr  strlen  strcase  strcat

Number Functions   abs  atof  atoi  fix  float  itoa

List Functions   car   cdr   cadr   caddr    caar    cddr    foreach   list    cons   nth

Group Codes/Associated List        assoc     Entity_DXF_Group_Codes

Conversion Functions    fix   float   itoa   atoi   atof    rtos   angtos

Math Functions    +    -    *   /   +1     -1    cos    atan    sin     sqrt    expt

Selecting Entities     entsel     ssget

Selection Set Functions   ssadd    ssdel   sslength   ssname   

Entity Functions   entget    entlast   entnext   entdel   entmod    entupd

File Functions     open    close     read-line     write-line     New!

DXF Group Code Table


Support this Site!


AutoLisp Tutorial Home

AutoLisp Home

Home

All questions/complaints/suggestions remarks should be sent to JefferyPSanders.com

Last Updated May 1st, 2013

Copyright 2002-2013 JefferyPSanders.com. All rights reserved.