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. |
Hatch Maker |
|
|||||||||||||||||||||
Our last tip of the month is Hatch Maker (Tip #2065) from Lanny Schiele. Hatch Maker is a nifty utility for creating hatch patterns. If you have tried to create a hatch pattern by hand, you know that it's not that easy to make anything interesting. Lanny just changed that for you. Load the LSP file and type DrawHatch at the AutoCAD Command line to start things up. This function prepares a drawing area and sets the grid snap mode in AutoCAD for creation of a hatch pattern. Draw lines and points to make up the hatch pattern cell. When you are finished, type SaveHatch and follow the directions on screen to create a custom PAT file. Harry was quite taken with this routine and gave it double thumbs up. I think I know why (figure 2). Thanks, Lanny!
|
|||||||||||||||||||||
Remove Extra Spacing from Imported Mtext |
|
|||||||||||||||||||||
Cara Nash Snyder sent us this useful AutoCAD tip for fixing paragraph spacing in pasted text: Have you ever pasted formatted text into AutoCAD MText from another application (such as Microsoft Word) and found that the spacing is off? You try to adjust the line spacing, but that doesn’t fix it. If so, you can easily fix it by activating the MText editor, highlighting the text, and right-clicking. In the right-click menu, select Paragraph. Next, check Paragraph Spacing, and set the values to 0. This will remove the embedded formatting from the other application.
Notes from Cadalyst tip reviewer R.K. McSwain: Pasting text from other applications can be frustrating sometimes because unwanted formatting can come along with it. You might want to keep certain properties such as font and color, but remove other formatting. This is a good tip for removing unwanted paragraph spacing that may be applied to pasted text. |
|||||||||||||||||||||
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. |
Sort text |
|
|||||||||||||||||||||
Editor's Note: To download this LISP file, do not use the "Download This Tip" button; instead, visit this link: http://www.cadalyst.com/cadalyst/sortlsp-17285
|
|||||||||||||||||||||
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. |
Make New Objects with Existing Objects' Properties |
|
|||||||||||||||||||||
Frequent contributor Kent Cooper is back this month with another new and improved routine. Kent’s inspiration for this function is a 2008 Cadalyst CAD Tip from Mosad H. Elewa, titled "Make More Of The Same." The purpose of this routine is to allow you to create a new object in AutoCAD that's based on the properties of a selected object. For example, if you select a text entity, the Text command will be initiated with the properties of the selected text object (layer, style, etc.) set current so you can start drawing a new line of text with the same properties as the selected string. This routine is very similar to the built-in AutoCAD command named AddSelected, except that this routine has more options for certain objects. If you select a linear dimension, for example, you have the option to create a new dimension, a continued one, or a series of baseline dimensions. To get started, load the LISP file and type in the command MM. Pick any drawing object, and the command to draw that object will be launched. Kent authored this routine using AutoCAD 2004, so entity types newer than that are not supported; however, the properties of the selected object are still set current. This is a fairly complex routine, but as always, Kent’s code contains plenty of helpful comments and other tips. The noteworthy change is that it now works in noun-verb operation. If one object is pre-selected when the command name MM is typed in, it uses that object without asking the user to select something. If multiple objects are selected, it un-selects them and then asks the user to select one object as it did before (and of course still does when nothing is pre-selected). |
|||||||||||||||||||||
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. |
Edit Any Type of Text |
|
|||||||||||||||||||||
Jim Himes has resurrected an old LISP routine from the Cadence magazine days. This routine allows you to edit any sort of text with one command. If you are using a recent version of AutoCAD, then you may know that the built-in DDEdit command also has this capability, but there are still many people who use older versions of AutoCAD where this can come in handy. |
|||||||||||||||||||||
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. |
Detach Xrefs in Hurry |
|
|||||||||||||||||||||
an AutoLISP routine that detaches xrefs by selecting them. |
|||||||||||||||||||||
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. |
Rotate AutoCAD's UCS |
|
|||||||||||||||||||||||||||||||||||||||
Rowen Delaforce e-mailed a request to rotate the UCS (user coordinate system) by selecting an object even if that object is part of a block or xref. He wanted to include polyline segments and lines that may or may not be part of a block. The UCS rotation lets you place dimensions with the text facing from left to right. My solution is UCS-ROT.LSP, which automatically rotates the UCS after you pick a single object. The object must be a line, polyline, or lwpolyline. Any of these objects can be part of a block or xref, regardless of how deeply the object is nested in the block. I tested the program in AutoCAD 2000, but it should work in all versions back to Release 12 because I used only AutoLISP functions that appear in Release 12. How to use UCS-ROT.LSP
Download the file and save it in your support directory for AutoCAD 2000. Load the program with AutoCAD's Tools|Application menu. AutoCAD prompts you to enter UCR to start the program. Next, the prompt shown in figure 1 appears: Select a line or polyline. The object snap is set automatically to Nearest for the selection. You should pick a line or polyline segment (even if it is part of a block); otherwise the routine displays: You must select a line or polyline, try again.
Once you select a suitable object, the UCS icon rotates as shown in figure 2. If you select an arc segment of a polyline or lwpolyline, an alert box appears (figure 3), but the UCS still rotates to line up with the start and end points of the arc segment. Programming notes
To solve the problem with only one user pick is considerably more involved, especially if you select lwpolylines. The old-style polylines are easy to handle if you use (nentselp) for the selection, because (nentselp) returns the entity type VERTEX. The function (do-vertex) takes the selected vertex entity and uses (entnext) to find the next vertex. The required angle is simply the angle between these two vertices. If the selected vertex is the last one in the polyline, the next entity is the (sequend) entity. It's a simple matter to extract the name of the header polyline and use (entnext) on it to find the first vertex of the polyline. The code to do this is:
Note that this code also checks for arc segments and notifies you of any found. If the selected entity is part of a block, the routine finds the combined angle of all of the nested blocks and adds it to the entity angle. The (do-block) function finds this angle as follows:
An lwpolyline is complicated to deal with in this context because the routine can't identify any single vertex as an entity. You must obtain a list of vertices and test each pair to determine that the pick point lies on the segment. This is further compli cated if the entity is part of a block. The data returned by (nentselp) contains the pick point and the matrix that relates the position and orientation of the nested lwpolyline entity with respect to the WCS (world coordinate system). Use of that matrix is somewhat lengthy, so I used a simple translation and rotation to relate the picked point of the nested entity to that of the block table definition of the entity. The base point of blocks in the block table is at zero, so the translation distance is simply the distance between the block reference insertion point and zero. The picked point is at some angle alpha with respect to the block reference insertion point. The routine subtracts the block rotation angle from the alpha angle to place the picked point on the correct segment of the lwpolyline as defined in the block table. |
|||||||||||||||||||||||||||||||||||||||
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. |
Spur Gear Updated |
|
|||||||||||||||||||||
This month, I was spurred to return to a spur gear program that first appeared for AutoCAD Release 14. In response to requests, particularly from John Hurlburt, to update the routine for AutoCAD 2004/2005, I added a dialog box and corrected some compatibility problems to make SPURGEAR.LSP run in all versions of AutoCAD from 2000 onward. You supply the pitch diameter, number of teeth, and pressure angle using the Spurgear dialog box (figure 1). The program draws the gear in the image tile, showing the number of teeth for a quick reference. The default first-session values are shown as 4" PCD, 12 teeth, and a 14.5-pressure angle. These values are updated so the spur gear data becomes that of the prior entries.
|
|||||||||||||||||||||
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. |
New LISP Template |
|
|||||||||||||||||||||
Tipster Derek Beals says he and a buddy use this template when creating a new LISP routine. "The template includes all these cool little non-LISP functions we have come up with, so we don't have to physically load them every time — functions such as Tangent, Squaring a number, Fixx (opposite of fix), and probably my favorite non-LISP function, Getarc." Update 4/26/10: Derek Beals has submitted an updated file; new version attached for download. |
|||||||||||||||||||||
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. |
Rotating Annotation |
|
|||||||||||||||||||||
Editor's note: Please see an update to this tip titled Automatically Draw Arrowheads on Circles and Arcs. Rotating Annotation (Tip #2123) from William J. Townsend is a good example of a dimensioning utility. Load the LSP file into AutoCAD and type RT1 to add a rotational arrow and arc to an existing circle or arc object in your drawing. When RT1 starts it asks you select an arc or a circle. Next, it asks for the direction point (end of the arrow tip). This angle is where the annotation for the rotation starts. Next, specify where the annotation is to be drawn relative to the input object (inside or outside). The distance between the original object and the annotation is half the dimension text height. It then requests the extent of the rotation (full or partial) and the direction (clockwise or anticlockwise). An annotation based on the input parameters is then drawn on the Rotation layer. This routine is handy for anyone who needs to show the rotation of a shaft (represented by a circle) or some other mechanical device.
|
|||||||||||||||||||||