We want to make creating a drawing with Autocad fun and exciting! So let’s go! The code supplied includes commands for copying from and to text or attributes, exporting text, a clipboard, and simple math. Pasteblock is a command that pastes the clipboard contents as a block with a name provided by Autocad. We define the same command to insert the block and store the block’s name in a variable ‘bname’. Additional commands include picking text parameters from existing text, and getting scale factors from two circles, two lines, or two text entities.
The variables for dimscale ‘ds’, distance ‘d’, degrees ‘a’, precision ‘pc’, linetype factor ‘ltf’, color ‘col’, block name ‘bname’, and scale factor ‘sf’ are used to expedite commands. [an error occurred while processing this directive] Autocad’s commands remain unchanged, except c:c the Circle command has been replaced by c:cr the new Circle command, and c:ta the Tablet command has been replaced by c:tab the new Tablet command. We have redefined c:c to Copy and c:ta to Type Text Again To New Parameters, because while drawing, most of the time we copy many more times than do we draw circles.
After loading the code the command c:mla1 will create layers named center, dim, hatch, hidden, and text. With the command c:mla you can create layers named 0 through 9.
1. Some commands leave the drawing in either architectural units or in decimal units. c:ah restores architectural units and c:dec restores decimal units.
2. Text height needs to be set for many of the commands that we use. To reset it to zero use c:ht0. Text height is set to a value other than zero for commands that type text on the screen, for example, c:rf Read File, and c:tya Type ‘d’ Architectural.
3. When setting text height with c:ht, to view exact height in decimal units first use c:dec to set decimal units.
4. Unable to suppress “Unknown Command... Press F1 for Help.” in some commands. The same is true for Autocad’s prompts following the pedit commands in c:jl Join Last Line, or c:jp Join Lines, Pick.
5. Code from Article: “Simple and Effective Autolisp for Autocad Users” is included with code for this article.
6. One way to draw a line at angle ‘a’.
1. Set angle ‘a’ with c:de.
2. Set snapangle with c:ssa.
3. Draw line with Autocad’s line command c:L.
4. Reset snapangle with c:1.
7. Lines have two insert points. To distinguish between the two we will call the start point of the line as being the “first” insert point, and the other end of the line the “second” insert point. Also, any text that has justification other than left justified text has two insert points: 1. The “first” insert point is the left justification point, and 2. Another justification point (for example, for mid justified text or for right justified text) that we are calling the “second” insert point. Left justified text has only the “first” insert point as do inserts, polylines, circles, arcs, and many more that you can think of.
8. It is not possible to undo Autolisp changes to variables that you make. An example is undoing a change to variable ‘bname’ that you have made with the command c:reb.
9. You may change values that are set in the code to suit your needs. An example is the variable ‘ltf’. Just search the code with any text editor for: “(setq ltf” (at the beginning of the code, not elsewhere). Now, change the 0.375 value following the characters “ltf” to, say, 0.5. Now, when you load this code in any drawing you will have the variable ‘ltf’ equal to 0.5.
Similarly, you can change the commands that are defined. With your editor just search for, say, “(defun c:ttl”. Now, change “ttl” to, for example, “ctl”.
Now, the Copy To Layer command works when at Autocad’s command prompt you enter “ctl” followed by an enter. Yes, you must load the code again for the change to occur!
10. After starting a command (that is, typing the command at Autocad’s command prompt and following it with an enter), if there is nothing else visible at the command prompt use c:1 to restore the command echo variable (cmdecho) to 1 or on. Now, restart your command.
Use with caution!
Click here to download the Autolisp
Subodh Nehra can be contacted at firstname.lastname@example.org
Related sites: Digital CAD
[an error occurred while processing this directive]