A few years ago, we posted some info and sample code on how to create a table in AutoCAD using autolisp. That works OK, but what if you want to define a particular table style first? I ran across this post by Lee Ambrosius on creating a table style from scratch using autolisp.

Read more about Create a table style in AutoCAD using autolisp

Ok, getting back to the last (ssget) call in part 1...

(ssget "_W" 
 (list 5.0 5.0)(list 8.0 8.0)
 '((0 . "CIRCLE")(-4 . "<")(40 . 1.0))

If you have written routines with Autolisp, then you have probably used the (ssget) function to select entities on the screen, either automatically or by prompting the user.

(ssget) is a powerful function that can do more than you probably realize. Let's look at a simple example.

(ssget '((0 . "TEXT")))
 Read more about Exploring the autolisp SSGET function - part 1

In the previous post about Startup Lisp Functions, the special (S::STARTUP) function was mentioned. Startup lisp code is loaded before the drawing is initialized, but you cannot call the (COMMAND) function until after the drawing is initialized. The solution is to place your (COMMAND) calls inside the (S::STARTUP) function. Read more about S::STARTUP Function

If you have lisp routines that you want to make available in each drawing session, forget the "Startup Suite" and load them using the "acaddoc.lsp" file. "acaddoc.lsp" is not included with AutoCAD, you create it yourself. But it is nothing more than a plain lisp file, except that the first one found at drawing startup (just put it in your support file search path), is loaded automatically each time a drawing is opened. Read more about Startup Lisp Functions

Here is a simple example of how to read a TXT file into lisp and then do something with the contents. In this example, the TXT file contains coordinates, and the code will draw either points or lines.

One thing to keep in mind. Most times when you open a file for read or write, you should open the file, perform the entire operation, then close the file. Keep the code to a minimum while the file is open. This way if you run into an unhandled error, the file isn't stuck open, and in the case of shared files, you are not locking the file for an extended amount if time. Read more about Reading a TXT file using LISP

If you program with autolisp, you have probably used the command function at some point, probably to construct drawing entities. There is certainly nothing wrong with that. However, if you are working on a large program that constructs a lot of drawing entities, you may have noticed that the command function runs pretty slow.

I put together some tests to compare the (command) function to two other methods of entity creation, (entmake) and (vla-add...). The test constructs 1,999 line entities using various methods.

Read more about Command vs. entmake vs. vla-add

This bit of lisp code will toggle the background color from white to black to white in whatever space you are in. (no effect on the block editor though...) Read more about Toggle AutoCAD Background

Here is an example of creating a TABLE entity using lisp. This example also creates some FIELDS using lisp.

This routine allows the user to select closed polylines, and it will create a TABLE with two columns. One containing the area, and the other containing the ObjectID. The last row totals up the area. You could easily adapt this to show the layer, color or any other property. Read more about Create a TABLE using lisp

If you are planning on upgrading to AutoCAD 2008 32-bit, and you have existing LISP, VBA, or ARX programs, will they work? Generally speaking, yes. You may have to make a minor adjustment to your code, but for the most part there shouldn't be any problems.

If you are planning on upgrading to AutoCAD 2008 64-bit, then you may have some decisions to make and/or work to do... Read more about AutoCAD 2008 - Will my programs work?



All content is copyright © CAD PANACEA 2005-2013 unless otherwise noted and may not be reproduced. All comments posted to this blog are the sole responsibility of the person making the comment.

Google, as a third party vendor, uses cookies to serve ads on this site. Google's use of their cookies enables it to serve ads to users based on their visit to your sites and other sites on the Internet. You may opt out of the use of these cookies by visiting the Google ad and content network privacy policy.

Powered by Drupal