Sei sulla pagina 1di 89

Published by CFS Documentation cell

Division of Centre for Electronics Design and Technology of India


A Scientific Society of Department of Electronics,
Govt. of India,
New Delhi.

First Edition: 1999

TRADE MARKS: All brand name and product names mentioned in this book are trade marks or registered trade mark of
their respective companies.

Every effort has been made to supply complete and accurate information. However, CEDTI assumes no responsibility for its
use, nor for any infringement of the intellectual property rights of third parties which would result from such use.

No part of this publication may be stored in a retrieval system, transmitted or reproduced in any forms or by any means,
electronic, photocopy, photograph, magnetic or otherwise, without written permission of CEDTI.

CEDTI/CFS/99/4/5.2/R1
FOREWORD

The Information Technology and Telecom sectors have suddenly opened up avenues, which require a very
large specially trained manpower. These sectors are highly dynamic and need training and re-training of manpower
at a rapid rate. The growing gap of requirement of the industry and its fulfilment has created a challenging situation
before manpower training institutes of the country. To meet this challenge most effectively, Centre for Electronics
Design and Technology of India (CEDTI) has launched its nation-wide franchising scheme.

Centre for Electronics Design and Technology of India (CEDTI) is an Autonomous Scientific Society under
the Govt. of India, Department of Electronics with its Headquarters at New Delhi. It operates seven centres located
at Aurangabad, Calicut, Gorakhpur, Imphal, Mohali, Jammu and Tezpur. The scheme will be implemented and
coordinated by these centres.

The scheme endeavours to promote high quality computer and information technology education in the
country at an affordable cost while ensuring uniform standards in order to build a national resource of trained
manpower. Low course fees will make this education available to people in relatively small, semi urban and rural
areas. State-of-the-art training will be provided keeping in view the existing and emerging needs of the industrial
and Govt. sectors. The examinations will be conducted by CEDTI and certificates will also be awarded by CEDTI.
The scheme will be operated through all the seven centres of CEDTI.

The CEDTI functions under the overall control and guidance of the Governing Council with Secretary,
Department of Electronics as its Chairman. The members of the council are drawn from scientific, government and
industrial sectors. The Centres have separate executive committees headed by Director General, CEDTI. The
members of these committees are from academic/professional institutes, state governments, industry and
department of electronics.

CEDTI is a quality conscious organisation and has taken steps to formally get recognition of the quality and
standards in various activities. CEDTI, Mohali was granted the prestigious ISO 9002 certificate in 1997. The other
centres have taken steps to obtain the certification as early as possible. This quality consciousness will assist
CEDTI in globalizing some of its activities. In keeping with its philosophy of ‘Quality in every Activity’, CEDTI will
endeavour to impart state of the art – computer and IT training through its franchising scheme.

The thrust of the Software Courses is to train the students at various levels to carry out the Management
Information System functions of a medium sized esTablishment, manufacture Software for domestic and export
use, make multimedia presentations for management and effectively produce various manufacturing and architectural
designs.

The thrust of the Hardware Courses at Technician and Telecommunication Equipment Maintenance Course
levels is to train the students to diagnose the faults and carry out repairs at card level in computers, instruments,
EPABX, Fax etc. and other office equipment. At Engineer and Network Engineer levels the thrust is to train them
as System Engineers to instal and supervise the Window NT, Netware and Unix Networking Systems and repair
Microcontrollers / Microprocessor based electronic applications.
An Advisory Committee comprising eminent and expert personalities from the Information Technology field
have been constituted to advise CEDTI on introduction of new courses and revising the syllabus of existing
courses to meet the changing IT needs of the trade, industry and service sectors. The ultimate objective is to
provide industry-specific quality education in modular form to supplement the formal education.

The study material has been prepared by the CEDTI, document centre. It is based on the vast and rich
instructional experience of all the CEDTI centres. Any suggestions on the improvement of the study material will
be most welcome.

(R. S. Khandpur)
Director General (CEDTI)
Customization Basics

A
uto CAD is a general- Purpose drafting system designed with an open architecture, so you can
customize and extend its many features. As a result, you can expand and shape AutoCAD according
to your needs.

¾ Run applications and utilities from within Auto CAD.


¾ Create aliases for frequently used commands.
¾ Create on-line help files for your in-house procedures and applications.
¾ Create your own menus.
¾ Automate repetitive tasks.
¾ Create automated “slide” shows for presentations.
¾ Redefine or disable AutoCAD commands.
¾ Create your own applications and dialog boxes.

The ACAD.PGP File.


Auto CAD software come with the program parameter file ACAD, PGP which defines aliases for the
operating system commands and some of the AutoCAD commands, when you install ACAD, this file is
automatically copied to the support subdirectory. The ACAD .PGP file lets you access the operating system
commands from the drawing editor. This file has command aliases of some frequently used Auto CAD
commands.

; AutoCAD External Command and Command Alias definitions.


; External Command format:
; <Command name>,[,DOS request >],<Memory reserve>,[*]<Prompt>,
; Examples of external Commands for DOS
; For Windows NT Add START before all items to prevent locking AutoCAD

CATALOG, DIR/W, 0, File specification:,


DEL, DEL, 0, File to delete:,
EDIT, DIR, 0, File specification:
EDIT, START EDIT, 0, File to edit;
SH, , 0, *OS Command:
SHELL, , 0, *OS Command:,

START, START, 0, *Application to start:,


TYPE, TYPE, 0, File to list:,
CALC, START CALC, 0,,
EXPLORER, START EXPLORER, 0,,
NOTEPAD, START NOTEPAD, 0, *File to edit:
PBRUSH, START PBRUSH, 0,,

; Command alias format:


; <Alias>,*<Full command name>
; The following are guidelines for creating new command aliases.
; 1. Try the first character of the command, then try the first two , then the first three.
; 2. Ignore “DD” at the beginning of command.
; 3.Abbreviate the following prefixes:
; 3 for 3D, A for ASE, D for Dim, I for Image , R for render.
; 4. Once an alias is defined, add suffixes for related aliases:
; R for Redraw, RA for Redrawall.
; 5. Exceptions are T for Dtext, X for Explode.
; 6. An alias should reduce a command by at least two characters.

1
; 7. Command s with a control key equivalent, status bar button, or function key
; do not require a command alias.
; 8. Use a hyphen to differentiate between command line and dialog box commands
; Sample aliases for Auto CAD Commands
; These examples include most frequently used common

3F, *3DFACE
A, *ARC
AL, *ALIGN
AR, *ARRAY
AAD, *ASEADMIN
AEX, *ASSEXPORT
ALI, *ASELINKS
ASQ, *ASESQLED
ARO, *ASEROWS
ASE, *ASESELECT
AT, *DDATTDEF
ATE, *DDATTE
B, *BMAKE
BO, *BOUNDARY
BR, *BREAK
C, *CIRCLE
CH, *DDCHPROP
-CH, *CHANGE
CHA, *CHAMFER
COL, *DDCOLOR
CO, *COPY
D, *DDIM
DAL, *DIMALIGNED
DAN, *DIMANGULAR
DBA, *DIMBASELINE
DCE, *DIMCENTER
DCO, *DIMCONTINUE
DDI, *DIMDIAMETER
DED, *DIMEDIT
DI, *DIST
DIV, *DIVIDE
DLI, *DIMLINEAR
DO, *DONUT
DOR, *DIMORDINATE
DOV, *DIMOVERRIDE
DR, *DRAWORDER
DRA, *DIMRADIUS
DST, *DIMSTYLE
DV, *DVIEW
E, *ERASE
ED, *DDEDIT
EL, *ELLIPSE
EX, *EXTEND
EXIT, *QUIT
EXP, *EXPORT
EXT, *EXTRUDE
F, *FILLET
G, *GROUP
GR, *DDGRIPS
H, *BHATCH

2
HE, *HATCHEDIT
HI, *HIDE
I, *DDINSERT
IAD, *IMAGEADJUST
IAT, *IMAGEATTACH
ICL, *IMAGECLIP
IIM, *IMAGE
IM, *IMPORT
IN, *INTERFERE
INS, *INSERTOBJ
INT, *INTERSECT
L, *LINE
LA, *LAYER
LE, *LEADER
LEN, *LENGTHEN
LI, *LIST
LT, *LINETYPE
LTS, *LTSCALE
M, *MOVE
MA, *MATCHPROP
ME, *MEASURE
MI, *MIRROR
ML, *MLINE
MO, *DDMODIFY
MS, *MSPACE
MT, *MTEXT
MV, *MVIEW
O, *OFFSET
OS, *DDOSNAP
P, *PAN
PA, *PASTESPEC
PE, *PEDIT
PL, *PLINE
PO, *POINT
POL, *POLYGON
PR, *PREFERENCES
PRE, *PREVIEW
PS, *PSPACE
PU, *PURGE
Q, *QUIT
R, *REDRAW
RA, *REDRAWALL
RE, *REGEN
REA, *REGENALL
REG, *REGION
REN, *DDRENAME
REV, *REVOLVE
RM, *DDRMODES
RO, *ROTATE
RPR, *RPREF
RRE, *RENDER
S, *STRETCH
SC, *SCALE
SCR, *SCRIPT
SE, *DDSELECT
SEC, *SECTION

3
SET, *SETVAR
SHA, *SHADE
SL, *SLICE
SO, *SOLID
SP, *SPELL
SPL, *SPLINE
SPE, *SPLINEDIT
ST, *STYLE
SU, *SUBTRACT
T, *DTEXT
TA, *TABLET
TH, *THICKNESS
TO, *TOOLBAR
TOL, *TOLERANCE
TOR, *TORUS
TR, *TRIM
UC, *DDUCS
UCP, *DDUCSP
UN, *DDUNITS
UNI, *UNION
V, *DDVIEW
VP, *DDVPOINT
W, *WBLOCK
WE, *WEDGE
X, *EXPLODE
XA, *XATTACH
XC, *XCLIP
XL, *XLINE
XR, *XREF
Z, *ZOOM

SHAPES

Shapes are objects that are used in a manner similar to blocks. To use a shape, you first use the LOAD
command to lead the complied shape file containing the shape definition. Then you use the SHAPE
command to insert shapes from this file into your drawing. You can specify the scale and rotation to use for
each shape as you add it to your drawing. AutoCAD Text fronts and shapes are defined in the same way.

Blocks are more versatile and easier to use and apply than shapes. However, shapes are more efficient for
AutoCAD to store and draw. User-defined shapes are helpful when you musts insert a simple part many time
and when speed is very important.

SHAPE DESCRIPTION

Each line in a shape definition file can contain up to 128 characters. Longer line cannot be complied.
AutoCAD ignores blank lines and text to the right of a semicolon. The semicolon provides the ability to
embedded comments in shape definition files.

Each shape description has a header line of the following form and is followed by one or more lines
containing specification bytes, separated by comma and terminated by a 0.

*shape number, defbytes, shapename

4
specbytel, specbytec2, specbytec3,……..,0
The following describes the fields of a shape description:

Shapenumber

A number, unique to the file, between 1and 258, and preceded by an asterisk (*). Every shape in a shape file
must have a number (number 256, 257,and 258 are for the symbolic identifier Degree Sign, Plus Or Minus
Sign, and Diameter Symbol).Text fronts (files containing shape definitions for each character) require
specific numbers corresponding to the value of each character in ASCII code; other shapes can be assigned
any number.
defbytes
The number of data bytes (specbytes) required to describe the shape, including the terminating zero.
.Thelimit is 2,000 bytes per shape.

Shapename
The shape name. Shape names must be upper case to be recognized. Names with lower case characters are
ignored and are usually used to label font shape definitions.

Specbyte
A shape specification byte. Each specification byte is a code that defines either a vector length and direction
or one of a number of special codes. A specification byte can be expressed in the shape difinition file as
either a decimal or hexadecimal value. This section uses both decimal and hexadecimal specification byte
values for its examples (as do many of the shape definition files). If the first character of a specification byte
is a 0 (zero ), the following two characters are interpreted as hexadecimal values.

A simple shape specification byte contains vector length and direction encoded into one specification byte
(one specbyte field ). Each vector length and direction code is a three character string. The first character
must be a 0, which indicates to AutoCAD that the next two characters are interpreted as hexadecimal values
range from 1(one unit long) through F (15 units long).The third character specifies the direction of the
vector.The following figure illustrates the direction codes.
5
4 3
6 2
1
7 0

8
F
9

A B D E
C

Vector direction codes


All the vectors in the preceding figure were drawn with the same length specification. Diagonal
vectors stretch to match the X or Y displacement of the closest orthogonal vector. This is similar to
the action of the snap grid in AutoCAD.

The following example constructs a shape named DBOX with an arbitrarily assigned shape number of 230.

5
*230, 6,DBOX
014, 010, 01C, 018, 012, 0

The preceding sequence of specification bytes defines a box one unit high by one unit wide, with a
diagonal line running from th4/13/98e lower-left corner to the upper-right corner. After saving the
files as dbox.shp use the COMPILE command to generate the dbox. Shx file .Use the SHAPE
command as follows:
Command: SHAPE
Name (or?): DBOX
Starting Point: 1,1
Height< Current>:2
Rotation angle<current> :0
The resulting shape is shown in the following illustration.
010

014 01C

018
In addition to defining Vectors, a specification byte can use the following special codes to create additional
forms and specify certain action. To use a special code, the second character of the three character string (the
Vector length specification) must be 0, or you can specify only the code number (for example, 008 and 8 are
both valid specifications).

Specification byte codes


Code Description
000 End of shape definition.
001 Activate Draw mode (pen down)
002 Deactivate Draw mode (pen up)
003 Divide vector lengths by next byte
004 Multiply vector lengths by next byte
005 Push current location from stack
006 Pop current location from stack
007 Draw subshape number given by next byte
008 X-Y displacement given by next two byte
009 Multiple X-Y displacements, terminated (0,0)
00A Octant arc defined by next two bytes
00BFractional arc defined by next five bytes
00C Arc defined by X-Y displacement and bulge
00D Multiple bulge-specified arcs

Code 0: End of shape


Code 0 marks the end of the shape definition.

Codes 1 and 2: Draw Mode Control


Codes 1 and 2 control Draw mode. Draw is activated at the start of each shape. When Draw mode is turned
on, the vectors cause lines to be drawn. When Draw mode is turned off, the vectors move to a new location
without drawing.

Codes 3 and 4: Size Control


Codes 3 and 4 : Size Control the relative size of each Vector. The height specified with the SHAPE
command is initially considered the length of a single orthogonal vector (directions 0, 4, 8, or C). Codes 3
and 4 are followed by a specification byte containing an integer scale factor (through 255). If you want the

6
shape height to specify the size of the entire shape, and you use 10 vector lengths to draw it, you can use 3,10
to scale the height specification. The scale factor is cumulative within a shape; that is, multiplying by 2 and
again by 6 results in a scale factor of 12. Usually you will want to reverse the effect of your scale factors at
the end of the shape , especially for subshapes and text font shapes. Auto CAD does not reset the scale factor
for you.

Codes 5 and 6: Location Save/Restore


Codes 5 and 6 push (save)and pop (restore) the current coordinate position while drawing a shape so that you
can return to it from a later point in the shape. If the stack overflows because of too many pushes or too many
missing pops, the following message is displayed when the shape is drawn

Position stack overflow in shape nnn.


Similarly, if you try to pop more locations than have been pushed onto the stack, the following message is
displayed when the shape is drawn.

Position stack underflow in shape nnn.


Code 8 and 9: X-Y Displacements
Normal vector specification bytes draw only in the 16 predefined directions, and the longest length is 15.
These restrictions help make shape definitions efficient but are sometimes limiting. With codes 8 and 9 you
can draw non-standard vectors using X, Y displacements. Code 8 must be followed by two specification
bytes in the format:

8,x-displacement, Y-displacement
The X, Y displacements can range from-128 to +127. A leading + is optional, and you can use parentheses to
improve readability. The following example results in a vector that draws (or moves) 10 units to the left and
three units up.

8, (- 10, 3 )

Following the two displacement specification bytes, the shape returns to Normal Vector mode.

You can use code 9 to draw a sequence of nonstandard vectors.This code can be followed by any number of
X, Y displacement pairs. It is terminated by a (0,0) pair. The following example draws three nonstandard
vectors and returns to Normal Vector mode.

9, (3, 1) , (3, 2) , (2, -3) , (0,0 )

Note that you must terminate the sequence of X, Y displacement pairs with a(0,0) pair in order for Auto
CAD to recognize any Normal Vectors or special codes that follow.

Code 00A: Octant Arc


Special code 00A (or 10) uses the next two specification bytes to define an arc. This is called an octant arc
because it spans one or more 45-degree octants, startintg and ending on an octant boundary. Octants are
numbered counter clock wise from the 3o’clock position, as shown in the following illustration.

2
3 1

7
The arc specification is

10, radius, (-) osc

The radius can be any value from 1 through 255.The second specification byte indicates the direction of the
arc (counterclockwise if Positive, and clockwise if negative), its starting octant (S-a value from 0through
7),and the number of octants it spans (C-a value from 0through 7, in which 0 equals eight octants, or a full
circle).You can use parentheses to improve readability .
For example consider the following fragment of a shape definition:

…..012, 10, (1, -032), 01E,……


This code draws a one-unit vector up and to the right, a clockwise arc from octant 3 (with a radius of one unit
for two octants), and then a one – unit vector down and to the right, as shown in the following illustration.

OCTANT3 OCTANT1

012
(TWO OCTANT) 01E

Code 00B: Fractional Arc


Special code 00B (11) draws an arc that doesn’t necessarily start and end on an octant boundary .The
definition uses five specification bytes.
11,start_offset, end_offset, high_radius, (-) OSC
The start _offset and end _offset represent how far from an octant boundary the arc begins of ends. The high
_ radius represents the most significant eight bits of the radius ; It will be 0 unless the radius is greater than
255 units. Multiply the high _radius value by 256 and add that value to the radius value to generate an arc
radius greater than 255. The radius and ending specification byte are the same as for the octant arc
specification (code 00A, described previously).

You determine the start offset by calculating the difference in degrees between the starting octan’ts boundary
(a multiple of 45 degrees) and the start of the start of the arc. Then you multiply this difference by 256 and
divide by 45. If the arc starts on an octant boundary, its start offset is 0.

For example, a fractional arc from 55 degrees to 95 degrees with a 3 unit radius would be coded as follows:

11, (56, 28, 0,3, 012)

Here is the explanation:

Start_offset =56 because ( (55-45)* 256/45) =56


End_offset =28 because ( (95-90)*256/45) =28
High_radius =0 because (radius<255)
Radius =3
Starting octant =1 because arc starts in the 45 degree octant
Ending octant =2 because arc ends in the 90 degree octant

8
Codes 00C and 00D: Bulge – Specified Arcs
Special codes 00C and 00D (12 and 13 ) Provide another mechanism for including arc segments in shape
descriptions. They are similar to codes 8 and 9 in that you can use them to specify X, Y displacements.
However, codes 00C and 00D let you draw arcs by applying a bulge factor to the displacement vector.
Code 00C draws one arc segment, while code 00D draws multiple arc segments (polyarcs) until it is
terminated by a (0,0) displacement.

Code 00C must be followed by three bytes describing the arc:

0c, X- displacement, Y- displacement, Bulge

Both the X and Y displacement and the bulge, which specifies the curvature of the arc, can range from –127
to +127. If the line segment specified by the displacement has length D, and the perpendicular distance from
the midpoint of that segment has height H, the magnitude of the bulge is ((2*H/D)* 127). The sign is
negative if the arc from the current location to the new location is clockwise.

D
A semicircle has bulge 127 (or-127) and is the greatest arc that can be represented as a single arc segment
using these codes (use two consecutive arc segments for larger arcs ). A bulge specification of 0 is valid and
represents a straight-line segment. Note, however, that using code 8 for a straight-line segment saves a byte
in the shape description.

The polyarc code (00D, or 13) is followed by 0 or by more arc segment triples, and is terminated by a (0,0)
displacement. (Note that no bulge is specified after the final displacement.) For example, the letter S might
be defined by the following sequence:

13, (0, 5, 127) , (0, 5, -127), (0,0)

Zero bulge segments are useful within polyarcs to represent straight segments; they are more efficient than
terminating the polyarc, inserting one straight segment, and then starting another polyarc.

The number –128 cannot be used in arc segment and polyarc definitions.

Compiling Shape/Font Files

You enter the description of shapes in a specially formatted text file with a file extension of shp. To create
such a file, use a text editor or word processor that enables you to save in ASCII format, and then compile the
ASCII file. Compiling a shape definition file generates a file format accepted by the LOAD or STYLE
command.

To compile a shape or font file, enter

Command: COMPILE

9
AutoCAD displays the select shape File dialog box from which you can select a shape definition file (.shp) or
Post Script font file (.pfb). After you select the file name, compiling begins. If AutoCAD finds an error in the
line number. When compiling is complete, the following messages are displayed:

Compilation Successful

Output file name. Shx contains nnn bytes.


The compiled file has the same name as the shape definition file but with a file type of .shx. If the shape
definition file defines a font, you use the STYLE command to define a text style. Then you use one of the
text placement commands (TEXT, DTEXT or MTEXT) to place the characters in the drawing. If the shape
definition file defines shapes, you use the LOAD command to load the shape file into the drawing. Then you
use the SHAPE command to place the individual shapes in the drawing (similar in concept to the INSERT
command).

10
Line type creation
AutoCAD linetypes are defined by linetype definition files. These files have a. lin extension. AutoCAD
linetypes are composed of a series of dots and dashes separated by spaces, and can contain embedded shape
and text objects. The default linetype file is acad lin. You can prints this file to better understand how to
construct linetypes.

Line types that are composed of only dots, dashes, and spaces are considered simple linetypes. Linetypes that
contain embedded shape and texst objects along with dots, dashes , and spaces are complex linetypes.
Although these two types of linetypes are handled similarly by AutoCAD, their definitions are considerably
different.

Two methods are available for creating and modifying linetype definitions. Youn can edits the lin file
using a text editor or word processor, or you can use the LINETYPE commands Create option. You cannot
create or modify complex linetypes at the command line.

A line type file can contain many linetype definitions. You can add your custom linetsypes to the acad. Lin
file or start building your own linetype library file . Commects can be included in a lin file. Any text on a line
that begins with a semicolon is ignored.

*linetype –name [, description]


This line must begin with an asterisk and must be immediately followed by the linetype name. If the
description is provided, it must be separated from the name by a comma and be no more than 47 characters.
The description is not used by AutoCAD; it is intended to help you visualize the appearance of the linetype.
The second line is the code that describes the actual pattern. Alignment, patdesc-1, patdesc-2
This line begins with the alignment code (currently only A is allowed), followed by a commandelimited listof
pattern descriptors (no spaces are allowed).

Simple Linetypes
You could have simple linetype called DD1 with the following repeating pattern:
¾ Dash, 0.5 drawing units long
¾ Space, 0.25 drawing units long
¾ Dot
¾ Space, 0.25 drawing units long
A, .5, -. 25, 0, - . 25

DD1 is the linetype name , and the description field is the description of the linetype displayed by the
LAYER Ltype? Command sequence. In this case, the description is a simple representation of the dash-dot
pattern.

The description is optional and can be a sequence of dots, spaces, and dashes, or a comment such as “Use this
linetype for hidden lines.” If you omit the description, do not put a comma after the linetype name. If you
include a description, it should be no more than 47 characters long.

The alignment field specifies the action for pattern alignment at the ends of individual line, circles, and arcs.
Currently, AutoCAD supports only one alignment action. You specify it by entering A in the field. It is
entered into the definition automatically when you use the LINETYPE Create option; however, if you create
the linetype definition using a text editor, you need to include the A yourself. AutoCAD rejects any other
character in the alignment field.

Each pat-n field specifies the length of a segment making up the line type. If the length is positive, a pen-
down segment will be drawn. A negative length denotes a pen up (blank) segment. A dash length of 0 draws

11
a dot. You can enter up to 12 dash-length specifications per linetype, provided they fit on one 80-character
line.
With A-type alignment, AutoCAD guarantees that the endpoints of lines and arcs start and stop with a dash.
For example, suppose you create a linetype called CENTRAL that displays the repeating dash-dot sequence
commonly used as a center line. AutoCAD adjusts the dash-dot sequence on an individual line basis so that
dashes and line endpoints coincide. The pattern fits the line so that at least half of the first dash specification
begins and ends the line. If necessary, the first and last dashes are lengthened. If a line is too short to hold
even one dash dot sequence, AutoCAD draws a continuous line between the endpoints. For arcs, the pattern
is also adjusted so that dashes are drawn at the endpoints. Circles do not have endpoints, but AutoCAD
adjusts the dash-dot sequence to provide reasonable displays.

The A-type alignment requires that the first dash length be 0 or greater (a dot or pen-down segment). The
second dash length should be less than 0 (a pen-up segment). You must have at least two dash specifications
for this alignment. Between the starting and ending dashes, the pattern dash specifications are drawn
sequentially, beginning with the second dash specification and restarting the pattern with the first dash
specification when required.

Note:

When you create a linetype, it is not loaded into your drawing automatically. Use the Load option of the
LINETYPE command.

Complex Linetypes
Complex linetype descriptions are placed in lin files along with simple linetypes. A complex linetype
specifies a single, possibly broken, line interspersed with symbols. This linetype can denote utilities,
boundaries, contours and so on. As with simple linetypes, complex lines are dynamically drawn as the user
specifies vertices. Shapes and text objects embedded in lines are always displayed completely; they are never
trimmed.

The syntax for complex linetypes is similar to that of simple linetypes in that it is a commadelimited list of
pattern descriptors. Complex linetypes can include shape and text objects as pattern descriptors, as well as
the dash-dot descriptors of simple linytypes.

The syntax for both shape and text object descriptors in a linetype descriptors in a linetype description is as
follows:

Shape
[shapename, shxfilename] or
[shapename, shxfilename, transform]

text
[“string”, stylename] or
[“string”,stylename,transform]

Where transform is optional and can be any series of the following (each preceded by a comma):

R=## Relative rotation


A=## Absolute rotation
S=## Scale
X=## X offset
Y=## Y offset

In this syntax,## is a signed decimal number (1,-17,0.01, and so on), the rotation is in degrees, and the
remaining options are in linetype-scaled drawing units. The preceding transform letters, if they are used,
must be followed by an equal sign and a number.

12
Shapes in Complex Linetypes
The following linetype definition defines a linetype name CON1LINE that is composed of a repeating pattern
of a line segment, a space, and the embedded shape CON1 from the file es.shx (note that the es.shx file must
be in the support path for the following example to work properly).

*CON1LINE,-----[CON1] -----[CON1]----[CON1]
A,1.0,-.25, [CON1,es.shx], -1.0

Except for the code enclosed in square brackets, everything is consistent with the definition of a simple
linetype. This example shows the minimal linetype definition that embeds a shape within a linetype.

As previously described, a total of six fields can be used to define a shape as part of a linetype. The first two
are mandatory and position dependent; the next four are optional and can be ordered arbitrarily. The
following two examples demonstrate various shape definition field entries.

[CAP, es. Shx, S=2, R=0, X=0.5]

This code elaborates the shape CAP defined in the shape file es.shx with a scale of two times the units scale
of the linetype, a tangential rotation of 10 degrees in a clockwise direction, and an X offset of 0.5 drawing
units before shape elaboration takes place.

[DIP8, pc. Shx, X=0. 5, Y=1,R=0, S=1]

This code elaborates the shape DIP8 defined in the shape file pc.shx with an X offset of 0.5 drawing units
before shape elaboration takes place, and a Y offset of one drawing unit above the linetype with a scale equal
to the unit scale of the linetype and 0 rotation.

The following syntax defines a shape as part of a complex linetype.


[shapename, shapefilename, scale, rotate, xoffset, yoffset]
The definitions of the fields in the syntax follow.

Shapename
The name of the shape to be elaborated. This field must be included. If it is omitted, linetype definition fails .
If shape name does not exist in the specified shape file, continue with linetype elaboration without embedded
shape.

Shapefilename
The name of a compiled shape definition file (shx). If it is omitted, linetype definition fails. If shapefilename
is unqualified (that is, no path is specified ), search the library path for the file. If shapefilename is fully
qualified and not found at that location, strip off the prefix and search the library path for thefile. If it is not
found, continue with linetype elaboration without embedded shape.

Scale
S=value. The scale of the shape is used as a scale factor by which the shape’s internally defined scale is 0, the
S= value alone is used as the scale.

Rotate
R= value or A=value. R = signifies relative or tangential rotation with respect to the lines elaboration. A=
signifies absolute rotation of shape with respect to the origin; all shapes have the same rotation regardless of

13
their relative position to the line. The value can be appended with a d for degrees (if omitted, this is the
default), r for radians, or g for grads. If rotation is omitted, 0 relative rotation is used.

Xoffset
X = value. X offset specifies the shift of the shape in the X axis of the linetype computed from the end of the
linetype definition vertex. If X offset is omitted or is 0, the shape is elaborated with no offset. Include this
field if you want a continuous line with shapes. This value is not scaled by the scale factor defined by S=.

Yoffset
Y= value. This field is the shift of the shape in the Y axis of the linetype computed from the end of tshe
linetype definition vertex. If yoffset is omitted or 0, the shape is elaborated with no offset. This value is not
scaled by the scale factor defined by S=.

Text in Complex Line


Complex linetypes with text are used primarily for incorporating text as the shape to be elaborated. The
primary difference between the use of shapes and the use of shapes and the use of text is that text is
associated with a text style associated with the linetype must exist prior to loading the linetype into the
drawing.

The following is an example of a complex linetype definition that include a text style.

*MC line,----MC----MC-----MC
A,1.0,-0.25, [“MC” ,mystyle, S=1, R=0, X=0, Y= -0.25], -1.25

Where MC line is the name of the linetype, and” –MC –MC –MC” is the ASCII description.

[“string”, style, S=scale, R=rotate, X=xoffset, Y=yoffset]

The definitions of the fields in the syntax follow.

String
The text to be used in the complex linetype.

Style
The name of the texts style to be elaborated .The specified text style must be included. If it is omitted, use
the currently defined style.

Scale.
S=value. The scale of the style is used as a scale factor by which the style’s height is multiplied. If the style’s
height is 0, the S=value alone is used as the scale.

Because the final height of the text is defined by both the S=value and the height assigned to the text style,
you will achieve more predictable results by setting the text style’s height to zero. Additionally, it is
recommended that you create separate text styles for text in complex linetypes to avoid conflicts wisth other
text in your drawing.

Rotate
R =value or A = value. R= signifies relative or tangential rotation with respect to the lines elaboration. A=
signifies absolute rotation of the text with respect to the origin; all text has the same rotation regardless of its
relative position to the line. The value can be appended with a d for degrees (if omitted, this is the default), r
for radians, or g for grads .If rotation is omitted, 0relative rotation is used.

14
Rotation is centered between the baseline and the nominal cap heights box.

X offset
X = value. X offset specifies the shift of the texts in the Xaxis of the line type computed from the end of the
line type definition vertex. If x offset is omitted or is 0, the text is elaborated by using the lower left corner of
the text as the offset. Include this field if you want a continuous line with text. This value is not scaled by the
scale factor that is defined by S =.

Y offset
Y= value. Y offset is the shift of the text in the Y axis of the line type computed from the end of the line type
definition vertex . If y offset is omitted or is 0, the text is elaborated by using the lower left corner of the text
as the offset. This value is not scaled by the scale factor that is defined by S =.

Hatch Pattern Creation


Developing a hatch pattern definition for AutoCAD requires some knowledge, practice, and patience, and
also a text editor. You can add a pattern to the library file acad. pat or store it in a file by itself, in which case
the file name must be the same as the pattern name. For instance, a pattern named PIT would reside in the file
pit.pat.

Regardless of where the definition is stored, it has the same format. It has a header line that looks like this;
*pattern-name [, description]

It also has one or more line descriptors of the following form.

Angle, X-origin, Y-origin, delta-x, delta-Y [, dash-1, dash-2,…]

AutoCAD ignores blank line and text to the right of a semicolon,

For example, a pattern called L45 that hatches with 45-degree lines separated by a spacing of 0.5 would be
defined as follows;

*L45, 45 degree lines

45, 0, 0, 0, 0.5

This simple pattern specifies that a line is to be drawn at an angle of 45 degrees, that the first line of the
family of hatch lines is to pass through the (0,0) drawing origin , and that the spacing between hatch lines of
the family is to be 0.5 drawing units. L45 is the name of the pattern displayed by the HATCH ? command. (if
you omit the description, do not include a comma after the pattern name.) Each line in a pattern definition file
can contain up to 80 characters.

The default hatch patterns used by AutoCAD are stored in the file acad.pat. You can add pattern definitions
to this file, as previously described.

The Boundary Hatch and Hatch Pattern Palette dialog boxes display the names of all the hatch patterns
defined in the file acad. Pat

You can add new hatch patterns to the dialog boxes by adding the hatch definitions to the acad. pat file.
Whenever a slide name in acad. slb matches a pattern name in acad. pat, the slide is also displayed by the
dialog boxes.

15
A pattern is made up of one or more pattern lines.(AutoCAD imposes no limit on the number of lines).Each
pattern line is considered the first member of a line family,created by applying the delta offsets in both
directions to generate an infinite family of parallel lines.The delta –Y value gives the spacing between
members of the family (that is ,it is measured perpendicular to the lines).Delta -Y value gives the spacing
between members of the family (that is ,it is measured perpendicular to the line).Delta-x gives the
displacement between members of the family in the direction of the line;it is meaningful only for dashed
lines.

Example
1.Modify a pattern for 45-degree lines to draw dashed lines with adash length of .5 units and a spacing
between dashed of .5 units.
*DASH45,DASHED LINES AT 45-DEGREES
45, 0, 0, 0, .5, -.5

This is same to as the original 45-degree pattern,but you have added a dash specification to the end.Yhe pen
down length is .5 units,and the pen-up length is .5,meeting the started objectives.If you wanted to draw .5-
units dash, a .5-units space,a dot,and a .25-unit space before the next dash,the defination would be as follows
*DDOT45,DASH DOT PATTERN: 45 degrees
45, 0, 0, 0, .5, -.5

2.(a)Write a hatch pattern for the following.

____ _____ _____


____ _____ _____
____ _____ _____
____ _____ _____
____ _____ _____
____ _____ _____

b) ___ ___ ___ ___


___ ___ ___ ___ The distance between the two
___ ___ ___ ___ is .5 length=.5
___ ___ ___ ___

c)

16
CUSTOM MENU

Menu customization is particularly useful if you need to perform an application-specific task


on a regular basis. You can improve productivity by adding a selection to your menu. In this way,
multiple steps to accomplish a task can be initiated with a single menu selection, automating a
complex operation.

Menus are defined by menu files. You can modify an existing menu file or create your own.
By editing the text in a menu file, you can define the appearance and location of menu items. You
can then assign menu macros that execute specific actions when a menu item is selected.

Menu macros can be simple recordings of keystrokes that accomplish a task, or they can
be a complex combination of commands and AutoLISP or DIESEL program code. More complex
menu macros have some decision-making ability. A menu macro is similar to a script in that it
issues a series of commands. However, scripts have no decision-making ability and cannot pause
for interact to create custom menus to complement those supplied with AutoCAD.

Menu file define the functionality and appearance of menu area. The menu items in each
menu area contain AutoCAD command strings and macro syntax that define the resulting action
when the menu items is selected. The following areas are defined by menu files.

™ Pointing-device button menus


™ Pull-down and cursor menus
™ Toolbars
™ Image tile menus
™ Screen menus
™ Digitizing-tablet menus
™ Help strings and tooltips
™ Keyboard accelerators

Menu File Types

The term menu file actually refers to the group of the files that work together to define and
control the appearance and functionally of the menu area. The following table describes the
AutoCAD menu file types.

AutoCAD Menu Files

File type Description

MNU Template menu file


MNC Compiled menu file. This binary file contains the command strings and menu
syntax that defines the functionality and appearance of the menu
MNR menu recourse file. This binary file contains the bitmaps used by the menu.
MNS Source menu file (generated by AutoCAD)
MNL Menu LISP file. These files contain AutoLISP expressions that are used by the
menu file and are loaded into memory when a menu file with the same file name is
loaded.

17
Menu definition files have the file extension .mnd. These are special menu source file that
contain macros. File of the type MND must be compiled with the menu compiler utility (mc.exe).

Menu File Structure

Menu file are divided into sections that relate to specific areas of the AutoCAD interface.
Depending on its functionality, each menu are can be defined by one or more sections. Each
section contains menu items, which provide instructions for the appearance and action related to
the menu selection. Menu items are comprised of the following elements: a name tag, a label and a
menu macro. Although menu items are similar in structure and functionality, each section uses a
special syntax for its menu items labels.

A menu file does not need to contain entries for every menu section. You need only those
that pertain to your application. It is recommended that you divide your menus into several smaller
menu files that can be loaded and unloaded on demand (with the MENULOAD command). Not only
does this give you better control to your system resources, but also it makes development and
maintenance easier because you can work with smaller pieces as needed.

Menu file sections are identified by section labels that use the format ***section_name,
Section labels and their associated menu areas are listed in the following table.

Section labels and associated menus

Section label Menu area

*** MENUGROUP Menu file group name

*** BUTTONSn Pointing-device button menu

*** AUXn System pointing device menu

*** POPn Pull-down/cursor menu areas

*** TOOLBARS Toolbar definitions

*** IMAGE Image tile menu area

*** TABLETn Tablet menu area

*** HELPSTRINGS Text that is displayed in the status bar when a pull-down or cursor
menu item is highlighted, or when the cursor is over a toolbar
button.

*** ACCELERATORS Accelerator key definitions

Each section contains menu items that define the appearance and functionality of menu
selections.

You an include comments in menu files for use as copyright notices, documentation, or
notes. Any line that begins with two slashes (//) is ignored by the menu compiler, as shown in the
example:

// This line is a comment

18
Menu Item Syntax

The general syntax of menu items is consistent across all menu sections that allow for
menu items. Each menu item can consist of a name tag, a label, and a menu macro (except the
Image section, which does not permit name tags). A menu item normally resides on one line of the
file and uses the following format.

name_tag label menu_macro

The following sample menu code from a Pop (pull-down) menu illustrates a simple menu
item:

ID-Quit [Exit] C^C^_ quit

The first item ID-Quit is the name tag and the label [Exit] displays Exit in the menu. When
this menu item is selected by a user, the menu macro C^C^_ quit is issued.

Name Tags

A name tag is a string consisting or alphanumeric and underscore ( _ ) characters that


directly precedes the menu item label. This string uniquely identifies as item within a menu file.
Name tags provide the following functionality:

™ Link Pop menu items and toolbar buttons to their associated status line help (see “Menu-
Specific Help)”

™ Link keyboard key sequences to a corresponding Pop menu macro (see “Accelerator Keys”)

™ Enable menu items to switch from one state to another (such as enabled to disabled and
marked to unmarked) from menu macros or AutoLISP (see “Display Control Menu Item
Labels”)

Name tags are not allowed in Buttons, Aux, and Image sections. They are allowed in Screen
and Tablet sections but serve no purpose.

Menu-Specific Help

Status-line help messages are an important aspect of native help support. These are the
simple, descriptive messages that appear in the status line when a menu item is chosen. The
Helpstrings menu section provides support for this form of help.

The following example shows a simple menu file that makes use of Helpstrings.

*** MENUGROUP=Gsample

*** POP1

ID_Title [/Ttitle]

ID_Cancel [Cancel Command] ^C^C

ID_Line [/Lline] ^C^C_Line

[Disable Line] (menucmd “Gsample.ID_Line=~”)


(Check Line] (menucmd “Gsample.ID_Line=~.”)

19
*** POP2

[/2Title2]

[Another Pull down[ (menucmd “Gsample.ID_Line=`”)

***HELPSTRINGS

ID_Title [This is the Title menu]

ID_Cancel [This item cancels the previous command]

ID_Line [This draws a simple line]

The syntax for the Helpstrings section is a name tag follow by a label. When a menu item
is highlighted, the name tag for that item is queried for a corresponding entry in the
***HELPSTRINGS section. If such a match occurs, the string contained within the label is displayed
in the status line.

Accelerator Keys

AutoCAD supports user-defined accelerator keys. The following is a short example of an


Accelerators section.

***ACCELERATORS

ID_Line [SHORT+CONTROL+”L+
[CONTROL+”Q”] ^C^C_quit

[CONTROL+SHIFT+”Z”] ^C^Czoom extents

The Accelerators section contains items in one of two formats. The first is a name tag
(such as ID_Line), followed by a label containing modifiers. The modifiers are followed by either a
single character or a special virtual key string (such as “F12”) enclosed in quotation marks. This
type of item maps a key sequence to a menu item. You can concatenate more than one modifier
with another by using the plus symbol )+), as in the first example. When a special key sequence is
recognized, the menu item associated with the name tag is executed as if the user had chosen the
menu item.

The second method of defining an accelerator uses a label containing a modifier and key
string, followed by a command sequence. This method maps a key sequence to a command string
and does not have a corresponding menu item.

The following table lists the valid modifiers.

Valid Modifiers
ring Description

CONTROL The CTRL key

SHIFT The SHIFT key, either right or left.

The following table lists the special virtual keys. (These keys must be enclosed in quotation
marks).

20
Special virtual keys

String Description

“F1” F1 key Although the F1 key can be assigned a menu macro, this is
discouraged because this key is generally associated with Help. Using a
modifier with this key is acceptable.

“F2” F2 key Unmodified, this key toggles the state of the next window

“F3” F3 key unmodified, this key runs OSNAP


“F4” F4 key unmodified, this key toggles TABMODE

“F5” F5 key unmodified, this key toggles ISOPLANE

“F6” F6 key unmodified, this key toggles COORDS

“F7” F7 key unmodified, this key toggles GRIDMODE

“F8” F8 key unmodified, this key toggles ORTHOMODE

“F9” F9 key unmodified, this key toggles SNAPMODE

“F11” F11 key None

“F12” F12 key None

“INSERT” INS key None

“DELETE” DEL key None

“ESCAPE” ESC key Although the ESC key can be assigned a menu macro, this is
discouraged because this key is generally associated with Cancel.
CTRL+ESCAPE and CTRL+SHIFT+ESCAPE cannot be assigned a menu
macro; these sequence are controlled by Window. Using the SHIFT
modifier with this key is acceptable.

“UP” UPARROW key Must be used with the CONTROL modifier.

“DOWN” DOWNARROW key Must be used with CONTROL modifier

“LEFT” LEFTARROW key Must be used with the CONTROL modifier

“RIGHT” RIGHTARROW key Must be used with the CONTROL modifier

“NUMPAD0” 0 key None

“NUMPAD1” 1 key None

“NUMPAD2” 2 key None

“NUMPAD3” 3 key None

“NUMPAD4” 4 key None

“NUMPAD5” 5 key None

21
“NUMPAD6” 6 key None

“NUMPAD7” 7 key None

“NUMPAD8” 8 key None

“NUMPAD9” 9 key None

Note:

F10 is used by the Windows operating system as an alternative to ALT and is therefore not user-
configurable.

User who make extensive use of coordinate entry, might find the following menu enhancement very
useful.

[“NUMPAD5” ]@X^h

[“NUMPAD6” ]<0

[“NUMPAD9” ]<45

[“NUMPAD8” ]<90

[“NUMPAD7” ]<135

[“NUMPAD4” ]<180

[“NUMPAD1” ]<-135

[“NUMPAD2” ]<-90

[“NUMPAD3” ]<-45

If this code is added to the Accelerators section, your numeric keypad is modified as
follows: the RETURN key enters the @ symbol and the other number keys enter the less-than
symbol (<), followed by the angular value represented by its location in the keypad. For example, if
you wanted to draw a square that was 3 units on each side, you would enter the following:

Command: LINE

From point: specify start point

To point: (press number 5) 3 (press number 6)

To point: (press number 5) 3 (press number 2)

To point: (press number 5) 3 (press number 4)

To point: c

22
Display Control of Menu Item Labels

Another customization feature of pull-down and cursor menus is the ability to control the
way that item labels are displayed. You can disable (gray out) the labels, making them inaccessible
to the user or mark them with a check mark.

Labels can also contain DIESEL string expressions to modify the contents of the label. This
can disable, mark, or interactively change the text of the displayed label. For more information, see
“DIESEL Expressions in Menus”.

Note:

When disabling and making menu item labels, be sure to use an appropriate technique that
keeps track of changes that affect the state of the label.

Disabling Labels

A Menu item label that begins with a tilde (~) will be disabled (grayed out). By convention,
this indicates that the item is not presently a valid selection. Any commands associated with the
item are not issued, and any submenus are inaccessible.

For example, the following menu labels are disabled.

[~Line]
[~-> Pline]

The child menu of a disabled label is inaccessible

Using DIESEL to Disable Labels

Menu item labels can contain DIESEL string expressions that conditionally disable or
enable labels each time they are displayed. For example, the DIESEL string expression within the
following menu item label disables the label with a command is active.

[$ (if, $(getvar, cmdactive), ~)MOVE]move

Using AutoLISP to Disable Labels

The AutoLISP menucmd function can be used to disable and enable labels from a menu
macro or application. For example, see “Reference Pull-Down and Cursor Menus”.

Marking Labels

You can mark a menu item label with a leading check mark (✔) by including an
exclamation point and period (!). Making a menu item does not restrict your ability to choose the
item, although a marked item can be disabled.

In the following example, the Line menu item is marked with a ✔

[!. Line]

23
Using DIESEL to Mark Labels

Menu item labels can contain DIESEL string expressions hat conditionally mark labels
each time they are displayed. The following example places a check mark to the left of menu labels
whose related system variables are currently enabled.

[$ (if, $ (getvar, orthomode), !.) Ortho]^O

[$ (if, $ (getvar, Snapmode), !.) Snap]^B

[$ (if, $ (getvar, gridmode), !.) Grid]^G

Using AutoLISP to Mark Labels

The AutoLISP menucmd function can be used to mark labels from a menu macro or
application. For example, see “Referencing Pull-Down and Cursor Menu”.

Simultaneous Disabling and Marking

You can mark and disable menu items at the same time. The format is

[~ !. labeltext]

or

[!. ~ labeltext]

where ~ is the special character code to disable a menu item and !. is the special character
code to mark a menu item.

In the example that follows, the Line menu item is disabled and marked with a check mark.
As with the previous examples, a DIESEL expression can be used to simultaneously disable and
mark a menu item label.

[~!. Line]

Referencing Pull-Down and Cursor Menus

There are two methods for referencing a pull-down or cursor menu. One method uses the
menu group and name tag, the other uses the absolute position of the menu item in the menu
hierarchy. The former method is recommended because of its dynamic nature, which allows it to
function properly, regardless of the current state of the menu.

Relative Referencing of Pull-Down and Cursor Menu Items

To reference a pull-down or cursor menu item based on its menu group and name tag, use
the AutoLISP menucmd function. The following syntax references a menu item based on its name
tag.

(menucmd “Gmenugroup.name_tag=value”)

The following example disables the menu item ID_Line that is the sample menu group. It
works regardless of the menu item’s location in the menu.

[Disable Line] (menucmd “Gsample.ID_Line=~”)

24
If the author of a partial menu is aware of the contents of the base menu, the syntax of a
menu item can reference a tag from the base file. An excerpt from the base file acad.mnu might
look something like the following:

*** MENUGROUP=ACAD

*** POP0 (and so forth . . . .)

....

*** POP6

ID_MnHelp [Help]
ID_Contents [Contents]C^C^_HELP
ID_About [About]^C^C_ABOUT

An menu item in a partial menu can be modified to have an additional men item that
references the tag in the base menu.

**** POP2

[Title2]

[Disable Help Contents] (menucmd “Gaad.ID_Contents=~”)

In this manner, multiple partial menu files and specific base file can work together.
AutoCAD enforces strict menu group definition so that no two menu can define the same menu
group. Attempts to load a menu with a conflicting menu group results in cancellation of the
MENULOAD request.

Absolute Referencing of Pull-Down and Cursor menu Items

Similar to the referencing described in the previous section, you can activate or deactivate
a menu item with the Pn=xxx (if present), specifics a string defining the action.

The following example uses the AutoLISP menucmd function to reference a pull-down or
cursor menu item. Because AutoCAD menu files are dynamic (through the loading of partial
menus), the following syntax is not guaranteed to work in all cases.

[Disable Line Old Way] (menucmd “P1.2 =~”)

This syntax relies on the location of the menu item and does not work if a new item was
inserted into the POP1 section by the menu author or id a new pull-down menu is inserted before
POP1 by the MENULOAD command.

You can use the Pn=xxx syntax from a menu macro if it allows the $ command. The
following example disables item 4 in the POP3 section.

$P3.4=~

the following exampel adds a check mark to item 1 in the POP7 section.

$ P7.1=!.

25
The following example removes any disabling or mark character from item 1 in the POP7
section.

$ P7.1=

Menu item numbering is consecutive without regard to the hierarchy of the menu file; item
1 is the first item following the title.

***POP5

[Assist ] Title

[Help ! ] ‘? Item 1

[Cancel ] ^C^C^C Item 2

[--] Item 3

[Undo }^C^C_U Item 4

[Redo ] ^C^C_redo Item 5

[--] items 6

[->0snap ] Item 7

[Center ]center Item 8

To make it easy for an item to address itself without regard to location in the menu
hierarchy, the following forms also can be used.

$P@.@=XXX

References the current or most recently chosen menu item.

$P@.n=XXX

References the current or most recently chosen menu.

Labels

The format and use of menu item labels differs for each menu section. The label is
contained within square bracket ([ ]) and defines what is displayed or presented to the user. Menu
sections that have to interface for displaying information, do not require labels (such as the
Buttons, Aux, and Tablet section); however, they can used for internal notes. The following table
shows how each menu section uses labels.

Menu section Use of label

BUTTONSn,

AUXn, and POPn Defines the content and formatting of pull-down and cursor menu
selections.

26
TOOLBARS Defines the toolbar name, status (floating or docked, and hidden or
visible), and position. Also, it defines each button and its properties.

IMAGE Defines the text and image displayed in the image tile menus.

SCREEN Defines the text that is displayed in the screen menus.

HELPSTRINGS Defines the status line help related to Pop and Toolbar menu items.

ACCELERATORS Associates keyboard action with menu macros.

Menu Macros

If you intend to include command parameters in a menu item, you must know the
sequence in which that command expects its parameters. Every character in a menu macro is
significant, even the blank spaces. As AutoCAD is revised and enhanced, the sequence of prompt
for various commands (and sometimes even the command name) might change. Therefore, your
custom menus might require minor changes when you upgrade to a new release of AutoCAD.
Most of the examples in this section apply specifically to Pop and Screen menu sections;
however, with little or no revisions, must menu macros work equally well in all sections.

When command input comes from a menu item, the settings of the PICKADD and
PICKAUTO system variables are assumed to be 1 and 0, respectively. This preserves compatibility
with previous releases of AutoCAD and makes customization easier because you are not required
to check the settings of these variables.

Menu Macro Syntax

The following table provides a synopsis of special characters used in menu macros. The
use of these characters is described an detail in later sections.

Special characters used in menu macros

Character Description

; Issues RETURN

^M Issues RETURN

^I Issues TAB

SPACEBAR Enters a space; blank space between command sequences in a menu tem
is equivalent to pressing the SPACEBAR

\ Pauses for user input

- Translates AutoCAD command and key words the follow

+ Continues menu macro to the next line (if last character)

=* Displays the current top level image, pull-down, or cursor menu

*^C^C Prefix for a repeating item

$ Special character code that loads a menu section or introduces a


conditional DIESEL macro expression ($M=)

27
^B Toggles Snap on or off (CTRL+B)

^C Cancels command (ESC)

^D Toggles Coords on or off (CTRL+E)

^E Sets the next isometric plane (CTRL+G)

^G Toggle Grid on or off (CTRL+G)

^H Issues backspace

^O Toggles Ortho on or off (CTRO+O)

^P Toggles MENUECHO on or off

^Q Echoes all prompts, status listings, and input to the printer


(CTRL+Q)

^T Toggles tablet on or off (CTRL+T)

^V Changes current viewport (CTRL+V)

^Z Null character that suppresses the automatic addition of SPACEBAR at


the end of a menu item.

Macro Termination

When a menu item is selected, AutoCAD places space at the end of the macro before
processing the command sequence. AutoCAD processes the following menu macro as though you
had entered line SPACEBAR.

[Line] line

Sometimes this is undesirable; for example, the TEXT or DIM command must be
terminated by RETURN, not by a space. Also, it sometimes takes more than one space (or
RETURN) to complete a command, but some text editors don’t let your create a line with trailing
blanks. Two special conventions get around these problems.

™ When a semicolon (;) appears in a menu macro, AutoCAD substitutes a RETURN.

™ If line ends with a control character, a backslash (\), a plus sign (+), or a semicolon (;),
AutoCAD does not add a blank after it. (For an example of the use of control character as a
menu item terminator, see “Conditional Macro Expressions”).

Look at the Erase 1 menu item in the following example:

[Erase 1] erase \;

If this item simply ended with the backslash (which indicates user input), it would fail to
complete the ERASE operation, because AutoCAD doesn’t add a blank after the backslash.
Therefore, this menu macro uses a semicolon (;) to force a RETURN after the user input.

Here are more examples:

28
[UCS ] ucs

[UCS W ] ucs;

[Address ] text \4. 0 DRAFT Inc;;; Main st.;;;City, State;

Selecting the first item enters ucs and SPACEBAR on the command line, and the following
prompt appears.

Origin/Zaxis/3Point/Entity/View/X/Y/Z/Pre/Restore/Save/Del/?/<World>:

Selecting the second item enters ucs, SPACEBAR, and ; (interpreted as RETURN) at the
command line, which accepts the default value, World, No difference between the first and second
item would be evident on the screen; naturally, you wouldn’t put both on the same menu.

Menu Groups

The ***MENUGROUP = label defines the contents of a menu file to be members of a


particular group. The purpose of this group name is to distinguish its item from other item when
using partial menus. This label must proceed all menu sections that use the name tag mechanism.
It defines the menu group name for these sections. A Menugroup definition is a string of up to 32
alphanumeric characters (spaces and punctuation marks are not allowed).

Because each menu has its own menu group label, multiple partial menus can use the
same name tag. A name tag, therefore, must be unique only within the menu file in which it was
defined. This also enables applications that load partial menu files to access each other’s items.

Menu group names combined with Pop menu names or aliases provide the following
functionality:

™ Interactive loading and unloading of partial menus (see the MENULOAD command)

™ Control of pull-down menu display and layout from menu macros or AutoLISP (see “Display
Control of Menu Item Labels”)

Note:

The Menugroup section contains no menu items.

Button and Auxiliary Menus

The button (***BUTTONs) and Aux (***AUXn) menus are identical in format. Their use
depends on the type of pointing devices you are using. The system mouse uses the auxiliary
menus, and any other pointing device (such as a digitizer puck or other input device) uses the
button menus: the BUTTONS1 menu functions to the AUX1 menu and so on.

Creating Button and Auxiliary Menus

The AUXn sections of the menu file define the menu macros associated with the buttons
on your mouse. Each line in this section represents a mouse button. You can access each button
menu with the key/button sequences shown in the following table.

29
Key/button sequence Menu sections

Simple button press AUX1 and BUTTONS1

SHIFT + button press AUX2 and BUTTONS2

CTRL + button press AUX3 and BUTTONS3

CTRL + SHIFT + button press AUX4 and BUTTONS4

Although the areas 1 though 4 are the only active sections, you can define additional
sections and swap them into the action sections. This was previously achieved with submenus
(such as **othermenu). The **label syntax is used for section aliases in the Button Aux sections.
For information on menu swapping, see “Button and Auxiliary Menu Swapping”.

Creating or customizing button menus can make use the pointing device more efficient
and dynamic. By selecting the menu items and adding them to the button menu, you can
personalize your pointing device to fit your needs.

Examine the BUTTONS1 section of the standard acad.mnu file:


*** BUTTONS1

$P0=*

^C^C

^B

^O

^G

^D

^E

^T

The first line after the menu section label, *** BUTTONS1, represents the next button after
the pick button on your pointing device. If the pick button is button 1, the semicolon (;) assigns
RETURN to button number 2 on your pointing device. The second line after the menu section label
represents the third button.

Note:

You cannot reassign the pick button. The pick button may be different on each pointing
device, depending on the manufacturer.

* * * BUTTONS1

[button no.2];

[button no.3] $P0=*

30
[button no.4] ^C ^C

The macro assigned to button number 3 in the example causes another menu to be
displayed. It has the format

$ Pn=*

where $ is the special character code for loading a menu area; Pn specifies the Pop menu
section; and =* displays what is currently loaded to the specified menu area.

Therefore, in the example from acad.mnu, choosing button number 3 displays the menu
assigned to the P0 menu area (the P0 menu area is the cursor menu). Typically, the **POP0
section of the menu file is assigned to the P0 menu area.

Each remaining line in that section assigns a command sequence to each subsequent
button on the pointing device-for example, ^C ^C (ESC twice) to button 4, ^B (Snap mode toggle)
to button 5, and so on. Your pointing device can recognize as many lines as it has assignable
buttons.

Special Use of the Backslash

When you select a menu item with one of the menu buttons on a multibutton pointing
device, AutoCAD receives not only the button number but also the coordinates of the screen
crosshairs at the time you press the button. By carefully constructing the macros in the Buttons and
Aux sections of the menu file, you can choose to ignore these coordinates or to use them with the
command activated by button.

As described earlier, you can include a backslash (\) in a menu item to pause for user
input. For the buttons menus, the coordinates of the screen crosshair are supplied as user input
when the button is pressed. This occurs only for the first backslash in the menu item; if the item
contains no backslashes, the pointer coordinates are not used. For example, consider the following
menu items:

* * * BUTTONS2

line

line \

The first menu button issues an ordinary LINE command and solicits the From point
prompt in the normal fashion. The second menu button also issues a LINE command, but AutoCAD
reads the current pointer location and uses it as the From point.

Pull-Down and Cursor Menus

The pull-down (* * POPn) and cursor ( ***POP0) menus are displayed as cascading menus
(also known as walking or hierarchical menus). Thus, they allow logical layout of menus without
swapping menu areas. The cursor menu can provide quick access to often-used menu items such
as Object Snap modes. Pull-down and cursor menu items are similar to items in other menu
sections, and you define menu macros similar to the way you define standard screen or tablet
menus.

A pull-down menu can contain up to 999 menu items. A cursor menu can contain up to 499
menu items. Both limits include all menus in the hierarchy. If menu items in the menu file exceed

31
these limits, AutoCAD ignores the extra items. If a pull-down or cursor menu is taller than the
available space on the graphics screen, it is truncated to fit on the screen.

Pull-down menus are always pulled down from the menu bar, but the cursor menus is
always displayed at or near the crosshairs on the graphics screen. They syntax for both of these
POPn menu sections is the same except that the cursor menu title isn’t included in the menu bar.
The cursor menu title is not displayed at all (but you must still enter a dummy title). Access to the
cursor menu is through the $P0=* menu command, which can be issued by another menu item
(such as a BUTTONSn menu item) or by an AutoLISP or ARX program. While the cursor menu is
active, the menu bar is not available.

Note:

If no active pull-down menus are defined (POP-POP16), the cursor menu (POP0) does not
function.

Creating Pull-Down and Cursor Menus

The POPn menu sections control the pull-down menus and the cursor menu. POP0
controls the cursor menu; POP1 through POP16 control the active pull-down menus for the menu
bar.

AutoCAD scans for POPn menu sections while loading each menu file. For the POP1
through POP16 menu sections it constructs a menu bar containing the titles of those sections. If
no POPn sections are defined, AutoCAD inserts default File and Edit menus.

The following example illustrates the syntax that is used to create a pull-down or cursor
menu.

* * * POP2

* * EDIT

ID_MnEdit [&Edit]

ID_U [&Undo\tCtrl+Z]_u

ID_Redo [&Redo\tCtrl+Y]^C^C-redo

[--]

ID_cutclip [Cu&t\tCtrl+X]’ _cutclip

ID_ Copyclip [&Copy\t\Ctrl+C]’ _copyclip

ID_Copylink [Copy &Link] ^C^C_copylink

ID_pasteclip [&Paste\t\Ctrl+V]’ _pasteclip

ID_Pastesp [Paste & Special . . . ]^C^C_pastespec

ID_Erase [cle&ar\t\Del]^C^C_erase

[--]

32
ID_Links [&OLE Links. . . .]^C^C_olelinks

Pull-Down and Cursor Menu Label Syntax

The following table characters that each have a special function when enclosed in a pull-
down or cursor menu label.

Character Description

-- Item label that expands to become a separator line in the pull-down and
cursor menus (when used with no other characters).

+ Continues macro to the next line (if last character).

-> Label prefix that indicates that the pull-down or cursor menu item has
submenu.

<- Label prefix that indicates that the pull-down or cursor menu item is the
last item in the submenu.

<-<-… Label prefix that indicates that the pull-down or cursor menu item is the
last item in the submenu, and terminates the parent menu. (One <-
required to terminate each parent menu.)
$( Enables the pull-down or cursor menu item label to evaluate a DIESEL
string macro if $(are the first characters.

~ Label prefix that disables (grays out) a menu item.

! Label prefix that marks a menu item with a check mark.

& An ampersand placed directly before a character specifies that character


as the menu accelerator key in a pull-down or cursor menu label. For
example, S&ample displays as Sample.

/c Specifies the menu accelerator key in a pull-down or cursor menu label.


For example, /aSample displays as Sample.

\t Specifies that all label text to the right of these characters is pushed to the
right side of the menu.

Note:

The only nonalphanumeric characters that can be used as the first character in a menu
label are those listed above. Nonalphanumeric characters not listed in the previous table are
reserved for future use as special menu characters.

Pull-Down Menu Bar Titles

For pull-down menus, the first label defines the menu bar title; succeeding labels define
menu and submenu items. The following example is the top portion of the POP2 pull-down menu
section.

* * * POP2
ID_MnEdit [&Edit]

33
ID_U [&Undo\tCtrl+Z]_u

ID_Redo [&Redo\tCtrl+Y]^C^C-redo

On the first line after the * * *POP2 section label, the label [&Edit] causes Edit to be
displayed as a menu bar title and the letter E is underscored to indicate that it is the menu
accelerator key. The name tag associated with the menu title. (ID_MnEdit) can be used to enable
and disable this entire menu. Pull-down menu titles cannot have an associated menu macro.

Note:

Although cursor menus (POP0) must define a title, this title is not displayed.

Cascading Submenus

Pull-down and cursor menu labels use special character (such as ->, <-, and <-<-…) to
control the hierarchy of cascading menus. These special characters indicate submenus and last
items in submenus, and last items in submenus, and can also terminate all parent menus. Each
special character string must be the first characters in an item label.

The special character -> indicates that this item has a submenu, as in the following
example:

[->&Arc]

If you pull down in Draw menu and choose the Arc item or move the cursor to the right end
of the item, the Point Filters submenu is displayed.

The special character <- indicates this item is the last item in a submenu, as in the
following example:

[<C&ontinue]^C^C_arc;

Special characters <-<-… indicate this item is the last item of a submenu and also of its parent
menu, as in the following example:

[->Text]

[->Attributes]

[<-<-Extract. . . ]^C^Cddattext

Separation of Menu Item Labels

To create separator lines, use a label of two hyphens.

[- -]

Because the width of each pull-down and cursor menu is determined by its widest label,
the preceding example expands to become a separator line filling the entire width of the menu. You
cannot choose separator lines from the menu, and any menu macro assigned to them is ignored.

Image Title Menus

34
You define an image tile menu by providing an * * * IMAGE section in the menu file. This
replaces the * * * ICON section used in previous release ( * * * ICON is still valid but might not be
supported in future in future releases).

AutoCAD display images in group of 20, along with a scrolling list box containing the
associated slide names or related text. Image tile submenus are unlimited in length: if an image tile
submenu contains more than 20 slides, AutoCAD provides Next and Previous buttons that the user
can press to leaf through pages of images.

Images Tile Menu Items

The Images section uses submenus similar to the Toolbars and Screen section. As with
Pop menu sections, the first line of the submenu is its title. The title is displayed as the label of the
dialog box that contains the images. Each submenu should be separated by at least one blank line
to clear out items from a previous submenu.

Image tile menu item use item labels to define the text of the scrolling list and the image
itself. The label is followed by an associated menu macro.

Note:
Image the menus contain name tags.

Image Title Item Lables

Labels in an image tile menu generally refer to slide file names instead of text labels that
are displayed on the screen. The slide file name, which can be a single slide or part of a library,
should appear exactly as you would enter it at the VSLIDE command. The slide contains the image
to show for that selection.

Image tile menu labels are displayed in a scrolling list box that can accommodate up to 19
characters per label. This slide file name is typically displayed; however, the following icon menu-
labeling options are also available.

Item Label Description

[sldname] The slide name sldname is displayed in the list box, and the slide sldname
is displayed as an image.

[sldname,labeltext] The text labeltext is displayed in the list box, and the slide sldname in the
slide library slidlib is displayed as an image.

[sldlib(sldname, The slide name sldname is displayed in the list box, and the slide sldname
in the slide library sldlib is displayed as an image.

[sldlib(sldname, The text labeltext is displayed in the list box, and the slide sldname in the
slide library sldlib is displayed as an image.

[blank] When you supply the text blank as in icon label, a separator line is
displayed in the list box and a blank image is displayed.

[labeltext] When the first character of an item label is a space, the text supplied as
labeltext is displayed in the list box and no image is displayed. In this case
you can include related commands and simple items such as Exit without
needing to make slides that contain words.

35
Image Tile Menu Macros

Image tile menu macros can perform the same function as other menu macros; however,
you cannot use the menu macro repetition feature. These menu macros can contain menu
commands, including $I= commands. It is possible, therefore, to construct hierarchical image tile
menus in which a selection displays another image tile menu, and so on. Because the activation on
these menus is sequential rather than nested, there are no limits to the complexity of the structures
you can create.

Displaying Image Tile Menus

The $I= macro command addresses the image tile menu. Before you can display an image
tile menu you must load it. The following syntax loads an image tile menu.

$I= [menugroup.]menuname

The $I=image_poly $I=*

You can also use the AutoLISP menucmd function to load and display image tile menus.
The following code produces the same result as the previous example.

(menucmd “I=mygroup.myblocks”)

(menucmd “I=*”)

Sample Image Tile Menus

The following is a sample image tile submenu called **3DOBJECTS.

** 3DOBJECTS

[3D Objects]

[acad(Box3d, 3D Box)] ^c^cai_box

[acad(Pyramid)] ^c^cai_pyramid

[acad(Wedge)] ^c^cai_dome

[acad(Dome)} ^c^cai_dome

[acad(Sphere) ] ^c^cai_sphere

[acad(Cone)]^c^cai_cone

[acad(Torus)]^c^cai_torus

[acad(Dish)]^c^cai_dish

[acad(Mesh]^c^cai_mesh

36
The following figure shows a portion of the resulting image tile menu.

***3DOBJECTS image tile menu sample

The following is an example of an image tile menu that is used to insert various electronic
parts. The text label is an item that swaps to another image tile submenu that contains various
fasteners.

***IMAGE

**IPARTS

[Electronic Parts]

[cap]^Cinsert cap

[res]^Cinsert res

[neno]^Cinsert neon

[triode]^Cinsert triode

[tetrode]^Cinsert tetrode

[ Fasteners] $I=ifast $I=*

**IFAST

[Fasteners]

[nut632]. . .

To activate this image tile menu, you could choose a menu item such as the following from
any menu.

[Electronic parts] %I=iparts $I=*

In the following variation, the images are retrieved from a slide library named clib; only the
slide name appears in the list box.

** * IMAGE

37
* * IPARTS

[Electronic Parts]

[elib(cap]^Cinsert cap

[elib(res]^Cinsert res

[elib(neon)]^Cinsert neon

[elib(triode)]^Cinsert triode

[elib(tetrode)]^Cinsert tetrode

When successive icon slides from the same library are displayed, the library file remains
open. Therefore, the time required to display an icon menu is significantly reduced.

Preparation of Slides for Image the Menus

You can any slide generated by AutoCAD as an image. However, the optimal use of image
tile menus requires that you take care in preparing slides that will serve as images. Follow these
guidelines:

™ Keep it simple. When an image tile menu is displayed, the user must wait for all images to
be drawn before making a selection. If you are using the image tile menu to show the user
numerous complex symbols, make the images simple versions of the symbols rather than
full renditions. An image should be as simple as possible and yet immediately
recognizable.

™ File the box. Screen space is limited, and images appear in small portions of the full
screen. When making a slide for an image, be sure to fill the screen with the image before
entering the MSLIDE command. If the image is very wide and short, or long and thin, the
image tile menu will look best if you center the image on the screen with the PAN
command before making the slide.

Images are displayed with an aspect ratio of 1.5:1 (1.5 units wide by 1 unit high). If your
graphics area has a different aspect ratio, it can be difficult to produce image slides that are
centered in the image tile menu. If you work within a floating viewport that has an aspect ratio of
1.5:1, you can position the image and be assured that it will look the same when it is displayed in
the image tile menu.

The following commands set up a correctly proportioned viewport. (In this example, a
drawing with no viewports is used and TILEMODE is set to 1.)

Command: TILEMODE

New value for TILEMODE<1>:0


Entering paper space. Use MVIEW to insert Model space viewports.
Command: MVIEW
ON/OFF/Hideplot/Fit/2/3/4/Restore/<First Point>:0,0
Other corner: 3,2
Command: ZOOM
All/Center/Dynamic/Extents/Left/Previous/Vmax/Window/<Scale(X/XP)<: e

38
Command: MSPACE

This viewport is now the proportion of an image tile.

™ Solid filled areas such as wide polylines, traces, and filled solids are visible in image tiles
only if the slide was generated after issuing the SHADE command. Otherwise, they
display as outlines.

™ Remember the main purpose of theses images. Do not overuse images as you encode
abstract concepts into symbols. Images are useful primarily when the user must select a
graphic symbol.

Image Tile Menu Macros


Image tile menu macros can perform the same function as other menu macros; however,
you cannot use the menu macro repetition feature. These menu macros can contain menu
commands, including $I = commands. It is possible, therefore, to construct hierarchical image tile
menus in which a selection display another image tile menu, and so on. Because the activation of
these menus is sequential rather than nested, there are no limits to the complexity of the structures
you can create.

Screen Menus
The screen menu section controls the screen menu area. By default, the screen menu is
disabled. You can enable the screen menu by choosing Display AutoCAD Screen Menu in Drawing
Window on the Display tab of the Preferences dialog box (discussed in Step2).

Creating Screen Menus


The ***SCREEN section label represents the beginning of the AutoCAD screen menus.
The submenu section label show here is identified by the string** S. A simple, concise name, such
as this, is convenient when many separate items reference this submenu as shown in the following
example:

Screen menu file section

* * * SCREEN

**S

[AutoCAD ] ^C^C^P(ai-rootmenus) ^P

[**** ] $=ACAD.OSNAP

[ FILE ] $$=ACAD. 01_FILE

[ EDIT ] $$=ACAD02_EDIT

[ VIEW 1 ] $$=ACAD03_VIEW1

[ VIEW 2 ] $$=ACAD04_VIEW2

[ INSERT ] $$=ACAD.05_INSERT

39
[ FORMAT ] $$=ACAD.06_FORMAT

[ TOOLS 1 ] $$=ACAD.07_TOOLS1

[ TOOLS 2 ] $$=ACAD.08_TOOLS2

[ DRAW 1 ] $$=ACAD.09_DRAW1

[ DRAW 2 ] $$=ACAD.10_DRAW2

[ DIMENSIONS ] $$=ACAD.11_DIMENSION

[ MODIFY1 ] $$=ACAD.12_MODIFY1

[ MODIFY2 ] $$=acad.14_help

[ ASSIST ] $$=ACAD.ASSIST

[ LAST ] $$=ACAD.

Screen Submenus
Screen menu Submenu labels have the following format:

* * menuname [startnum]

The menuname is a string of up to 33 characters containing letters, digits, and the dollar
($), hyphen (-), and underscore (_) characters. The submenu label must reside on a menu file line
be itself and must not contain embedded blanks. An optional integer startnum, which specifies the
starting line of the submenu, can follow menuname.

A submenu can contain any number of items, but each menu area has a limited number of
accessible items (due to the screen size). For instance, if a screen menu submenu has 21 items,
but the screen can display only 20 items at a time, the last item in the submenu is inaccessible.

When a submenu is activated, its items normally replace those of the previous menu
starting at the beginning (menu box 1) and continuing through all items of the submenu. Thus, a
submenu can replace only a portion of the previous menu. You can add an item number after the
section or submenu label to specify replacement starting with a menu item other than 1 as shown
in the following example:

* * SAMPLE 3

When the SAMPLE submenu is activated, the first two menu boxes are unchanged and
submenu replacement begins with menu box 3. If you specify a negative item number, replacement
starts that number of items from the end of the menu (the bottom of the screen).

To restore the previous screen items, a menu item issue the following code without a
submenu label.

$$=

AutoCAD keeps track of the last eight submenus. If you exceed eight, the first menus are
discarded.

40
The following sample Screen menu section demonstrate s the use of submenus.

* * * SCREEN

[EASYmenu]
Blank line

[DRAW. . . ] $$=Draw_Root

Blank line
[EDIT . . . ] $$=edit_root

[Bye ] end

[ -MAIN- ]$$=SCREEN

* *Draw-Root 2

[Line ] line

[Circle ] circle

[Arc ] arc

* *Edit_Root2

[Erase ] $$=Sel_obj erase

[Copy ] $$=Sel_obj copy

[Move ] $$=Obj_sel move

* *Obj_sel 2

* * Sel_obj 2

[Last ] last

[Previous ]previous

[Window ]window

[Crossing]crossing

[-PREV-]$$=

• * * BUTTONS1

redraw

The previous example contains three submenus: Draw_Root, Edit_Root, and Sel_obj.

Draw_Root and Edit_Root are called from the main screen menu when you select the
Draw or Edit menu items. The Draw_Root submenu provides three selection items that correspond

41
to AutoCAD commands. The Edit_Root submenu also contains three selection items, each of
which calls the submenu Sel-obj before executing the appropriate command.

In all cases, a-MAIN-selection item recalls the main screen menu. A menu writes over
(erases) only as many lines of the previous screen menu as it contains. If a screen menu contains
more items than there are boxes on the screen, or if a buttons menu contains more items than
there are buttons available, the excess items are ignored.

Note:

You can use blank lines in menu files to lengthen submenus so that they cover up
previous menus. You can also include blank lines to improve the readability of the file.

Selecting a menu item called Zoom from the main screen menu may activate a submenu
containing the options for the ZOOM command. For an alternative method of calling a command
submenu, see MENUCTL System Variable.

Most screen menus in acad.mnu are loaded at menu box 3, allowing the menu labels
[AutoCAD] and [* * * ] to remain on the screen .

[BLOCKS] $$=X $$=BL

In the preceding example, the following line references the submenu **BL

[BLOCKS] $$=X $$=BL

The following example show how a **BL submenu is displayed on the screen. Notice that
the first list (for ATTDFE) is displayed at menu box 3.

Screen menu file section

* * BL 3

[ATTDEF: ]^C^C_ATTDEF

[BASE : ]^C^C_BASE

[BLOCK: ]^C^C_BLOCK

[INSERT: ]^C^C_INSERT

[MINSERT: ]^C^C_MINSERT

[WBLOCK: ]^C^C_WBLOCK

[XBIND: ]^^C^C_XBIND

[XREF: ]^C^C_XREF

The menu items Last, Draw, and Edit are displayed at the bottom of the screen menu area
because they are part of the **X submenu section, which is referenced by $$=X.

42
In the preceding example, the following line initially references the **X submenu section
with the command $$=X $$=BL

This submenu section blanks out the unwanted text from a previous menu. For this
example, AutoCAD displays the **X submenu and overlays it with the **BL submenu. The result is
shown in the preceding example of the screen menu area, starting at menu box 3.
The following **X submenu, which starts at menu box 3, contains 15 blank lines and ends
with the item labels LAST, DRAW and EDIT. This submenu serves as a base for the other menus
to overlay

15 blank lines

**X

...

[ _ _LAST_ _]$$= $$=

[ DRAW ]^C^C$$=X $$=Draw_root

[ EDIT ]^C^C$$=X $$=Edit_Root

In these last items, LAST restores the previous screen items. DRAW and EDIT both
reference the * * X submenu and the **Draw_Root and **Edit_Root submenus, respectively.

Item labels

If a screen menu does not contain an item label, the first eight characters of a menu macro
appear on the screen menu. In the following example the command would be displayed as SNAP
0.0.

SNAP 0.001

If the label is provided, the first eight characters of the label are displayed in the
appropriate screen menu box. Any addition characters can serve as comments.

Note:

The maximum number of menu items depends on your system. You can retrieve the
number of screen menu boxes with the SCREENBOXES system variable.

The MENUCTL System Variable

The MENUCTL system variable controls the automatic swapping of screen submenus
when a corresponding command is issued. When MENUCTL is set to 1 (On) and an AutoCAD
command is called from a menu item, AutoCAD issues a $$=cmdname (where cmdname is the
name of the command), which calls a screen submenu of the same name of the as the command.
The standard menu acad.mnu takes advantage of this feature by setting MENUCTL to 1 from the
acad.mnl file. Setting MENUCTL to 0 (Off) affects the option of the standard menu but may be
preferable for older custom menus.

43
MENU

MENU loads a menu file

At the Command: prompt, enter MENU.

A menu file is a text file containing the AutoCAD command strings and menu syntax that
define the menu labels and macros. A menu file can contain a section for each of these menu
areas: pull-down menus, toolbars, cursor menu, image tile menus, screen menu, pointing device
button menu, accelerator keys, and digitizer tablet menus.

You can create a customized menu file and use MENU to load the file for use in AutoCAD.

In the Select Menu File dialog box, enter or select a menu file name. To have no menu
display, choose Type It and enter a period (.) on the command line.

AutoCAD loads the appropriate sections of the menu file into the various areas.

44
MENU LOAD
MENULOAD loads partial menu files.

From the Tools menu, select Customize Menus…

At the Command: prompt, enter MENULOAD.

The MENULOAD command displays the Menu Customization dialog box, which allows you
to add partial menu files to an existing base menu, such as acad.mnu. Each menu file (base and
partial) has an associated menu group name. From each menu group, you can access each pull-
down menu that resides in its associated menu file.

After you load the partial menus, you can customize the AutoCAD menu bar by adding or
deleting pull-down menus.

Icon/Button Description

Lists the currently loaded menu files.


.

Specifies the file to load when you choose Load. You can either enter the
file name manually or use the Browse option to select a file from the Select
Menu File dialog box.

45
Removes all existing menu groups from the Menu Group list when you
load a new file menu.

Unloads the menu group highlighted in the Menu Group list.

Loads the specified under File Name

Displays the Select Menu File dialog box in which you can select a menu
file to load.

Customizes the menu-bar item list.

Displays a selected menu file in the Menu Group list.

Icon/Button
Lists all the menus defined in the menu group specified in

46
the Menu Group list.

Lists all the pull-down menus loaded in the AutoCAD application window.
The menu at the top of the list corresponds to the left-most pull-down
menu on the menu bar in the AutoCAD application window. The menu at
the bottom of the list corresponds to the right-most pull-down menu.

Inserts the highlighted menu in the Menus list above the highlighted menu
in the Menu Bar list. If no menu is highlighted in the Menu Bar list, the
highlighted menu in the Menus list is inserted at the top of the Menu Bar
list.

Removes the highlighted menu in the Menu Bar list.

Removes all menus from the menu bar in the AutoCAD application
window.

MENUUNLOAD

MENUUNLOAD unloads partial menu files.

At the Command: prompt, enter MENUUNLOAD.

The MENUUNLOAD command displays the Menu Customization dialog box, which has the
same options as MENULOAD. The only difference between the two commands is in the command
line prompts.

When FILEDIA is set to 0 (Off), MENUUNLOAD displays the following prompt on the
command line.

Enter the name of the MENUGROUP to unload: Enter a name

47
TOOLBAR
TOOLBAR displays, hides, and customize toolbars.
From View menu, select Toolbars…

At the Command: prompt, enter TOOLBAR or TO.


AutoCAD displays the Toolbars dialog box.

Icon/Button Description

Displays or hides toolbars. To turn a toolbar on or off, select the box to the
left of its name.

Displays the New Toolbar dialog box.

Description

48
Specifies a name for the new toolbar.

Specifies a menu group for the new toolbar. For more


information, see “Custom Menu,”

Removes the toolbar selected in the Toolbars list.

Displays the Customize Toolbars dialog box.

49
Moves or copies icons from one toolbar to another. Drag
the icon from the Customize Toolbars dialog box to a
visible toolbar. To copy a tool icon, hold down CTRL while
you drag.

When the Customize Toolbars dialog is displayed, right-clicking any icon


displays the Button Properties dialog box. Right-clicking on an icon that
contains a flyout toolbar displays the Flyout Properties dialog box.

Icon/Button Descripyion

Specifies the tool icon name . If show ToolTips is


selected in the Toolbars dialog box, the name is
displayed when the pointing device moves over
the tool icon.

Display the text displayed at the left end of


the status bar when the pointing device moves

50
over the tool icon

Controls the command or set of the commands


associated with a tool icon.Enter a command in
the box.Separate a series of commands using a
semicolon(;).

Specifies the icon associated with a tool. Select


an icon from the list or choose Edit to modify an icon.

Edit displays the Button Editor dialog box, in


which you can customize an existing button or
create a new one.

This modifies or creat s buttons

Displays the button at its actual size.

Edit one pixel at a time in the selected


color.Press the return button on the pointing device to edit
several pixel at once.

51
Creat lines in the selected color.Press the retutn button on
st
the pointing to set the 1 end point of the line.Drag to draw
the lines Release the return button to complete the line.

Sets pixcels to white.Double -click the erase tool with the


pointing device to set all pixels to white.

Provides close up view of the button icon for pixel editing.

Sets the current color

Clears the editing area.

Opens an exististing button icon for editing.Button icons


are stored as BMP files

52
Undoes the last action.

Saves the custumised button as a BMP file.

Closes the current icon.

Turns on the grid.Each grid dot represents one pixel.

Specifies the tool icon name.If Show Tool Tips


is selected in the Toolbars dialog box,the
name is displayed when the pointin
device moves over the tool icon.

Displays the text displayed at the left of thestatus


bar when the pointing device moves over the tool
icon.

53
Specifies the toolbar associated with the flyout
icon.

Displays the flyout icon specified under Button Icon.


If show This Button's Icon is
selected,AutoCAD uses this icon for the
flyout.Otherwise,the flyout icon displayed is
the icon of the last flyout selected.

Specifies the icon associated with a tool.Select an icon


from the list,or choose edit to modify an icon.

Edit displays the Button Editor dialog box,in which you can
customise an existing button or creae a new one.

54
Creating Regions
Description

Creates a region from a set of entities. The given entities must form a closed coplanar region. This
method will create a region out of every closed loop formed by the input array of curves. AutoCAD
converts closed 2D and planar 3D polylines to separate regions then converts polylines, lines, and
curves that form closed planar loops. If more than two curves share an endpoint, the resultant
region might be arbitrary.
You can explode a region into the individual loops by using the Explode method. The Boolean
method allows you to create composite 3D solids or regions from the intersection, union, or
subtraction of a solid or region from another solid or region.

The total number of Region objects created is Ubound(objRegions) - Lbound(objRegions) + 1.

Syntax

RetVal = object.AddRegion(ObjectList)

Elements

ObjectList Array of Objects;


The array of objects forming the closed coplanar face to be made into a region. This array may
contain the following object types: Line, Arc, Circle, Elliptical Arc, LightweightPolyline, Spline.

Return Value

55
RetVal Variant;
This method outputs an array of the newly created Region objects.

Editing Regions
Description

A bounded planar face consisting of lines, circles, arcs, elliptical arcs, and spline curves.
Each object in the region retains its layer, linetype, and color. AutoCAD deletes the original objects
after converting them to regions and does not hatch the regions by default.
You can explode a region into the individual loops by using the Explode method. The Boolean
method allows you to create composite 3D solids or regions from the intersection, union, or
subtraction of a solid or region from another solid or region.

To create a region, use the method AddRegion. To edit or query a region, use the following
methods and properties:

Creating 2D Entities From Regions

Methods
ArrayPolar
Description

Creates a polar array of objects given a NumberOfObjects, AngleToFill, and CenterPoint.


AutoCAD determines the distance from the array’s center point to a reference point on the last
object selected. The reference point used depends on the type of object previously selected.
AutoCAD uses the center point of a circle or arc, the insertion point of a block or shape, the start
point of text, and one endpoint of a line or trace.
Note that this method does not support the Rotate while Copying option of the AutoCAD ARRAY
command.

Polar array with NumberOfObjects = 6, AngleToFill = 180, CenterPoint = 0,0,0.


This method cannot be executed while simultaneously iterating through a collection. An iteration
will open the work space for a read-only operation, while this method attempts to perform a read-
write operation. Complete any iteration before you call this method.

Syntax

RetVal = object.ArrayPolar (NumberOfObjects, AngleToFill, CenterPoint)

Elements

NumberOfObjects Integer; input-only


The number of objects to be created in the polar array. This must be a positive integer greater than
1.

56
AngleToFill Double; input-only
The angle to fill in radians. A positive value specifies counterclockwise
rotation. A negative value specifies clockwise rotation. An error is returned for an angle that equals
(0.0).

CenterPoint Variant (three-element


array of doubles); input-only
The 3D WCS coordinate specifying the center point for the polar array.

Return Value

RetVal Variant Array (array of objects);


The array of new objects.

ArrayRectangular
Description

Creates a 2D or 3D rectangular array of objects. For a 2D array, specify the NumberOfRows,


NumberOfColumns, DistBetweenRow, and DistBetweenColumns
A rectangular array is constructed by replicating the object in the selection set the appropriate
number of times. If you define one row, you must specify more than one column and vice versa.
The object in the selection set is assumed to be in the lower left-hand corner, and the array is
generated up and to the right. If the distance between rows is a negative number, rows are added
downward. If the distance between columns is a negative number, the columns are added to the
left.

AutoCAD builds the rectangular array along a baseline defined by the current snap rotation angle.
This angle is zero by default, so the rows and columns of a rectangular array are orthogonal with
respect to the X and Y drawing axes. You can change this angle and create a rotated array by
setting the snap rotation angle to a nonzero value. To do this, use the Snap Rotation Angle
property.

Rectangular array with NumberOfRows = 5, NumberOfColumns = 4, DistBetweenRows = 1,


DistBetweenColumns = 1.

Syntax

RetVal = object.ArrayRectangular (NumberOfRows, NumberOfColumns, NumberOfLevels,


DistBetweenRows, DistBetweenColumns, DistBetweenLevels)

Elements

NumberOfRows Integer; input-only

57
The number of rows in the rectangular array. This must be a positive number. If this number is 1,
then
NumberOfColumns must be greater than 1.

NumberOfColumns Integer; input-only


The number of columns in the rectangular array. This must be a positive number. If this number is
1, then
NumberOfRows must be greater than 1.

NumberOfLevels Integer; input-only


The number of levels in a 3D array.

DistBetweenRows Double; input-only


The distance between the rows. If the distance between rows is a positive number, rows are added
upward from the base entity. If the distance is a negative number, rows are added downward.

DistBetweenColumns Double; input-only


The distance between the columns. If the distance between columns is a positive number, columns
are added to the right of the base entity. If the distance is a negative number, columns are added to
the left.

DistBetweenLevels Double; input-only


The distance between the array levels. If the distance between levels is a positive number, levels
are added in the positive direction from the base entity. If the distance is a negative number, levels
are added in the negative direction.

Return Value

RetVal Variant Array (array of objects);


The array of newly created objects.

Copy
Description

Duplicates the given object to the same location.

Syntax

RetVal = object.Copy

Elements

None

Return Value

RetVal Object;
The newly created duplicate object.

Erase
Description

58
Erases the specified object.
When erasing a selection set, all the objects in the selection set are erased.

Syntax

object.Erase

Elements

None

Return Value

None

Move
Description

Moves an object along a vector.


The two points you specify define a displacement vector indicating how far the given object is to
be moved and in what direction.

Syntax

object.Move Point1, Point2

Elements

Point1 Variant (three-element


array of doubles); input-only
A 3D WCS coordinate specifying the first point of the move vector.
Point2 Variant (three-element
array of doubles); input-only
A 3D WCS coordinate specifying the second point of the move vector.

Return Value

None

Rotate
Rotates an object around a base point.

Syntax

object.Rotate BasePoint, RotationAngle

Elements

Base Point Variant (three-element array of doubles); input-only

59
A 3D WCS coordinate specifying the point through which the axis of rotation is defined as parallel
to the Z axis of the UCS.
Rotation Angle Double; input-only
The angle in radians to rotate the object.
Return Value

None

ScaleEntity
Description

Scales an object equally in the X, Y, and Z directions.

Syntax

object.ScaleEntity BasePoint, ScaleFactor

Elements

BasePoint Variant (three-element array of doubles); input-only


.
ScaleFactor Double; input-only
The factor by which to scale the object. The dimensions of the object are multiplied by the scale
factor. A scale factor greater than 1 enlarges the object. A scale factor between 0 and 1 reduces the
object.

Return Value

None

TransformBy
Description

Moves, scales, or rotates an object given a 4 x 4 transformation matrix.


The following table demonstrates the transformation matrix configuration, where R = Rotation, and
T = Translation:

R00 R01 R02 T0


R10 R11 R12 T1
R20 R21 R22 T2
0 0 0 1
This method will return an error if transformation matrix is not correct.

Syntax

object.TransformBy TransformationMatrix

Elements

TransformationMatrix Variant (4 x 4 array of doubles); input-only

60
A 4 x 4 matrix specifying the transformation to perform.

Return Value

None

Update
Description

Updates the object to the drawing screen.

Syntax

object.Update

Elements

None

Return Value

None

Properties
Application
Description

Gets the Application object.


The Application object represents the application’s frame controls and path settings, and provides
the means to navigate down the object hierarchy.

Syntax

objVariable = object.Application

Element

Application Application object; read-only

Area
Description

Gets the enclosed area of an arc, circle, ellipse, lightweight polyline, polyline, region, or planar-
closed spline.
Wide polylines:
The area defined by the center of the width is returned.
Open objects such as arcs, spline curves, and open polylines:
The area is computed as though a straight line connects the start point and endpoint.
Regions:
The combined area for the objects in the region is returned.

61
Syntax

dblVariable = object.Area

Element

Area Double; read-only


The area is returned in square drawing units.

Centroid
Description

Gets the center of area or mass for a region or solid.


The Centroid is returned as X, Y, and Z coordinates defined as a variant.

Syntax

vrntVariable = object.Centroid

Element

Centroid Variant (three-element


array of doubles); read-only
The 3D coordinate representing the centroid.

Color
Description

Specifies the color of an entity or layer.


Colors can be set and read as numeric index values ranging from 0 to 256. Constants have been
provided for the standard seven colors, as well as the BYBLOCK and BYLAYER designations.
If you use acByBlock, AutoCAD draws new objects in the default color (white or black depending
on your configuration) until they are grouped into the block. When the block is inserted in the
drawing, the objects in the block inherit the current setting of the color property.

If you use acByLayer, new objects assume the color of the layer upon which they are drawn.

Syntax

intVariable = object.Color
object.Color = <integer>

Element

Color Integer; read-write


The default color designation is acByLayer. Use a color index number from 0 to 256, or one of the
constants listed here:

62
acByBlock
acByLayer
acRed
acYellow
acGreen
acCyan
acBlue
acMagenta
acWhite

Entity Name
Description

Specifies the name of an entity.


The entity name is equivalent to the class name of the object. When querying AutoCAD objects,
use the EntityType property. When querying custom objects, if no EntityType has been provided,
you can use this property to identify the entity.

Syntax

strVariable = object.EntityName

Element

EntityName String; read-only


The name of the entity.

Layer
Description

Specifies the layer for an entity.


All entities have an associated layer. The document always contains at least one layer (layer 0). As
with linetypes, you can specify a layer for an entity. If you don’t specify a layer, the current active
layer is used for a new entity. If a layer is specified for an entity, the current active layer is ignored.
Use the ActiveLayer property to set or query the current active layer.
Each layer has associated properties that can be set and queried through the Layer object.

Syntax

strVariable = object.Layer
object.Layer = <string>

Element

Layer String;
The name of the layer.

63
Linetype
Description

Specifies the linetype of an entity.


The linetype values identify the series of dots and dashes used for drawing lines. If you don’t
specify a linetype, the current active linetype is used for a new entity. If a linetype is specified for
an entity, the current active linetype is ignored. Use the ActiveLinetype property to set or query the
current active linetype.

Special linetype entries are as follows:

CONTINUOUSThe default linetype, which is automatically created in the linetype symbol table.
BYLAYER The linetype value of the entity’s layer.
BYBLOCK The linetype value of the entity’s surrounding block definition’s current block
reference.

Syntax

strVariable = object.Linetype
object.Linetype = <string>

Element

Linetype String;
The linetype of an entity. The default linetype is the linetype of the layer (BYLAYER).

MomentOfInertia
Description

Gets the moment of inertia for the solid.


The moment of inertia is returned as X, Y, and Z coordinates defined as a variant. It is calculated
based on the current coordinate system.

Syntax

vrntVariable = object.MomentOfInertia

Element

MomentOfInertia Variant (three-element


array of doubles); read-only
A 3D coordinate based on the current coordinate system.

64
ObjectID
Description

Gets the object ID of the entity.

Syntax

lngVariable = object.ObjectID

Element

ObjectID Long; read-only


The object ID of an entity.

Perimeter
Description

Gets the total length of the inner and outer region loops.

Syntax

dblVariable = object.Perimeter

Element

Perimeter Double; read-only


The perimeter is returned in drawing units.

PrincipalDirections
Description

Gets the principal directions of the solid or region.


The principal directions are returned as X, Y, and Z coordinates defined as a variant. They are
calculated based on the current coordinate system.

Syntax

vrntVariable = object.PrincipalDirections

Element

PrincipalDirections Variant (three-element


array of doubles); read-only
The X, Y, and Z coordinates calculated on the current coordinate system.

PrincipalMoments
Description

Gets the principal moments property of the solid or region.


The principal moments are returned as X, Y, and Z coordinates defined as a variant. They are
calculated based on the current coordinate system.

65
Syntax

vrntVariable = object.PrincipalMoments

Element

PrincipalMoments Variant (three-element


array of doubles); read-only
The X, Y, and Z coordinates calculated on the current coordinate system.

ProductOfInertia
Description

Gets the product of inertia of the solid or region.


The product of inertia is returned as X, Y, and Z coordinates defined as a variant. It is calculated
based on the current coordinate system.

Syntax

vrntVariable = object.ProductOfInertia

Element

ProductOfInertia Variant (three-element


array of doubles); read-only
The X, Y, and Z coordinates calculated on the current coordinate system.

RadiiOfGyration
Description

Gets the radius of gyration of the solid or region.


The radius of gyration is returned as X, Y, and Z coordinates defined as a variant. It is calculated
based on the current coordinate system.

Syntax

vrntVariable = object.RadiiOfGyration

Element

RadiiOfGyration Variant (three-element


array of doubles); read-only
The X, Y, and Z coordinates calculated on the current coordinate system.

Visible
Description

66
Specifies the visibility of a drawing object or the application.
If you specify an object to be invisible, it will be invisible regardless of the application visible
setting. Specifying the application to be invisible allows you to run tasks in the background without
having to see the component.

Syntax

blnVariable = object.Visible
object.Visible = <boolean>

Element

Visible Boolean;
For the Group object this property is write-only. For all other valid objects this property is read-
write.

acOn:
The object or application is visible.

acOff:
The object or application is not visible.

Accessing External Databases

67
Using external databases to store nongraphic attributes for objects can reduce the size of
drawings, simplify reporting, and enable you to edit external data.
AutoCAD can associate, or link, nongraphic attributes stored in external database
programs such as dBASE III, ORACLE, and Microsoft Access (using ODBC) with
graphic objects in your AutoCAD drawing. You can use all of the external database feature
without prior knowledge of databases or query languages. However, it is helpful to be
familiar with the standard structured query language ANSI SQL.
After linking, you will be capable of:
1. Selecting objects based on nongraphic data
2. Creating text objects based on linked data values
3. Executing query operations based on graphic objects
4. Creating new database files
5. Generating reports

Use of SQL

SQL stands for Structured Query Language. It is a standard language used by databases and in
application for multiple platforms. In database model, a table is a two dimensional data structure
made of rows & columns. A row describes one of the elements in the table. The description is a list
of attributes pertaining to the element. A column specifies some aspects or attributes of the objects.
The intersection of a particular row and column contains a single data value or attribute value.

Organizing External Database

Organization of Databases can be done many ways. AutoCAD puts no restriction on type or
amount of data or organization of databases & it does not requires special columns or tables.
Consider the following while using databases:
1. Organization of your data: one table, many table, many databases etc.
2. Type of data desired to be linked to AutoCAD objects.
3. Whether it is desired to link multiple objects to the same row of data or each row to
link to only one object.
4. Link structure- whether to link more than one row or table or database or DBMS.
5. Keys that identify specific rows.
6. The type of out put desired.

Connecting to Existing Databases

When you install AutoCAD and select Full installation, or choose External Databases after
selecting Custom installation, AutoCAD will be installed and configured for connecting to
the sample database. You can also connect AutoCAD to the sample database during an
AutoCAD session. If you want to access either the ORACLE or ODBC databases using the
supplied DBMS drivers, run the configuration program by double-clicking the External
Database Configuration icon in the AutoCAD program folder.
Viewing External Data

All operations that require selecting a row are accessible from the ASEROWS command.
Some operations change only the database and have no effect on the drawing. These

68
operations include viewing a row, adding a row, deleting a row, or changing the values of
the data, and creating selection sets. Other operations affect the drawing directly by
changing the graphic information or by adding links to the drawing database.

Before using database data, set the cursor state and specify whether data can be modified.
The cursor state determines the accessibility of table rows that belong to the set. The cursor
is a mechanism that identifies the current position in the table for a set of rows that meet a
query condition. In AutoCAD, the cursor has one of three states: scrollable, updatable, or
read-only.
With a scrollable cursor, you can navigate the rows in a forward or backward direction.
With updatable and read-only cursors, the cursor moves only in the forward direction. You
cannot update read-only rows, but you can use the SQL UPDATE command on updatable
rows.

You can operate on only one row at a time. The row you select for manipulating is the
current row. The simplest way to make a row current is to select all rows (this is equivalent
to SELECT * FROM <current table> in SQL) and then locate a particular row using the
First, Last, Next, and Previous options for scanning the table. Another way is to use a key
to search for a row or rows using an SQL WHERE clause. You can also select a row
graphically by selecting the object it is linked to.

Viewing and Accessing New Databases Dynamically

If a new database object is created, such as a new table created with a CREATE TABLE
statement from the SQL Editor or from another user or application on a network, that table
or other database object will not be immediately visible in the lists in the ASE dialog
boxes.
To view or access the new database object, you must select a different superior database
object, and then select the new database object. Selecting the new database object adds it to
the database objects list. For example, if your current database object settings are
DB3.CAT.SCH.TABLE1 and a new TABLE2 was just added to the SCH schema, you
should choose a different schema, catalog, or environment. The new table will be
contained in the lists the next time they are viewed. If only one scheme, catalog, and
environment are contained in the lists, disconnect and reconnect to the environment.

You can also set an environment by:


Using Set By in the Administration dialog box; you select the database object by selecting
the AutoCAD object linked to it
Using Path in the Administration dialog box, when Catalog and Schema are turned off (the
current driver does not support catalog and schema)

69
Modifying External Data

The data in your database is likely to require updating eventually. For example, a database
containing an EMPLOYEE table might contain the names of employees whose addresses
have changed. To edit information in the table, first choose the row that contains the data.
Then, make that the current row. In the AutoCAD user interface, the current row is the one
that appears on the screen or in a list box.
To edit a table row
Command: ASEROWS

70
You can also change the database by deleting rows from the table. For example, if an
employee leaves the company, you can delete the relevant personnel information.
To delete a row from a table

You can make changes to the database by adding rows to the table. For example, when a
new employee joins the company, you can add information about the employee--name,
room, extension, and so on--to the database.

Defining Key Columns

When you link an AutoCAD object with data in an external database, you specify the row
or rows in the database table by using a key. The key specifies a column or set of columns
in the table and a value against which the column values are matched. A key is used to
search for and select specific information in the database. For example, in the sample table
below, if the key column is Inv_ID and a value of 173 is specified, the Inv_ID column of
the table must have a value of 173 to match. The key identifies one or more database rows
to attach to the object.

Inventory Table

INV_ID TYPE DESCRIPT MFR PRICE ROOM EMP_ID


1 furniture 6x3 couch FutonsRu 800 101 1000
119 furniture file cabinet MetalWork 35 118 1024
173 hardware telephone Baby Bell 150 118 1024

A unique key is one that matches only one row in a table. A key that is not unique can
identify more than one row in a table. The uniqueness of a key depends upon the data in
the table.
A compound key consists of more than one column, for example, Type = furniture and
Price = 800. A compound key does not guarantee a unique key.
A unique compound key is a key that is based on more than one column and that locates
only one row in the table. For example, two rows in the previous inventory table both

71
contain the Type column value furniture. In the first row, the value for a second column
called Room is 101. In the second row, the value for the same column is 118.
If you search for the Type column value furniture with a key based on Type only, the query
retrieves two rows; the first has a value for Room of 101, the second a Room value of 118.
If, however, you search using a compound key based on both Inv_ID and Rooms the query
retrieves the first row encountered (because you created a unique compound key).

Setting Link Paths

A link path identifies the database object hierarchy: environment.catalog.schema.table. A


link path name specifies key columns for the current table identified by its link path. You
might register it by selecting LAST_NAME and FIRST_NAME as the key columns. A
link path name is used to distinguish between multiple instances of a registered table. A
link path name is an alias for the link path. It is recommended that key values and link path
names be determined by their relevance to a particular project and that all drawings use the
same scheme so that they can be used together.

In the following example, the link path name is DB3.CAT.SCH.Employee


(Employee_Name).

In the following example, the link path name is DB3.CAT.SCH.Employee

(Employee_Title).

The same link path name can be used in multiple drawings. It can define the same link
path, or it can define different link paths.

72
For example, if in a block the name for the link path having LAST_NAME and ROOM as
key columns is EMPLOYEE_NAME instead of EMPLOYEE_LOCATION, and that block
is imported into a drawing with links to EMPLOYEE_NAME, all links in the block would
be discarded. To avoid losing any link information, you should give unique link path
names to the block before it is included in the drawing.

If the link path resides in an externally referenced drawing and has the same key columns,
it is considered identical to the link path in the current drawing. However, if it has the same
link path name and different key column information, it is considered a duplicate. To avoid
confusion with the same link path name in the main drawing, the link path name is given a
prefix of the attached drawing name.

Setting Link Paths

Defining Primary and Secondary Link Path Names

You can create a single link from one object to multiple tables (within a DBMS) that share
the same key columns by creating two link path names that have the same key column or
columns. You make one a primary link path name and the other a secondary link path
name. The secondary link path name becomes an alias or a map to the first (primary) link
path name. Thus, a single link points to multiple tables that have the same key column
definition and there is no need to create duplicate links for each table.

For example, the following Water table has the key field PIPE_ID. The link path name for
this table is WATER_LPN.

Water table

PIPE_ID MATERIAL AGE


1234 Cast Iron 25
2123 Cast Iron 30
3215 PVC 10

Suppose you make a link from an object to the first row with a key value of 1234. You can
then select the object and view this linked row. A second table, called Maint, has the same
key column as the Water table--PIPE_ID.

Maint table

PIPE_ID DATE MAINT_DESC


1234 0494 Replaced Pipe
2123 0392 Fixed Break
3215 0893 Replaced Pipe

73
Because both tables have the same key column, you can create a secondary link path name
for the Maint table. This new link path name is called MAINT_LPN. You can then access
the data in the Maint table using either the primary or the secondary link path name
without having to relink the object to the Maint table, thus without having to duplicate link
data.
When you link a drawing object to a database record using either the primary or the
secondary link path name, the primary link path name's key values are always used. When
you create a link using a secondary link path name, you will not be able to access records
from tables referenced through the primary link path name by using this link. In order to
access multiple tables from one link path name, all links must be created using the primary
link path name.

Associating Database Rows with AutoCAD Objects

Choosing Isolation Levels

Isolation levels refer to the integrity of the data retrieved in an SQL statement when
multiple users are accessing the data simultaneously. Depending on the isolation level,
results of a query can be affected in different ways.

Linking Objects to the Database

You can link more than one AutoCAD object to a single row. Furthermore, using
databases and tables from one or several DBMS programs, you can link more than one row
to one AutoCAD object. You cannot create links to OLE objects.

Links to databases are stored in the AutoCAD drawing. You can modify links only when
the drawing is loaded into AutoCAD, but you can modify the linked database values and
view them from either the DBMS or AutoCAD. The data is stored in the native external

database format and is available to the DBMS even when the drawing is not loaded in
AutoCAD.

74
One advantage of using external database commands is being able to manipulate database
data from AutoCAD. Another is the ability to link that data to graphic objects in the
drawing. By linking external data to AutoCAD objects, you can manipulate data more
quickly by selecting the AutoCAD objects that are linked to the data. (You can link more
than one AutoCAD object to a single row and link more than one row to a single
AutoCAD object.) The greatest advantage is that, in storing links to the external database,
you can avoid storing that data in your drawing. Many drawings can share the data in a
database.

In addition to maintaining link information in the main drawing, AutoCAD can access
links to objects in xrefs and blocks. You can create a link to one or more objects and then
later include them in a block or an xref. Furthermore, you can have multiple levels of
nesting by including a block that contains a link within another block.

Referencing Link Path Names in Blocks and Xrefs

Links to blocks and external references (xrefs) are established using link path names just as
they are for objects in the main drawing. The current database object settings in the main
drawing are not affected by the link path name attached to the block or xref. However, the
names of the database objects in the block or xref appear in the database objects list as
available. A link path name in a block or xref attached to the main drawing has one of the
following characteristics:

Unique
The incoming link path name is contained in the block or xref only and no link path with
the same name exists in the main drawing.

Identical
The incoming link path name is already contained in the main drawing, and both link path
names have the same structure (same link path and key columns).

Duplicate
The incoming link path name is already contained in the main drawing but has a different
structure--the same link path name, but a different link path and/or key columns.
Certain operations, such as detaching xrefs or manipulating link path names of the main
drawing, can change the characteristic of an xref's link path name and put it into a different
category. However, its original characteristic will be maintained throughout an ASE
editing or xref session.

Using Identical or Unique Link Path Names

If a block or xref contains a unique link path name (not defined in the main drawing), it is
displayed the same as any other link path name of the main drawing. If a block or xref
contains a link path name identical to one in the main drawing, these xref link path names
are combined into one operable link path name in the main drawing. This one link path
name then supports common operations such as linked object selection and links export

75
across multiple xrefs. In this way, many identical link path names that are attached to a
drawing only need to be listed once as a single link path name and can be easily selected
and used in filtering. There is no difference in how you access and view links in blocks or
xrefs and links in the main drawing as long as they have unique or identical link path
names.

Using the Bind option of XREF may cause problems when you are attempting to rename
or erase a link path name in the main drawing if it is from, or also used in, an attached xref.
Use the Detach option of XREF on the xref before renaming or erasing link path names.

Using Duplicate Link Path Names in Xrefs

If an xref contains a duplicate link path name (having the same name as the main drawing,
but a different link path and/or key columns), AutoCAD displays the link path names with
a prefix of the xref file name, as it does for blocks. Thus, they are temporarily unique
during their attachment. However, duplicate link path names should be the exception rather
than the rule.

Creating Links to Xrefs

You can create links directly to objects and then include them in xrefs, and you can make
links directly to xrefs, but you cannot make links directly to objects nested within an xref.
For example, you can make links to objects within office.dwg, and then from your main
drawing floorplan.dwg, you can attach the drawing office.dwg as an xref. You can then
make a link to office.dwg itself, but not to an object within the xref. You can then change
the links so that they associated with another xref.

AutoCAD cannot create, delete, or modify links to objects nested within xrefs. If a drawing
has objects that already contain links, and the drawing is later attached as an xref, the links
to those objects nested in the xref can be viewed (read) only. However, they can be
created, deleted, or modified after the drawing attached as an xref is detached from the
main drawing.
You can use the Bind option of XREF on xrefs whose link path names are duplicated in the
main drawing. However, the duplicated link path names from the xref and their associated
link information are lost after execution. To prevent their loss, load the xref as a separate
drawing and rename the corresponding link path names. A link path name from the main
drawing can be erased or renamed if there is a duplicate link path name.

Creating Links to Blocks

Command: ASEROW
Windows: Choose rows from External Database Toolbar.

You can create links directly to objects and then include them in blocks, and you can make
links to a block, but you cannot make links directly to objects within a block. For example,
you can create links to objects, and then from those objects make a block called

76
office.dwg. From your main drawing, floorplan.dwg, you include the block office.dwg.
You can make a link to the block itself (as described in "To link an AutoCAD object to a
row"), but not to any objects within the block. You can then change links from one block
to another block.

When a block is inserted into a drawing, AutoCAD creates a block definition. If the block
contains nested objects with links, these links are stored in the block definition. If a link is
made to a block reference (an instance of the block), the link is stored with the block
reference, not the block definition.
Block link information becomes accessible as soon as the block is inserted into the current
drawing. Block link information becomes inaccessible (detached) as soon as the block is
purged.

A block definition and its associated link information is maintained when you use
WBLOCK. Objects containing links that become nested within a block maintain their link
information after the block is exploded.
If a block has objects that already contain links and the block is later included in a drawing,
the links to those objects nested in the block can be viewed (read), deleted, and modified.

Editing Links

You can edit and delete links in the main drawing and to blocks included in the drawing
using ASELINKS. When you change a link, you specify the scope of the change: all links
to the object or only those within the environment, catalog, schema, or table. You select
the object in the drawing whose link you want to modify. Then you select the row you
want to link the object to. Changing a link does not change the data in the external
database.

To edit a link

Command: ASELINKS
Windows: Choose LINKS from External database Toolbar.

Use ASELINKS command then select the object whose link is desired to be changed. The
key value list in the links dialogue box displays the key value of the row linked to the
object. Choose rows to open the rows dialogue box. Select Rows and use the navigation
keys to select the row desired to link the object to. To update the link, choose OK in the
row dialogue box.
To delete a link to the selected object
Command: ASELINKS
At the Select objects prompts, select the object whose link is to be deleted.
Choose delete to delete the link information listed in the key values box, or choose delete
all to delete all link information if more than one link has been created for the selected
object.

77
You can also delete a link by selecting the row an object is linked to instead of selecting
the object.
To delete a link to the current row
Command: ASEROWS
Select the row whose link is to be deleted. Then Select Link. Choose delete to delete the
link from the object connected to the current row.

Accessing Links in Xrefs and Blocks

If you want to view or change links to an object that is nested in an xref or a block, use the
Selected Object list in the Links dialog box to view its linked values. The list shows the
name of the base object within the selected object and all parent block or xref names,
regardless of whether the selected object contains a link.
For example, you might select Chair, which contains the link to the current row. Chair is
nested in a block called Office, which is part of an xref called furnitur.dwg.

AutoCAD searches for links to the highest level of nested objects--in this case,
furnitur.dwg. The Selected Object list will contain a hierarchical list of drawing objects
associated with Chair. The Key Values list does not display any linked values because
furnitur.dwg does not contain links. Similarly, when the base object Line, which is used to
create the Chair block, is selected, the Key Columns list remains empty because Line is not
linked to a row. Key values are displayed only when Chair is selected in the list or when
Nested Links is checked under Selected Object.

Rows can have links to an xref or a block and separate links to nested objects within that
xref or block. The Office block can be linked to one row, Chair to another row, and Line to
a third row.

78
By default, you can view links only to the selected object and not to its nested objects. If
you want to change or delete links in a block or to view links to nested objects, select
Nested Links. All links are displayed in the Key Values list. You cannot create, change, or
delete links in xrefs.

Updating or deleting links in a block changes the links for every insertion of that block.

Editing Rows Linked to Objects

Links between AutoCAD objects and external data are used for a variety of purposes,
including updating the external database from within AutoCAD, exporting link data to
database files, and selecting objects linked to nongraphic data. The simplest and most
common use of external data is to view it with the graphic objects it relates to. Use either
ASEROWS or ASESQLED to modify rows.
Several important issues arise when objects are linked to a row in a table (see "To edit a
table row"):

When you edit a row, all objects linked to that row reflect the changes.
If you edit a row linked to a displayable attribute, use the Reload DA option of the
ASEADMIN command to update the displayable attributes with the new values (see "To
create a displayable attribute").
If you edit a column, ASEROWS prompts you to update the links. If you edit a column
using ASESQLED, the links between the drawing objects and the external data are not
maintained.

If you want to change data for only one of the linked objects, use ASEROWS to create a
new row for that object only and enter the new information. Once you have created a new
row, you must use ASELINKS to link that object to the new row.

Creating Text Objects from Database Rows

After you have created a link between the drawing object and a row in the external
database, you may find it helpful to add a visual link near the linked drawing object so that
you know which row it is linked to. A displayable attribute is an AutoCAD block
containing text that is linked to a row in the database. Adding displayable attributes to your
drawing is similar to using attributes with blocks, as described in "Creating Attributes."
The text reflects the attribute values in the linked row. You can store the displayable
attribute in the drawing near the object it describes.

Inventory table

INV_ID TYPE DESCRIPT MODEL PRICE ROOM EMP_ID


1 furniture 6x3 couch lounger 800 101 1000
38 furniture adjustable chair comp pro 200 129 1017
119 furniture file cabinet fc 15x27d 35 118 1024

79
If you modify the data in the external database, you can update the displayable attributes
by selecting Reload DA in the Administration dialog box.
Selecting Objects Using Nongraphic Search Criteria

You can use linked nongraphic data to find and select graphic objects in the drawing. For
example, you can find all the vacant offices in a building or a specific fastener in an
assembly. You can select graphic objects by their nongraphic attributes, highlight the
selected objects, or create a selection set of objects.
Two options in the Rows dialog box--Select and Unselect--add highlighted objects to or
removes them from the selection set. Displaying highlighted objects makes it easy to see
when you have the correct row selected.

To create a selection of objects linked to the current row


ASESELECT gives you more flexibility; you can create a selection set based on a
combination of graphic and nongraphic data. This command creates a selection set from
sets A and B: graphically selected linked AutoCAD objects and AutoCAD objects linked
to search criteria in the current table.

A Intersect B
Creates the selection set of objects belonging to both selection sets.

A Union B
Creates a selection set made up of all AutoCAD objects linked to rows meeting search
criteria and all the selected graphic objects.

Subtract A-B
Creates a selection set of objects based on the results of subtracting the second selection set
from the first selection set.
Subtract B-A

Creates a selection set of objects based on the results of subtracting the first selection set
from the second selection set.
For example, executive offices have been upgraded with new couches. You can use
ASESELECT to locate executive offices. The office layout in the following illustration
shows furniture in each of the offices. To locate inventory, you link all the fixtures in the
drawing to the row with a matching INV_ID in the INVENTRY table.

To create a selection set from graphic and nongraphic data


If the PICKFIRST system variable is set to 0 (off), use the Previous option of SELECT to
obtain the selection set created with either ASESELECT or ASEROWS.

Exporting Associated Data

With external database commands, you can produce reports and materials lists based on
information linked to your drawings. AutoCAD does not provide direct reporting
capability. Reports are generated by the products best suited to the task--the DBMS and

80
report-writer software. However, AutoCAD's external database commands simplify the
process.
With AutoCAD you could structure your data so that each object in the drawing is linked
to only one row and each row is linked to only one object. Although tables do not store
information on the objects linked to them, you can produce reports easily because each row
represents one object in the drawing.

With external database commands you can link more than one object to a single row,
which reduces the size of your database when objects do not have unique attributes. If you
have structured your data this way--with shared rows--there is no way to know how many
objects are linked to a single row from the DBMS. ASEEXPORT provides a way to
retrieve that count information by exporting link information in the drawing, and in any
xrefs and blocks it contains, in various formats (the format native to your DBMS, comma-
delimited format, or space-delimited format). You can combine this information with the
data in the tables to produce a report.

Exporting Associated Data

With external database commands, you can produce reports and materials lists based on
information linked to your drawings. AutoCAD does not provide direct reporting
capability. Reports are generated by the products best suited to the task--the DBMS and
report-writer software. However, AutoCAD's external database commands simplify the
process.
With AutoCAD you could structure your data so that each object in the drawing is linked
to only one row and each row is linked to only one object. Although tables do not store
information on the objects linked to them, you can produce reports easily because each row
represents one object in the drawing.

With external database commands you can link more than one object to a single row,
which reduces the size of your database when objects do not have unique attributes. If you
have structured your data this way--with shared rows--there is no way to know how many
objects are linked to a single row from the DBMS. ASEEXPORT provides a way to
retrieve that count information by exporting link information in the drawing, and in any
xrefs and blocks it contains, in various formats (the format native to your DBMS, comma-
delimited format, or space-delimited format). You can combine this information with the
data in the tables to produce a report.

Accessing External Data with SQL

The external database commands available through AutoCAD are primarily for querying
the database as it relates to objects in a drawing. However, you might need to manipulate
data as it relates to other tables within the database. When you need greater data
manipulation capabilities, you can issue SQL statements from AutoCAD to query external
databases directly. For example, to add rows to an external database table directly without
using the Edit or Insert options of ASEROWS, you could include these two lines in a text
file:

81
insert into employee values (1035, 'Park', 'John', 'Sales', 'Coordinator', '','')
insert into employee values (1036, 'Burns', 'Julie', 'Engineering', 'Programmer', '', ''

To query external databases


Command: ASESQLED

All external database commands except ASESQLED have options you can use to change
the current database objects. ASESQLED changes only the environment, catalog, and
schema. All tables within the selected schema are accessible using SQL statements (see
"Opening Files Containing Links").

Checking Data Integrity

Conflicts between an external database and a drawing can occur if the objects in the
drawing or the data in the database are altered in some ways. These conflicts are the result
of a loss of data integrity when links still exist to a record that has been deleted from the
database. This problem occurs when you do any of the following:

Delete a record from a database when the drawing to which it's linked is not loaded in
AutoCAD or when AutoCAD is not loaded. AutoCAD is a single drawing file
environment, and the database management systems are not aware of the graphics links
stored in the AutoCAD drawing.
Use an SQL DELETE FROM statement in ASESQLED. The SQL DELETE statement is
processed directly by the driver, and AutoCAD does not know which rows have been
deleted.

82
Use an SQL UPDATE statement for a key value in ASESQLED or outside of AutoCAD.
The SQL DELETE statement is processed directly by the driver, and AutoCAD does not
know which rows have been deleted.
Choose Delete in the ASESQLED SQL Cursor dialog box. If you delete the row by using
ASEROWS, then AutoCAD removes associated links to the deleted row automatically.

To report on and restore data integrity, use ASEADMIN with the Synchronize option. This
option is available only for synchronizing links that do not have secondary link path
names. If they do, you must first delete the secondary link path name and then
resynchronize the database with the drawing.
To check data integrity
Command: ASEADMIN

To ensure drawing integrity, you can limit a specific operator's ability to edit external data
by using the access permission capabilities of your DBMS or operating system. With
AutoCAD, you can use user names and passwords for DBMS products that support them.

Opening Files Containing Links

AutoCAD loads external database commands automatically so that it can track the changes
made to the linked objects. If you won't be working with links in the current drawing
session, you can unload the external database commands after using ASEADMIN and
ASESQLED by entering at the Command prompt

To access link information already stored in drawings, ASE must first be loaded before the
drawing is opened. To ensure that it is loaded first, do one of the following:

83
Manually load ase.arx with the ARX command by entering
arx .ase

Run an external database command before opening the drawing

If a drawing that contains links is loaded and external database commands are not loaded,
no link information will be recognized, although it is still stored in the drawing.
DXFIN and DXFOUT also require that external database commands be loaded first,
otherwise link information will not be read or written.
AutoCAD Release 12 drawings opened in AutoCAD Release 13 and Release 14 retain
their link information. However, Release 13 links cannot be saved back to Release 12 with
SAVEASR12. You can convert Release 12 drawing links into a Release 14 format by
running the External Database Configuration utility in the directory or folder where you
installed AutoCAD.

To convert Release 12 links to Release 14 links


To remove unneeded data from the Release 12 links

If a Release 12 drawing is attached as a block or xref, associated links are converted to


Release 14 links in memory. If the Release 12 drawing contains a bound xref, AutoCAD
saves link information as stated above. Convert Release 12 drawing links by running the
External Database Configuration utility.
You cannot edit links for objects on locked layers. In these cases, AutoCAD displays a
Warning dialog box with a message that the selected object is on a locked layer. The
corresponding layer name and object handle are displayed in the Diagnostic Parameters
list. You must unlock the layers before editing the links. This also applies to reading
AutoCAD Release 12 drawings that contain objects with links on locked layers.

NOTE: FIGURES COURTSEY FROM AUTODESK MANUAL.

84
85

Potrebbero piacerti anche