AutoCAD

    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
Tip# 2065 By Lanny Schiele On 01-Oct-2005
4.75
Rated By 4 users Downloaded : 38498
Categories : Patterns
Software type : AutoCAD
Rename File To : Tip2065: HatchMaker.lsp
Routine to automatically create hatch patterns.
Related CAD Tips

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
Tip# 4269 By Cara Nash Snyder On 10-Mar-2014
4
Rated By 1 users
Categories : Multiline Text
Software type : AutoCAD
Rename File To : No Files to download.
This is a good tip for removing unwanted paragraph spacing that may be applied to pasted text.
Related CAD Tips

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
Tip# 1992 By Tracy Coles On 01-Nov-2004
5
Rated By 1 users Downloaded : 938
Categories : Notes/Text
Software type : AutoCAD
Rename File To : HTH1992.lsp
Sort Text lets you select a group of text objects, and then sort them into alphabetic order (SORT.LSP).
Related CAD Tips

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

Our next tipster, Tracy Coles, submitted two excellent tools, Sort Text (Tip #1992) and Add Text Up (Tip #1993). Sort Text lets you select a group of text objects to sort into alphabetic order. The sorted text is output as new text objects in a column. You select the location of the new text at the beginning of the routine and then select the text objects to be sorted. The sorted text is displayed at the location provided earlier.

 

 
    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
Tip# 3935 By Kent Cooper On 17-Jul-2012
5
Rated By 1 users Downloaded : 1187
Categories : Object Properties, Match Properties, Linear Objects, Curved Objects
Software type : AutoCAD
Rename File To : MakeMore.LSP
This routine is very similar to the built-in AutoCAD command named AddSelected.
Related CAD Tips

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.

Update, July 2012: The author provided an updated version of the tip; see comments as follows:

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
Tip# 3605 By Jim Himes On 25-Mar-2011
4
Rated By 1 users Downloaded : 575
Categories : Multiline Text, Single-Line Text, 2D Editing
Software type : AutoCAD
Rename File To : DDE/,DDE/DDE.DCL,DDE/DDE.LSP
Edit any sort of text with one command.
Related CAD Tips

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.

This routine includes a DCL file to support a dialog, so you will need to place both files in a directory that is in your support file search path. Load the LISP file, then run the command DDE. You can select an attribute definition, an attribute (or a block with an attribute), text, mtext, or a dimension, and the appropriate editing command will be launched. Be careful with certain dimensions such as aligned dimensions; the dialog warns that the value shown will not be accurate.

 
    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
Tip# 1165 By Murray Clack On 01-Nov-1995
4
Rated By 1 users Downloaded : 246
Categories : DWG
Software type : AutoCAD
Rename File To : TIP1165.LSP
an AutoLISP routine that detaches xrefs by selecting them.
Related CAD Tips

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
Tip# 3466 By Tony Hotchkiss On 01-May-2001
4
Rated By 1 users Downloaded : 549
Categories : CUI (Customize User Interface)
Software type : AutoCAD
Rename File To : UCS-ROT.lsp
Automatically rotate the UCS after you pick a single object.
Related CAD Tips

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

Figure 1. UCS-ROT.LSP asks you to select an object.

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.


Figure 2. Then the routine rotates the UCS icon.

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
Rowen Delaforce had already discovered that it's relatively simple to do this job if you make two picks. Just pick the endpoints of any line or poly-line segment, then find the angle between those points. This works regardless of whether a block reference is involved.

Figure 3. The routine alerts you if you select an arc segment.

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:
(setq en1 (nth 0 edata) ; search for next vertex

v1 (dxf 10 en1)
en2 (entnext en1)
en2typ (dxf 0 en2)
) ;_ setq
(if (= en2typ "SEQEND")

(progn

(setq pname (dxf -2 en2)

v2 (dxf 10 (entnext pname))

) ;_ setq

) ;_ progn

(setq v2 (dxf 10 en2))

) ;_ if
(setq bulg (dxf 42 en1))
(if (/= 0.0 bulg)

(alert "POLYLINE segment is an arc")

 

) ;_ if
(setq ang (angle v1 v2))

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:

(defun do-block (edat / bnlist blen i insname ang)
(setq bnlist (nth 3 edat)

blen (length bnlist)

inspoint (dxf 10 (nth (1-blen) bnlist))

i 0

angtot 0.0

) ;_ setq
(repeat blen

(setq insname (nth i bnlist)

ang (dxf 50 insname)

angtot (+ angtot ang)

i (1+ i)

) ;_ setq

) ;_ repeat
angtot
) ;_ do-block


The data returned by (nentselp) contains a list of all nested blocks that include the selected entity. That list is used in the above repeat loop to produce the total angle.

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
Tip# ALSPSOL By Tony Hotchkiss On 01-Sep-2004
1
Rated By 1 users Downloaded : 1761
Categories : Standard Blocks
Software type : AutoCAD
Rename File To : spurgear.dcl, Spurgear.lsp
Updated spur gear routine includes a dialog box and improved AutoCAD compatibility.
Related CAD Tips

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.

Get the Code
Download the SPURGEAR.LSP and SPURGEAR.DCL files and save them in AutoCAD's Support directory. Use the
Appload facility by selecting Tools / Load Application. Then select the SPURGEAR.LSP program from where you stored the downloaded files.







 

 
    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
Tip# 3396 By Derek Beals On 01-May-2006
4
Rated By 1 users Downloaded : 779
Categories : Programmer's Tools
Software type : AutoCAD
Rename File To : New Lisp Template.lsp
A template for use when creating a new LISP routine.
Related CAD Tips

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
Tip# 2123 By William Townsend On 01-Jun-2006
4
Rated By 1 users Downloaded : 244
Categories : Notes/Text
Software type : AutoCAD
Rename File To : Tip2123: rotation.lsp
Show the rotation of a mechanical device.
Related CAD Tips

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.

 

 
Syndicate content