AutoCAD linetype customizing facilities, part two1 Oct, 1999 By: Bill Fane
It was a warm Friday morning, a perfect day for Grampa LearnCurve and his gorgeous wife to celebrate their 33rd wedding anniversary. Suddenly the phone rang. Its time, shouted their son-in-law. Whats with the Grampa LearnCurve bit? Yes, campers, Captain LearnCurve is a grandfather. Rebecca Nicole Milne, 8lb. 12oz., born July 9, 1999.
Last month we covered
AutoCADs various noncontinuous linetype styles. Sometimes the 45
available styles arent appropriate, so you learned how to define
Excuse me, last month you promised to discuss linetypes that include text and symbols. I need a linetype that indicates hot water supply in a piping diagram.
Not a problem. Just
issue either the Layer or Linetype command and load in the Hot_water_supply
linetype. To read last months
article on how to load a linetype.
Hold it! I also need linetypes for cold water and drains and compressed air and gas and. . .
Oh, all right, Ill
teach you how to create other linetypes that have text in them. Autodesk
introduced complex linetypes in Release 13.
Last month we learned that AutoCAD holds linetype definitions in external files with an LIN extension.
You can create and edit these files with any standard text editor such as Notepad. By default, Release 14 holds its standard linetype definitions in a file called C:\Program files\ \Support\acad.lin.
Note that Release 13 keeps the complex linetype definitions in a separate file called ltypeshp.lin, but the principles and procedures are exactly the same. In fact, you can easily cut and paste the complex linetype definitions from ltypeshp.lin into acad.lin.
You can create your own file or you can edit the standard one. If you choose the latter course, remember rule number 2: Always keep a safe copy of the original file before you modify it. Rule number 1 is Never break rule number 2. Rule number 3 is: The original files are available on the installation CD-ROM when you dont obey rules 1 and 2.
definitions with text
Before we begin, I must note a couple of points about linetype definitions. Once you load a linetype into a drawing, it is saved with the drawing. This means that if you send a drawing to other users, they dont need your linetype definition file.
The other side of the coin is that if you change the definition of a linetype, you must then manually reload it back into the drawing. Thus, if you experiment with the changes we are about to discuss below, you must use the Linetype command to load in your changes each time and then Regen to see the changes.
When you open your
copy of acad.lin, you see the definition for Hot_water_supply:
*HOT_WATER_SUPPLY,Hot water supply
HW HW HW
A,.5,.2,[HW,STANDARD,S=.1, R=0.0, X=-0.1,Y=-.05],-.2
The first line includes
the name of the linetype up to the comma. The rest of the first line is
the descriptive text that appears in the Linetype dialog box. The Release
14 and 2000 Linetype dialog boxes also have an Appearance field that shows
a quick translation of the linetype definition.
Figure 1. Here are two sample sections of the linetype, along with a copy of the linetype definition. The red leaders show which portions of the linetype definition control what.
The second line (shaded
above) contains the meat of the definition. A comparison with a regular
noncontinuous definition shows many similarities. For example, it must
always start with an A, and commas separate line segment definitions.
Positive values indicate pen down, or visible, segments. Negative values
define pen up, or gap, segments. For best results, a linetype definition
should end with a pen-up segment. In our example (figure 1), the line
starts with a segment 0.5 units long followed by a gap of 0.2 units,
then a bunch of stuff that well come back to, and another gap of 0.2 units. The pattern then repeats as necessary.
The only difference
in a complex linetype definition appears in the section between the square
Once again, the definition is divided into sections by commas. HW specifies the exact text that appears spaced down the line. It is case-sensitive.
Standard is the text
style name. You can specify any text style that currently exists in the
drawing. Note that the text style must also exist in any other drawing
into which you want to load the linetype.
Everything else is optional and defaults to zero if you omit it.
S=xx specifies a size or a scale factor for the text. If the specified text style has a size of zero, S=xx specifies the exact size of the text. If the specified style has a size greater than zero, S=xx defines a scale factor by which the text style size is multiplied. Note that LTSCALE multiplies the sizes of all the segment and gap lengths and further scales the text size.
R=xx specifies the rotation angle of the text relative to the line segments as you draw them. Our example of zero aligns the text parallel to the line segments. The text in a line segment that is drawn right to left is upside down compared to a line segment drawn left to right. If you use A=xx instead of R=xx, the text alignment is always absolute relative to the origin. A=0 means that the text always remains horizontal.
X=xx is a horizontal
offset distance for the start of the text. The example X=
-0.1 moves the start of the text 0.1 units back into the preceding line segment, which in our case is 0.2 units long. To achieve the same effect, set the preceding gap length to 0.1 and then set x=0 (or omit it).
Y=xx is a vertical offset distance for the text. The text normally aligns from its lower left corner. If you want to center it in the complex linetype, give it a negative value equal to half the text height. This can get a little messy because it is not scaled by the S=xx factor (but it is scaled by LTSCALE). You usually get the best and most consistent results by using a text size of zero for complex linetypes, even if this means creating a special text style just for this use.
The only other slightly gnarly bit with regard to text placement is conveniently forgotten by AutoCADs documentation. AutoCAD doesnt automatically calculate the length of space required for the text from the specified characters. You must define it yourself. In our example, if you change HW to HOT, the T crowds the start of the next pen-down line segment. Changing the font specified for the text style also has an impact.
to the bunch of stuff
Lets go back to the definition of the line segments. As we saw, the example line starts with a pen-down segment 0.5 units long followed by a pen-up segment 0.2 units long. This point defines the start of the text, but it also defines the start of the next line segment. In the example, the last line segment is a pen-up section 0.2 units long. If you put more or less text in the line or change fonts, you must adjust this final pen up segment accordingly. Take a look at the Gas line definition in acad.lin. Note how the last pen-up segment is 0.25 long instead of 0.20 to allow for the extra character in GAS.
The problem is compounded because an i is typically narrower than an m, and the specific character widths depend on the font. You usually need to experiment a bit to get the desired result for a specific text message.
Complex linetype definitions that include text most commonly identify the various lines in flow and schematic diagrams and the contour lines on maps. But I am sure a lot more applications are lurking out there.
Complex linetype definitions also let you include custom shape symbols. Come back next time when I show you how.
now for something completely different
Household pets, dogs in particular, can get jealous when you bring a new baby home from the hospital. To help ease the introduction, bring home a blanket that the baby has used so the dog gets used to the smell.
In her easy-to-follow, friendly style, long-time Cadalyst contributing editor Lynn Allen guides you through a new feature or time-saving trick in every episode of her popular AutoCAD Video Tips. Subscribe to the free Cadalyst Video Picks newsletter, and we'll notify you every time a new video tip is published. All exclusively from Cadalyst!