Calculate Weight Earns November Top Tip Honor (Hot Tip Harry AutoCAD Tutorial)31 Oct, 2007 By: Bill Kramer
This month's batch of tips from readers includes an outstanding utility to determine the real-world weight of a design given its material and thickness.
Now, on to this month's collection of tips.
Tip 2251: Bind Xrefs to the Drawing
Bind Xrefs to the Drawing, by Sherwood Coleman, is a very simple macro that combines two AutoCAD commands -- Xref and Purge -- into a single command called Bax. This function binds external references into the drawing, then purges the unused information. This example is great for those just starting in LISP and wondering how to put together a macro involving a couple of commands and system variable settings. To use it, just load the LSP file and type C:Bax at the Command line of AutoCAD. The rest is automatic. When you start building new commands, you begin to take control of AutoCAD. Next comes productivity. Thanks for the tip, Sherwood.
Tips 2252 and 2253: Object's Layer Off and Object's Layer Freeze
The next two tips -- Object's Layer Off and Object's Layer Freeze, come from Francis Gamotis; however, he notes that coworkers at the City of Tacoma, Washington, helped create these tips. Both tips are similar in that they allow you to select an object on the screen and either turn off the layer for that object or freeze it, respectively. This variation of the layer off/freeze power tool allows for the selection of nested objects. When a nested object is selected, the Block Insert layer is frozen instead. To use these tips, load the LSP code and type Offx to turn off the layer or Frzx to freeze the layer of the object selected. These handy AutoCAD power tools come from power users. Thanks, Francis.
Tip 2254: Enhanced View Rotate
The Enhanced View Rotate macro is from one of Harry's favorite contributors, Leonid Nemirovsky. Just after Harry's last request for more tips, Len sent in a fresh one he had created that day for his own work. This macro will rotate the current view based on the selection of two points defining a line meant to be parallel with the x-axis. Load the LSP code, then type Xpln at the Command line of AutoCAD to activate the command function. You will be prompted for two points: The first is the base point of your new x axis. The second is a point along the positive direction of the x axis. A line is drawn, the user coordinate system (UCS) sets to that new line, the plan view is shown, and the line erases automatically. Nice programming to solve an on-the-job issue. A tip of the hat once again from Harry!
Tip 2255: Revision Mark-ups
Ferdinand Gawat submitted the Revision Mark-ups utility, which contains two tools for marking revisions on your drawing. The first tool is a new command named RCloud for drawing revision clouds around notes or part of a drawing. The other tool is a command function named RDelta for inserting the revision number with a triangle around it. To use these command functions, just load the LSP file for the tip and type the names in AutoCAD. RCloud defines a revision cloud in a counterclockwise direction. When the cloud is defined, it will be placed on a layer named Rev along with the revision number, then -Cloud. The delta mark and number are drawn on layer Rev along with the revision number, then -Delta. The text height and arc length values are set in the program code with comments that make it easy for users to find and change them to their own preferences. This program is a very nice example for those learning about more advanced drawing with LISP.
Tip 2256: Convert LISP to FAS
The utility named Convert LISP to FAS, by Jim Dee, is a tool for CAD managers and programmers. This utility will convert a folder full of LSP files into faster-loading FAS files. FAS files are a type of LISP file in which all comments and extra white spaces have been removed along with other changes intended to make the file load and evaluate more quickly. In addition to the faster load times, FAS files are more difficult for others to read, which is a way to protect your programming work from prying eyes. Consultants and CAD managers will find this tool useful after it has been modified to match specific computer folder names. The folder names can be adjusted using a text editor; I recommend using AutoCAD's VLIDE command. Once prepared, load the LSP file and type CompLISP to activate. The program will ask if you want to compile the folder entire contents or just those files that have been changed. Changes are detected by comparing the date/time stamp of the LSP source and FAS target files. If the LSP is newer, then it has changed since the last compilation. This utility isn't for everyone, but it is quite handy for advanced CAD managers and programmers. Thanks, Jim!
Tip 2257: Track File Use
Another useful CAD manager utility -- Track File Use -- was written by Eric Brown. This utility will write entries -- including the drawing name, user login name, file creation date, folder location, and any other location you choose to add to the program -- to a log file. The log file is created in the root folder (C:\) of the computer. Log files of this type are very handy when you need to review what operators are doing on which drawings. This program will run when loaded. The obvious application is to add it to AutoCAD's startup suite so that it loads (and runs) as AutoCAD opens a drawing. No operator interaction is required -- this is a run-behind-the-scenes type of CAD manager application that makes the job easier.
Tip 2258: Calculate Weight
Jeffery Sanders submitted another of his professional-quality programs -- Calculate Weight -- that earns this month's top tip honor and wins the $100 prize. If you need to know the real-world weight of your product design (or a portion of it) given its material and thickness, this program is for you. The tip includes two files: a LSP program file and DCL dialog box definition. Add both files to a folder searched by AutoCAD. Load the LSP file and type Weight at the AutoCAD Command line. A dialog box displaying various materials will appear. Select the material of choice from the dialog box, pick a point inside a closed boundary (as in the AREA command), and then locate where to insert the total weight as text into the drawing. This program demonstrates a lot of LISP programming features, including lists of data manipulated with ease, a friendly dialog box, good error catching, and lots of useful comments. That earns it the top tip for this month. Great programming once again from Mr. Sanders!
Harry is always scouting for new tips. If you have a macro, function, or program you have written that makes your job as an AutoCAD expert easier, please send it in and share it with others so we all gain. It might be worth a cool T-shirt and some bucks. Send your tips to email@example.com and keep on programmin'.
Join the Hot Tip Harry Challenge
Harry needs your tips! Do you have an original routine written in VBA, Visual LISP, or even ObjectARX for AutoCAD customization? Send it in, with all the source code, to firstname.lastname@example.org. Your tip may be needed by others now, so don't delay!
Subscribe to Harry's Code Class
Cadalyst's Hot Tip Harry helps programmers and programmer wannabes learn the ins and outs of AutoCAD customization in his monthly e-newsletter, Harry's Code Class. Subscribe today and start building your programming expertise.
Hot Tip Harry Discussion Forums
Harry is standing by online to aid AutoCAD users and programmers. Cadalyst's Hot Tip Harry -- Help! forum offers assistance with AutoCAD programming and customization problems. Hot Tip Harry -- Requests can help you locate a specific LISP or VBA routine for AutoCAD. Participation in Cadalyst Discussion Forums requires registration, but it's free.
Get Your Weekly Fix of AutoCAD Tips
Cadalyst's Tips & Tools Weekly e-newsletter mails each Monday, delivering AutoCAD tips from readers -- all reviewed by Cadalyst's volunteer Tip Patrol. Plus, you'll also receive a rundown of new online CAD resources, deals and freebies, the past week's new CAD-related hardware and software products, and more. View the archives and subscribe today!