[Search tip detail and code files using keywords, tip number, author name, etc ]
    For tip to function correctly, you must ensure that the downloaded file name matches the file name
    displayed in the Rename File To field. Please rename downloaded files when necessary.
Collection of Tips from Hot Tip Harry Himself
Tip# HTH1206 By Bill Kramer On 01-Dec-2006
Rated By 1 users Downloaded : 1018
Categories : Misc. User Tools, LISP Code Modules
Software type : AutoCAD
Rename File To : HTH1206.LSP
Collection of LISP routines developed by Cadalyst's own Hot Tip Harry, inspired by requests submitted to the Hot Tip Harry-Help discussion forum.

Harry's Holiday Tip #1
Solid Arrowhead to Polyline Outline is a special example using LISP to change data coming in from another source. In this case, the drawings that are manipulated came into AutoCAD with arrowheads represented as solid objects, and the user wanted to change them into something else. Originally, the request was for an outline of the solid object -- that's where Harry picked up and went off on his own. Tip #1 is composed of the LISP function SOL2PL found in the source code file for this month's Get the Code. Load the LISP and type SOL2PL at the Command line to run. It's automatic from that point forward as it attempts to locate solid objects and convert them to polyline outlines.

Functionally, the programming steps are simple. It finds all the solids to be converted, grabs the points and draws the outline. The coding is a bit more complex, but not by much. You can study the source code. Functions like this are typically run once for each drawing that is imported into AutoCAD so that oddities are cleaned up. You can expand this example in many directions to suit your own purposes.

Harry's Holiday Tip #2
Pretty Print a List is a utility that has been around for ages in the LISP world and here it is again in a recursive style. (DISP-LIST) is a function that accepts a list as an argument and displays the list in the AutoCAD text window. Instead of just dumping the list to the screen, (DISP-LIST) displays each new open parentheses grouping spaced over by the nesting level so you can visually read through a complex list structure without straining your eyes.

This function set consists of two functions. (DISP-LIST) is one line that calls up the (R-DISP-LIST) function, a recursive routine that displays the list contents. (R-DISP-LIST) has two parameters: the list to display and an integer representing the current tab-over amount. Initially, the value is supplied as negative, which indicates the start of a new list.

Recursive functions are functions that call themselves inside the function after reducing the data in some way. Recursion works very well for list handling, because any structure of list can be manipulated as demonstrated in this simple example. This example has been used in classes and other places, but has never appeared in Hot Tip Harry before. Plus, someone on the forums was wondering about a quick tool to display lists in a readable format a while back.

Harry's Holiday Tip #3
Block Usage Report displays a summary of how blocks are used in a drawing. Some time ago, a forum reader asked if anyone knew of a way to check how a block was used in a drawing. Was it inserted anywhere? Was it part of another block? How many times was it used? These questions and others can be answered by investigating the blocks table in AutoCAD. When loaded and run, BlockGem displays the block data in a variety of ways on the AutoCAD text screen.

This tip is composed of a command function (C:BLOCKGEM) with a small suite of utility functions. Programmers wanting an example of list manipulation will find this one particularly interesting because the entire function suite is based on the construction of a nested data list from information in the block table. There are plenty of MAPCAR, LAMBDA and a few APPLY functions that make up the meat and potatoes of the report output.

Harry's Holiday Tip #4
Sum the Area lets you select objects and learn the total area. After loading the LISP code, type Areasum at the Command prompt. Areasum asks you to select objects, one at a time, displaying the cumulative area with each selection. When no more objects are selected, the total area is shown using an AutoCAD alert dialog box. Programmers who investigate the source code will also find a version of the area sum as a utility that adds up the total area of a selection set.

Harry's Holiday Tip #5
Utility to Parse Comma Delimited Input is very useful for programming applications that read data from files or other devices. The most common form of record data sharing between programs is to use text strings with commas (or some other delimiter)between each of the values. This utility is for programmers only and is not a command function. To use in your programs, supply a text string that is comma delimited. The result is a list with each member being a string. Note that the program solves the delimiter problem using recursion, and is a great example for teaching that concept.

Harry's Holiday Tip #6
Linking Excel and AutoCAD via Visual LISP can be used by a lot of applications developers. There are numerous examples on the Web, but most are not provided in a programmer utility format, so Harry decided to put these out there again. These simple utilities solve the basic interface problem for Visual LISP programmers. The first is SETUPXL which accepts a filename of an existing spreadsheet along with a sheetname. It establishes a set of global symbols that are used in the other functions to read and write data. The two interface functions are PUT_CELL and GET_CELL. These functions write and read string data from the open Excel spreadsheet given the row and column number. Because LISP programmers normally find it easier to work with numeric values for rows and columns (who doesn't?), this function suite also includes a function for converting integer column numbers into the string representation found in Excel. Hope you can use these! Note that you must change the reference to the "tlb-filename" in the SETUPXL function to match your system. This is the location of the Excel object library.



Average Rating:

User comments