89

A Cad

Embed Size (px)

Citation preview

Page 1: A Cad
Page 2: A Cad

Published by CFS Documentation cellDivision of Centre for Electronics Design and Technology of IndiaA 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 oftheir respective companies.

Every effort has been made to supply complete and accurate information. However, CEDTI assumes no responsibility for itsuse, 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

Page 3: A Cad

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.

Page 4: A Cad

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)

Page 5: A Cad

1

Customization Basicsuto CAD is a general- Purpose drafting system designed with an open architecture, so you cancustomize and extend its many features. As a result, you can expand and shape AutoCAD accordingto 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 theoperating system commands and some of the AutoCAD commands, when you install ACAD, this file isautomatically copied to the support subdirectory. The ACAD .PGP file lets you access the operating systemcommands from the drawing editor. This file has command aliases of some frequently used Auto CADcommands.

; 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.

A

Page 6: A Cad

2

; 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, *3DFACEA, *ARCAL, *ALIGNAR, *ARRAYAAD, *ASEADMINAEX, *ASSEXPORTALI, *ASELINKSASQ, *ASESQLEDARO, *ASEROWSASE, *ASESELECTAT, *DDATTDEFATE, *DDATTEB, *BMAKEBO, *BOUNDARYBR, *BREAKC, *CIRCLECH, *DDCHPROP-CH, *CHANGECHA, *CHAMFERCOL, *DDCOLORCO, *COPYD, *DDIMDAL, *DIMALIGNEDDAN, *DIMANGULARDBA, *DIMBASELINEDCE, *DIMCENTERDCO, *DIMCONTINUEDDI, *DIMDIAMETERDED, *DIMEDITDI, *DISTDIV, *DIVIDEDLI, *DIMLINEARDO, *DONUTDOR, *DIMORDINATEDOV, *DIMOVERRIDEDR, *DRAWORDERDRA, *DIMRADIUSDST, *DIMSTYLEDV, *DVIEWE, *ERASEED, *DDEDITEL, *ELLIPSEEX, *EXTENDEXIT, *QUITEXP, *EXPORTEXT, *EXTRUDEF, *FILLETG, *GROUPGR, *DDGRIPSH, *BHATCH

Page 7: A Cad

3

HE, *HATCHEDITHI, *HIDEI, *DDINSERTIAD, *IMAGEADJUSTIAT, *IMAGEATTACHICL, *IMAGECLIPIIM, *IMAGEIM, *IMPORTIN, *INTERFEREINS, *INSERTOBJINT, *INTERSECTL, *LINELA, *LAYERLE, *LEADERLEN, *LENGTHENLI, *LISTLT, *LINETYPELTS, *LTSCALEM, *MOVEMA, *MATCHPROPME, *MEASUREMI, *MIRRORML, *MLINEMO, *DDMODIFYMS, *MSPACEMT, *MTEXTMV, *MVIEWO, *OFFSETOS, *DDOSNAPP, *PANPA, *PASTESPECPE, *PEDITPL, *PLINEPO, *POINTPOL, *POLYGONPR, *PREFERENCESPRE, *PREVIEWPS, *PSPACEPU, *PURGEQ, *QUITR, *REDRAWRA, *REDRAWALLRE, *REGENREA, *REGENALLREG, *REGIONREN, *DDRENAMEREV, *REVOLVERM, *DDRMODESRO, *ROTATERPR, *RPREFRRE, *RENDERS, *STRETCHSC, *SCALESCR, *SCRIPTSE, *DDSELECTSEC, *SECTION

Page 8: A Cad

4

SET, *SETVARSHA, *SHADESL, *SLICESO, *SOLIDSP, *SPELLSPL, *SPLINESPE, *SPLINEDITST, *STYLESU, *SUBTRACTT, *DTEXTTA, *TABLETTH, *THICKNESSTO, *TOOLBARTOL, *TOLERANCETOR, *TORUSTR, *TRIMUC, *DDUCSUCP, *DDUCSPUN, *DDUNITSUNI, *UNIONV, *DDVIEWVP, *DDVPOINTW, *WBLOCKWE, *WEDGEX, *EXPLODEXA, *XATTACHXC, *XCLIPXL, *XLINEXR, *XREFZ, *ZOOM

SHAPES

Shapes are objects that are used in a manner similar to blocks. To use a shape, you first use the LOADcommand to lead the complied shape file containing the shape definition. Then you use the SHAPEcommand to insert shapes from this file into your drawing. You can specify the scale and rotation to use foreach 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 forAutoCAD to store and draw. User-defined shapes are helpful when you musts insert a simple part many timeand 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 toembedded comments in shape definition files.

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

*shape number, defbytes, shapename

Page 9: A Cad

5

specbytel, specbytec2, specbytec3,……..,0The 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 filemust have a number (number 256, 257,and 258 are for the symbolic identifier Degree Sign, Plus Or MinusSign, and Diameter Symbol).Text fronts (files containing shape definitions for each character) requirespecific numbers corresponding to the value of each character in ASCII code; other shapes can be assignedany number.

defbytesThe number of data bytes (specbytes) required to describe the shape, including the terminating zero..Thelimit is 2,000 bytes per shape.

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

SpecbyteA shape specification byte. Each specification byte is a code that defines either a vector length and directionor one of a number of special codes. A specification byte can be expressed in the shape difinition file aseither a decimal or hexadecimal value. This section uses both decimal and hexadecimal specification bytevalues for its examples (as do many of the shape definition files). If the first character of a specification byteis 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 charactermust be a 0, which indicates to AutoCAD that the next two characters are interpreted as hexadecimal valuesrange from 1(one unit long) through F (15 units long).The third character specifies the direction of thevector.The following figure illustrates the direction codes. 5

4 36 2

1 7 0

8F

9

A B D E C

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

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

Page 10: A Cad

6

*230, 6,DBOX014, 010, 01C, 018, 012, 0

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

010

014 01C

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

Specification byte codesCode Description000 End of shape definition.001 Activate Draw mode (pen down)002 Deactivate Draw mode (pen up)003 Divide vector lengths by next byte004 Multiply vector lengths by next byte005 Push current location from stack006 Pop current location from stack007 Draw subshape number given by next byte008 X-Y displacement given by next two byte009 Multiple X-Y displacements, terminated (0,0)00A Octant arc defined by next two bytes00BFractional arc defined by next five bytes00C Arc defined by X-Y displacement and bulge00D Multiple bulge-specified arcs

Code 0: End of shapeCode 0 marks the end of the shape definition.

Codes 1 and 2: Draw Mode ControlCodes 1 and 2 control Draw mode. Draw is activated at the start of each shape. When Draw mode is turnedon, the vectors cause lines to be drawn. When Draw mode is turned off, the vectors move to a new locationwithout drawing.

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

Page 11: A Cad

7

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

Codes 5 and 6: Location Save/RestoreCodes 5 and 6 push (save)and pop (restore) the current coordinate position while drawing a shape so that youcan return to it from a later point in the shape. If the stack overflows because of too many pushes or too manymissing 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 isdisplayed when the shape is drawn.

Position stack underflow in shape nnn.

Code 8 and 9: X-Y DisplacementsNormal 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 youcan draw non-standard vectors using X, Y displacements. Code 8 must be followed by two specificationbytes 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 toimprove readability. The following example results in a vector that draws (or moves) 10 units to the left andthree 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 ofX, Y displacement pairs. It is terminated by a (0,0) pair. The following example draws three nonstandardvectors 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 AutoCAD to recognize any Normal Vectors or special codes that follow.

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

23 1

4

Page 12: A Cad

8

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 thearc (counterclockwise if Positive, and clockwise if negative), its starting octant (S-a value from 0through7),and the number of octants it spans (C-a value from 0through 7, in which 0 equals eight octants, or a fullcircle).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 unitfor 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 ArcSpecial code 00B (11) draws an arc that doesn’t necessarily start and end on an octant boundary .Thedefinition 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 than255 units. Multiply the high _radius value by 256 and add that value to the radius value to generate an arcradius greater than 255. The radius and ending specification byte are the same as for the octant arcspecification (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 anddivide 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) =56End_offset =28 because ( (95-90)*256/45) =28High_radius =0 because (radius<255)Radius =3Starting octant =1 because arc starts in the 45 degree octantEnding octant =2 because arc ends in the 90 degree octant

Page 13: A Cad

9

Codes 00C and 00D: Bulge – Specified ArcsSpecial codes 00C and 00D (12 and 13 ) Provide another mechanism for including arc segments in shapedescriptions. 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 isterminated 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 –127to +127. If the line segment specified by the displacement has length D, and the perpendicular distance fromthe midpoint of that segment has height H, the magnitude of the bulge is ((2*H/D)* 127). The sign isnegative if the arc from the current location to the new location is clockwise.

H

D

A semicircle has bulge 127 (or-127) and is the greatest arc that can be represented as a single arc segmentusing these codes (use two consecutive arc segments for larger arcs ). A bulge specification of 0 is valid andrepresents a straight-line segment. Note, however, that using code 8 for a straight-line segment saves a bytein 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 mightbe 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 thanterminating 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 createsuch a file, use a text editor or word processor that enables you to save in ASCII format, and then compile theASCII file. Compiling a shape definition file generates a file format accepted by the LOAD or STYLEcommand.

To compile a shape or font file, enter

Command: COMPILE

Page 14: A Cad

10

AutoCAD displays the select shape File dialog box from which you can select a shape definition file (.shp) orPost Script font file (.pfb). After you select the file name, compiling begins. If AutoCAD finds an error in theline 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 shapedefinition file defines a font, you use the STYLE command to define a text style. Then you use one of thetext placement commands (TEXT, DTEXT or MTEXT) to place the characters in the drawing. If the shapedefinition file defines shapes, you use the LOAD command to load the shape file into the drawing. Then youuse the SHAPE command to place the individual shapes in the drawing (similar in concept to the INSERTcommand).

Page 15: A Cad

11

Line type creation

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

Line types that are composed of only dots, dashes, and spaces are considered simple linetypes. Linetypes thatcontain 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 considerablydifferent.

Two methods are available for creating and modifying linetype definitions. Youn can edits the lin fileusing a text editor or word processor, or you can use the LINETYPE commands Create option. You cannotcreate 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. Linfile or start building your own linetype library file . Commects can be included in a lin file. Any text on a linethat 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 thedescription 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-2This line begins with the alignment code (currently only A is allowed), followed by a commandelimited listofpattern 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 longA, .5, -. 25, 0, - . 25

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

The description is optional and can be a sequence of dots, spaces, and dashes, or a comment such as “Use thislinetype for hidden lines.” If you omit the description, do not put a comma after the linetype name. If youinclude 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 isentered into the definition automatically when you use the LINETYPE Create option; however, if you createthe linetype definition using a text editor, you need to include the A yourself. AutoCAD rejects any othercharacter 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

Page 16: A Cad

12

a dot. You can enter up to 12 dash-length specifications per linetype, provided they fit on one 80-characterline.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 sequencecommonly used as a center line. AutoCAD adjusts the dash-dot sequence on an individual line basis so thatdashes and line endpoints coincide. The pattern fits the line so that at least half of the first dash specificationbegins and ends the line. If necessary, the first and last dashes are lengthened. If a line is too short to holdeven one dash dot sequence, AutoCAD draws a continuous line between the endpoints. For arcs, the patternis also adjusted so that dashes are drawn at the endpoints. Circles do not have endpoints, but AutoCADadjusts 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). Thesecond dash length should be less than 0 (a pen-up segment). You must have at least two dash specificationsfor this alignment. Between the starting and ending dashes, the pattern dash specifications are drawnsequentially, beginning with the second dash specification and restarting the pattern with the first dashspecification when required.

Note:

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

Complex LinetypesComplex linetype descriptions are placed in lin files along with simple linetypes. A complex linetypespecifies 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 userspecifies vertices. Shapes and text objects embedded in lines are always displayed completely; they are nevertrimmed.

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

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

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 rotationA=## Absolute rotationS=## ScaleX=## X offsetY=## Y offset

In this syntax,## is a signed decimal number (1,-17,0.01, and so on), the rotation is in degrees, and theremaining 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.

Page 17: A Cad

13

Shapes in Complex Linetypes

The following linetype definition defines a linetype name CON1LINE that is composed of a repeating patternof a line segment, a space, and the embedded shape CON1 from the file es.shx (note that the es.shx file mustbe 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 simplelinetype. 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 twoare mandatory and position dependent; the next four are optional and can be ordered arbitrarily. Thefollowing 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 scaleof the linetype, a tangential rotation of 10 degrees in a clockwise direction, and an X offset of 0.5 drawingunits 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 unitsbefore shape elaboration takes place, and a Y offset of one drawing unit above the linetype with a scale equalto 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.

ShapenameThe 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 embeddedshape.

Shapefilename

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

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

RotateR= 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

Page 18: A Cad

14

their relative position to the line. The value can be appended with a d for degrees (if omitted, this is thedefault), 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 thelinetype definition vertex. If X offset is omitted or is 0, the shape is elaborated with no offset. Include thisfield 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 tshelinetype definition vertex. If yoffset is omitted or 0, the shape is elaborated with no offset. This value is notscaled 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. Theprimary difference between the use of shapes and the use of shapes and the use of text is that text isassociated with a text style associated with the linetype must exist prior to loading the linetype into thedrawing.

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

*MC line,----MC----MC-----MCA,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.

StringThe 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, usethe 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’sheight 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 isrecommended that you create separate text styles for text in complex linetypes to avoid conflicts wisth othertext in your drawing.

RotateR =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 itsrelative position to the line. The value can be appended with a d for degrees (if omitted, this is the default), rfor radians, or g for grads .If rotation is omitted, 0relative rotation is used.

Page 19: A Cad

15

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 theline type definition vertex. If x offset is omitted or is 0, the text is elaborated by using the lower left corner ofthe text as the offset. Include this field if you want a continuous line with text. This value is not scaled by thescale factor that is defined by S =.

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

Hatch Pattern CreationDeveloping a hatch pattern definition for AutoCAD requires some knowledge, practice, and patience, andalso a text editor. You can add a pattern to the library file acad. pat or store it in a file by itself, in which casethe file name must be the same as the pattern name. For instance, a pattern named PIT would reside in the filepit.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 bedefined 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 thefamily of hatch lines is to pass through the (0,0) drawing origin , and that the spacing between hatch lines ofthe family is to be 0.5 drawing units. L45 is the name of the pattern displayed by the HATCH ? command. (ifyou omit the description, do not include a comma after the pattern name.) Each line in a pattern definition filecan contain up to 80 characters.

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

The Boundary Hatch and Hatch Pattern Palette dialog boxes display the names of all the hatch patternsdefined 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 thedialog boxes.

Page 20: A Cad

16

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

Example1.Modify a pattern for 45-degree lines to draw dashed lines with adash length of .5 units and a spacingbetween dashed of .5 units.*DASH45,DASHED LINES AT 45-DEGREES45, 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 pendown 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 degrees45, 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)

Page 21: A Cad

17

CUSTOM MENU

Menu customization is particularly useful if you need to perform an application-specific taskon 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 acomplex 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. Youcan 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 canbe a complex combination of commands and AutoLISP or DIESEL program code. More complexmenu macros have some decision-making ability. A menu macro is similar to a script in that itissues a series of commands. However, scripts have no decision-making ability and cannot pausefor 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 eachmenu area contain AutoCAD command strings and macro syntax that define the resulting actionwhen 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 andcontrol the appearance and functionally of the menu area. The following table describes theAutoCAD menu file types.

AutoCAD Menu Files

File type Description

MNU Template menu fileMNC Compiled menu file. This binary file contains the command strings and menu

syntax that defines the functionality and appearance of the menuMNR 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 isloaded.

Page 22: A Cad

18

Menu definition files have the file extension .mnd. These are special menu source file thatcontain 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. Eachsection contains menu items, which provide instructions for the appearance and action related tothe menu selection. Menu items are comprised of the following elements: a name tag, a label and amenu macro. Although menu items are similar in structure and functionality, each section uses aspecial syntax for its menu items labels.

A menu file does not need to contain entries for every menu section. You need only thosethat pertain to your application. It is recommended that you divide your menus into several smallermenu files that can be loaded and unloaded on demand (with the MENULOAD command). Not onlydoes this give you better control to your system resources, but also it makes development andmaintenance 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 cursormenu item is highlighted, or when the cursor is over a toolbarbutton.

*** ACCELERATORS Accelerator key definitions

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

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

// This line is a comment

Page 23: A Cad

19

Menu Item Syntax

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

name_tag label menu_macro

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

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

The first item ID-Quit is the name tag and the label [Exit] displays Exit in the menu. Whenthis 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 thatdirectly 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 andmarked to unmarked) from menu macros or AutoLISP (see “Display Control Menu ItemLabels”)

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

Menu-Specific Help

Status-line help messages are an important aspect of native help support. These are thesimple, descriptive messages that appear in the status line when a menu item is chosen. TheHelpstrings 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=~.”)

Page 24: A Cad

20

*** 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 itemis 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 displayedin the status line.

Accelerator Keys

AutoCAD supports user-defined accelerator keys. The following is a short example of anAccelerators 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 asingle character or a special virtual key string (such as “F12”) enclosed in quotation marks. Thistype of item maps a key sequence to a menu item. You can concatenate more than one modifierwith another by using the plus symbol )+), as in the first example. When a special key sequence isrecognized, the menu item associated with the name tag is executed as if the user had chosen themenu item.

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

The following table lists the valid modifiers.

Valid Modifiersring 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 quotationmarks).

Page 25: A Cad

21

Special virtual keys

String Description

“F1” F1 key Although the F1 key can be assigned a menu macro, this isdiscouraged because this key is generally associated with Help. Using amodifier 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 isdiscouraged because this key is generally associated with Cancel.CTRL+ESCAPE and CTRL+SHIFT+ESCAPE cannot be assigned a menumacro; these sequence are controlled by Window. Using the SHIFTmodifier 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

Page 26: A Cad

22

“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 veryuseful.

[“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 asfollows: the RETURN key enters the @ symbol and the other number keys enter the less-thansymbol (<), followed by the angular value represented by its location in the keypad. For example, ifyou 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

Page 27: A Cad

23

Display Control of Menu Item Labels

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

Labels can also contain DIESEL string expressions to modify the contents of the label. Thiscan 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 thatkeeps 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 theitem 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 orenable labels each time they are displayed. For example, the DIESEL string expression within thefollowing 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 menumacro 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 anexclamation point and period (!). Making a menu item does not restrict your ability to choose theitem, although a marked item can be disabled.

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

[!. Line]

Page 28: A Cad

24

Using DIESEL to Mark Labels

Menu item labels can contain DIESEL string expressions hat conditionally mark labelseach time they are displayed. The following example places a check mark to the left of menu labelswhose 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 orapplication. 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 charactercode 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 andmark 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 themenu group and name tag, the other uses the absolute position of the menu item in the menuhierarchy. The former method is recommended because of its dynamic nature, which allows it tofunction 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, usethe AutoLISP menucmd function. The following syntax references a menu item based on its nametag.

(menucmd “Gmenugroup.name_tag=value”)

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

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

Page 29: A Cad

25

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

*** MENUGROUP=ACAD

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

. . . .

*** POP6

ID_MnHelp [Help]ID_Contents [Contents]C^C^_HELPID_About [About]^C^C_ABOUT

An menu item in a partial menu can be modified to have an additional men item thatreferences 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 menugroup. Attempts to load a menu with a conflicting menu group results in cancellation of theMENULOAD request.

Absolute Referencing of Pull-Down and Cursor menu Items

Similar to the referencing described in the previous section, you can activate or deactivatea 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 orcursor menu item. Because AutoCAD menu files are dynamic (through the loading of partialmenus), 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 wasinserted into the POP1 section by the menu author or id a new pull-down menu is inserted beforePOP1 by the MENULOAD command.

You can use the Pn=xxx syntax from a menu macro if it allows the $ command. Thefollowing 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=!.

Page 30: A Cad

26

The following example removes any disabling or mark character from item 1 in the POP7section.

$ P7.1=

Menu item numbering is consecutive without regard to the hierarchy of the menu file; item1 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 menuhierarchy, the following forms also can be used.

$P@.@=XXX

References the current or most recently chosen menu item.

[email protected]=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 iscontained within square bracket ([ ]) and defines what is displayed or presented to the user. Menusections that have to interface for displaying information, do not require labels (such as theButtons, Aux, and Tablet section); however, they can used for internal notes. The following tableshows 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 menuselections.

Page 31: A Cad

27

TOOLBARS Defines the toolbar name, status (floating or docked, and hidden orvisible), 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 thesequence in which that command expects its parameters. Every character in a menu macro issignificant, even the blank spaces. As AutoCAD is revised and enhanced, the sequence of promptfor various commands (and sometimes even the command name) might change. Therefore, yourcustom 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 andPICKAUTO system variables are assumed to be 1 and 0, respectively. This preserves compatibilitywith previous releases of AutoCAD and makes customization easier because you are not requiredto check the settings of these variables.

Menu Macro Syntax

The following table provides a synopsis of special characters used in menu macros. Theuse 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 temis 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 aconditional DIESEL macro expression ($M=)

Page 32: A Cad

28

^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 atthe end of a menu item.

Macro Termination

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

[Line] line

Sometimes this is undesirable; for example, the TEXT or DIM command must beterminated by RETURN, not by a space. Also, it sometimes takes more than one space (orRETURN) to complete a command, but some text editors don’t let your create a line with trailingblanks. 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 amenu 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 tocomplete 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:

Page 33: A Cad

29

[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 followingprompt 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 thecommand line, which accepts the default value, World, No difference between the first and seconditem 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 aparticular group. The purpose of this group name is to distinguish its item from other item whenusing 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 32alphanumeric characters (spaces and punctuation marks are not allowed).

Because each menu has its own menu group label, multiple partial menus can use thesame name tag. A name tag, therefore, must be unique only within the menu file in which it wasdefined. 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 followingfunctionality:

� 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 “DisplayControl 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 usedepends on the type of pointing devices you are using. The system mouse uses the auxiliarymenus, and any other pointing device (such as a digitizer puck or other input device) uses thebutton 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 buttonson your mouse. Each line in this section represents a mouse button. You can access each buttonmenu with the key/button sequences shown in the following table.

Page 34: A Cad

30

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 additionalsections 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 efficientand dynamic. By selecting the menu items and adding them to the button menu, you canpersonalize 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 afterthe pick button on your pointing device. If the pick button is button 1, the semicolon (;) assignsRETURN to button number 2 on your pointing device. The second line after the menu section labelrepresents the third button.

Note:

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

* * * BUTTONS1

[button no.2];

[button no.3] $P0=*

Page 35: A Cad

31

[button no.4] ^C ^C

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

$ Pn=*

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

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

Each remaining line in that section assigns a command sequence to each subsequentbutton 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 assignablebuttons.

Special Use of the Backslash

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

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

* * * BUTTONS2

line

line \

The first menu button issues an ordinary LINE command and solicits the From pointprompt in the normal fashion. The second menu button also issues a LINE command, but AutoCADreads 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 withoutswapping menu areas. The cursor menu can provide quick access to often-used menu items suchas Object Snap modes. Pull-down and cursor menu items are similar to items in other menusections, and you define menu macros similar to the way you define standard screen or tabletmenus.

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

Page 36: A Cad

32

these limits, AutoCAD ignores the extra items. If a pull-down or cursor menu is taller than theavailable 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 isalways displayed at or near the crosshairs on the graphics screen. They syntax for both of thesePOPn 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 thecursor 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 isactive, the menu bar is not available.

Note:

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

Creating Pull-Down and Cursor Menus

The POPn menu sections control the pull-down menus and the cursor menu. POP0controls the cursor menu; POP1 through POP16 control the active pull-down menus for the menubar.

AutoCAD scans for POPn menu sections while loading each menu file. For the POP1through POP16 menu sections it constructs a menu bar containing the titles of those sections. Ifno 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 cursormenu.

* * * 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

[ - - ]

Page 37: A Cad

33

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 andcursor 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 hassubmenu.

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

<-<-… Label prefix that indicates that the pull-down or cursor menu item is thelast 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 DIESELstring 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 characteras the menu accelerator key in a pull-down or cursor menu label. Forexample, 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 theright side of the menu.

Note:

The only nonalphanumeric characters that can be used as the first character in a menulabel are those listed above. Nonalphanumeric characters not listed in the previous table arereserved 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 definemenu and submenu items. The following example is the top portion of the POP2 pull-down menusection.

* * * POP2ID_MnEdit [&Edit]

Page 38: A Cad

34

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 bedisplayed as a menu bar title and the letter E is underscored to indicate that it is the menuaccelerator key. The name tag associated with the menu title. (ID_MnEdit) can be used to enableand 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 <-<-…) tocontrol the hierarchy of cascading menus. These special characters indicate submenus and lastitems in submenus, and last items in submenus, and can also terminate all parent menus. Eachspecial character string must be the first characters in an item label.

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

[->&Arc]

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

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

[<C&ontinue]^C^C_arc;

Special characters <-<-… indicate this item is the last item of a submenu and also of its parentmenu, 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. Youcannot choose separator lines from the menu, and any menu macro assigned to them is ignored.

Image Title Menus

Page 39: A Cad

35

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

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

Images Tile Menu Items

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

Image tile menu item use item labels to define the text of the scrolling list and the imageitself. 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 thatare 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 imageto show for that selection.

Image tile menu labels are displayed in a scrolling list box that can accommodate up to 19characters 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 sldnameis displayed as an image.

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

[sldlib(sldname, The slide name sldname is displayed in the list box, and the slide sldnamein 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 theslide library sldlib is displayed as an image.

[blank] When you supply the text blank as in icon label, a separator line isdisplayed 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 aslabeltext is displayed in the list box and no image is displayed. In this caseyou can include related commands and simple items such as Exit withoutneeding to make slides that contain words.

Page 40: A Cad

36

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 menucommands, including $I= commands. It is possible, therefore, to construct hierarchical image tilemenus in which a selection displays another image tile menu, and so on. Because the activation onthese menus is sequential rather than nested, there are no limits to the complexity of the structuresyou can create.

Displaying Image Tile Menus

The $I= macro command addresses the image tile menu. Before you can display an imagetile 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

Page 41: A Cad

37

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 electronicparts. The text label is an item that swaps to another image tile submenu that contains variousfasteners.

***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 fromany menu.

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

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

** * IMAGE

Page 42: A Cad

38

* * 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 remainsopen. 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 imagetile menus requires that you take care in preparing slides that will serve as images. Follow theseguidelines:

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

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

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

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

Command: TILEMODE

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

Page 43: A Cad

39

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 tilesonly if the slide was generated after issuing the SHADE command. Otherwise, theydisplay as outlines.

� Remember the main purpose of theses images. Do not overuse images as you encodeabstract concepts into symbols. Images are useful primarily when the user must select agraphic 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 menucommands, including $I = commands. It is possible, therefore, to construct hierarchical image tilemenus in which a selection display another image tile menu, and so on. Because the activation ofthese menus is sequential rather than nested, there are no limits to the complexity of the structuresyou can create.

Screen Menus

The screen menu section controls the screen menu area. By default, the screen menu isdisabled. You can enable the screen menu by choosing Display AutoCAD Screen Menu in DrawingWindow 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, suchas this, is convenient when many separate items reference this submenu as shown in the followingexample:

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

Page 44: A Cad

40

[ 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 linebe itself and must not contain embedded blanks. An optional integer startnum, which specifies thestarting line of the submenu, can follow menuname.

A submenu can contain any number of items, but each menu area has a limited number ofaccessible 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 menustarting at the beginning (menu box 1) and continuing through all items of the submenu. Thus, asubmenu can replace only a portion of the previous menu. You can add an item number after thesection or submenu label to specify replacement starting with a menu item other than 1 as shownin the following example:

* * SAMPLE 3

When the SAMPLE submenu is activated, the first two menu boxes are unchanged andsubmenu replacement begins with menu box 3. If you specify a negative item number, replacementstarts 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 asubmenu label.

$$=

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

Page 45: A Cad

41

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 theDraw or Edit menu items. The Draw_Root submenu provides three selection items that correspond

Page 46: A Cad

42

to AutoCAD commands. The Edit_Root submenu also contains three selection items, each ofwhich 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 containsmore items than there are boxes on the screen, or if a buttons menu contains more items thanthere are buttons available, the excess items are ignored.

Note:

You can use blank lines in menu files to lengthen submenus so that they cover upprevious 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 submenucontaining the options for the ZOOM command. For an alternative method of calling a commandsubmenu, 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 thatthe 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 areabecause they are part of the **X submenu section, which is referenced by $$=X.

Page 47: A Cad

43

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

This submenu section blanks out the unwanted text from a previous menu. For thisexample, AutoCAD displays the **X submenu and overlays it with the **BL submenu. The result isshown 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 endswith the item labels LAST, DRAW and EDIT. This submenu serves as a base for the other menusto 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 bothreference 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 macroappear on the screen menu. In the following example the command would be displayed as SNAP0.0.

SNAP 0.001

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

Note:

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

The MENUCTL System Variable

The MENUCTL system variable controls the automatic swapping of screen submenuswhen a corresponding command is issued. When MENUCTL is set to 1 (On) and an AutoCADcommand is called from a menu item, AutoCAD issues a $$=cmdname (where cmdname is thename 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 theacad.mnl file. Setting MENUCTL to 0 (Off) affects the option of the standard menu but may bepreferable for older custom menus.

Page 48: A Cad

44

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 thatdefine the menu labels and macros. A menu file can contain a section for each of these menuareas: pull-down menus, toolbars, cursor menu, image tile menus, screen menu, pointing devicebutton 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 menudisplay, choose Type It and enter a period (.) on the command line.

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

Page 49: A Cad

45

MENU LOADMENULOAD 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 youto add partial menu files to an existing base menu, such as acad.mnu. Each menu file (base andpartial) 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 ordeleting 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 thefile name manually or use the Browse option to select a file from the SelectMenu File dialog box.

Page 50: A Cad

46

Removes all existing menu groups from the Menu Group list when youload 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 menufile to load.

Customizes the menu-bar item list.

Displays a selected menu file in the Menu Group list.

Icon/ButtonLists all the menus defined in the menu group specified in

Page 51: A Cad

47

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-downmenu on the menu bar in the AutoCAD application window. The menu atthe bottom of the list corresponds to the right-most pull-down menu.

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

Removes the highlighted menu in the Menu Bar list.

Removes all menus from the menu bar in the AutoCAD applicationwindow.

MENUUNLOAD

MENUUNLOAD unloads partial menu files.

At the Command: prompt, enter MENUUNLOAD.

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

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

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

Page 52: A Cad

48

TOOLBARTOOLBAR 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 theleft of its name.

Displays the New Toolbar dialog box.

Description

Page 53: A Cad

49

Specifies a name for the new toolbar.

Specifies a menu group for the new toolbar. For moreinformation, see “Custom Menu,”

Removes the toolbar selected in the Toolbars list.

Displays the Customize Toolbars dialog box.

Page 54: A Cad

50

Moves or copies icons from one toolbar to another. Dragthe icon from the Customize Toolbars dialog box to avisible toolbar. To copy a tool icon, hold down CTRL whileyou drag.

When the Customize Toolbars dialog is displayed, right-clicking any icondisplays the Button Properties dialog box. Right-clicking on an icon thatcontains a flyout toolbar displays the Flyout Properties dialog box.

Icon/Button Descripyion

Specifies the tool icon name . If show ToolTips isselected in the Toolbars dialog box, the name isdisplayed when the pointing device moves overthe tool icon.

Display the text displayed at the left end ofthe status bar when the pointing device moves

Page 55: A Cad

51

over the tool icon

Controls the command or set of the commandsassociated with a tool icon.Enter a command inthe box.Separate a series of commands using asemicolon(;).

Specifies the icon associated with a tool. Selectan icon from the list or choose Edit to modify an icon.

Edit displays the Button Editor dialog box, inwhich you can customize an existing button orcreate a new one.

This modifies or creat s buttons

Displays the button at its actual size.

Edit one pixel at a time in the selectedcolor.Press the return button on the pointing device to editseveral pixel at once.

Page 56: A Cad

52

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

Sets pixcels to white.Double -click the erase tool with thepointing 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 iconsare stored as BMP files

Page 57: A Cad

53

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 Tipsis selected in the Toolbars dialog box,thename is displayed when the pointindevice moves over the tool icon.

Displays the text displayed at the left of thestatusbar when the pointing device moves over the toolicon.

Page 58: A Cad

54

Specifies the toolbar associated with the flyouticon.

Displays the flyout icon specified under Button Icon.If show This Button's Icon isselected,AutoCAD uses this icon for theflyout.Otherwise,the flyout icon displayed isthe icon of the last flyout selected.

Specifies the icon associated with a tool.Select an iconfrom the list,or choose edit to modify an icon.

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

Page 59: A Cad

55

Creating Regions

Description

Creates a region from a set of entities. The given entities must form a closed coplanar region. Thismethod will create a region out of every closed loop formed by the input array of curves. AutoCADconverts closed 2D and planar 3D polylines to separate regions then converts polylines, lines, andcurves that form closed planar loops. If more than two curves share an endpoint, the resultantregion might be arbitrary.You can explode a region into the individual loops by using the Explode method. The Booleanmethod allows you to create composite 3D solids or regions from the intersection, union, orsubtraction 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 maycontain the following object types: Line, Arc, Circle, Elliptical Arc, LightweightPolyline, Spline.

Return Value

Page 60: A Cad

56

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 objectsafter 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 Booleanmethod allows you to create composite 3D solids or regions from the intersection, union, orsubtraction 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 followingmethods and properties:

Creating 2D Entities From Regions

Methods

ArrayPolarDescription

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 lastobject 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 startpoint 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 ARRAYcommand.

Polar array with NumberOfObjects = 6, AngleToFill = 180, CenterPoint = 0,0,0.This method cannot be executed while simultaneously iterating through a collection. An iterationwill 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-onlyThe number of objects to be created in the polar array. This must be a positive integer greater than1.

Page 61: A Cad

57

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

CenterPoint Variant (three-elementarray of doubles); input-onlyThe 3D WCS coordinate specifying the center point for the polar array.

Return Value

RetVal Variant Array (array of objects);The array of new objects.

ArrayRectangularDescription

Creates a 2D or 3D rectangular array of objects. For a 2D array, specify the NumberOfRows,NumberOfColumns, DistBetweenRow, and DistBetweenColumnsA rectangular array is constructed by replicating the object in the selection set the appropriatenumber 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 isgenerated up and to the right. If the distance between rows is a negative number, rows are addeddownward. If the distance between columns is a negative number, the columns are added to theleft.

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 withrespect to the X and Y drawing axes. You can change this angle and create a rotated array bysetting the snap rotation angle to a nonzero value. To do this, use the Snap Rotation Angleproperty.

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

Page 62: A Cad

58

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

NumberOfColumns Integer; input-onlyThe number of columns in the rectangular array. This must be a positive number. If this number is1, thenNumberOfRows must be greater than 1.

NumberOfLevels Integer; input-onlyThe number of levels in a 3D array.

DistBetweenRows Double; input-onlyThe distance between the rows. If the distance between rows is a positive number, rows are addedupward from the base entity. If the distance is a negative number, rows are added downward.

DistBetweenColumns Double; input-onlyThe distance between the columns. If the distance between columns is a positive number, columnsare added to the right of the base entity. If the distance is a negative number, columns are added tothe left.

DistBetweenLevels Double; input-onlyThe distance between the array levels. If the distance between levels is a positive number, levelsare added in the positive direction from the base entity. If the distance is a negative number, levelsare added in the negative direction.

Return Value

RetVal Variant Array (array of objects);The array of newly created objects.

CopyDescription

Duplicates the given object to the same location.

Syntax

RetVal = object.Copy

Elements

None

Return Value

RetVal Object;The newly created duplicate object.

EraseDescription

Page 63: A Cad

59

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

MoveDescription

Moves an object along a vector.The two points you specify define a displacement vector indicating how far the given object is tobe moved and in what direction.

Syntax

object.Move Point1, Point2

Elements

Point1 Variant (three-elementarray of doubles); input-onlyA 3D WCS coordinate specifying the first point of the move vector.Point2 Variant (three-elementarray of doubles); input-onlyA 3D WCS coordinate specifying the second point of the move vector.

Return Value

None

RotateRotates an object around a base point.

Syntax

object.Rotate BasePoint, RotationAngle

Elements

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

Page 64: A Cad

60

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

None

ScaleEntityDescription

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-onlyThe factor by which to scale the object. The dimensions of the object are multiplied by the scalefactor. A scale factor greater than 1 enlarges the object. A scale factor between 0 and 1 reduces theobject.

Return Value

None

TransformByDescription

Moves, scales, or rotates an object given a 4 x 4 transformation matrix.The following table demonstrates the transformation matrix configuration, where R = Rotation, andT = Translation:

R00 R01 R02 T0R10 R11 R12 T1R20 R21 R22 T20 0 0 1This 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

Page 65: A Cad

61

A 4 x 4 matrix specifying the transformation to perform.

Return Value

None

UpdateDescription

Updates the object to the drawing screen.

Syntax

object.Update

Elements

None

Return Value

None

Properties

ApplicationDescription

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

Syntax

objVariable = object.Application

Element

Application Application object; read-only

AreaDescription

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.

Page 66: A Cad

62

Syntax

dblVariable = object.Area

Element

Area Double; read-onlyThe area is returned in square drawing units.

CentroidDescription

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-elementarray of doubles); read-onlyThe 3D coordinate representing the centroid.

ColorDescription

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 beenprovided 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 dependingon your configuration) until they are grouped into the block. When the block is inserted in thedrawing, 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.Colorobject.Color = <integer>

Element

Color Integer; read-writeThe default color designation is acByLayer. Use a color index number from 0 to 256, or one of theconstants listed here:

Page 67: A Cad

63

acByBlockacByLayer acRed acYellow acGreen acCyan acBlue acMagenta acWhite

Entity NameDescription

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-onlyThe name of the entity.

LayerDescription

Specifies the layer for an entity.All entities have an associated layer. The document always contains at least one layer (layer 0). Aswith linetypes, you can specify a layer for an entity. If you don’t specify a layer, the current activelayer 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.Layerobject.Layer = <string>

Element

Layer String;The name of the layer.

Page 68: A Cad

64

LinetypeDescription

Specifies the linetype of an entity.The linetype values identify the series of dots and dashes used for drawing lines. If you don’tspecify a linetype, the current active linetype is used for a new entity. If a linetype is specified foran entity, the current active linetype is ignored. Use the ActiveLinetype property to set or query thecurrent 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 blockreference.

Syntax

strVariable = object.Linetypeobject.Linetype = <string>

Element

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

MomentOfInertiaDescription

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 calculatedbased on the current coordinate system.

Syntax

vrntVariable = object.MomentOfInertia

Element

MomentOfInertia Variant (three-elementarray of doubles); read-onlyA 3D coordinate based on the current coordinate system.

Page 69: A Cad

65

ObjectIDDescription

Gets the object ID of the entity.

Syntax

lngVariable = object.ObjectID

Element

ObjectID Long; read-onlyThe object ID of an entity.

PerimeterDescription

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

Syntax

dblVariable = object.Perimeter

Element

Perimeter Double; read-onlyThe perimeter is returned in drawing units.

PrincipalDirectionsDescription

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 arecalculated based on the current coordinate system.

Syntax

vrntVariable = object.PrincipalDirections

Element

PrincipalDirections Variant (three-elementarray of doubles); read-onlyThe X, Y, and Z coordinates calculated on the current coordinate system.

PrincipalMomentsDescription

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 arecalculated based on the current coordinate system.

Page 70: A Cad

66

Syntax

vrntVariable = object.PrincipalMoments

Element

PrincipalMoments Variant (three-elementarray of doubles); read-onlyThe X, Y, and Z coordinates calculated on the current coordinate system.

ProductOfInertiaDescription

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 calculatedbased on the current coordinate system.

Syntax

vrntVariable = object.ProductOfInertia

Element

ProductOfInertia Variant (three-elementarray of doubles); read-onlyThe X, Y, and Z coordinates calculated on the current coordinate system.

RadiiOfGyrationDescription

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 calculatedbased on the current coordinate system.

Syntax

vrntVariable = object.RadiiOfGyration

Element

RadiiOfGyration Variant (three-elementarray of doubles); read-onlyThe X, Y, and Z coordinates calculated on the current coordinate system.

VisibleDescription

Page 71: A Cad

67

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 visiblesetting. Specifying the application to be invisible allows you to run tasks in the background withouthaving to see the component.

Syntax

blnVariable = object.Visibleobject.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

Page 72: A Cad

68

Using external databases to store nongraphic attributes for objects can reduce the size ofdrawings, simplify reporting, and enable you to edit external data.AutoCAD can associate, or link, nongraphic attributes stored in external databaseprograms such as dBASE III, ORACLE, and Microsoft Access (using ODBC) withgraphic objects in your AutoCAD drawing. You can use all of the external database featurewithout prior knowledge of databases or query languages. However, it is helpful to befamiliar with the standard structured query language ANSI SQL.After linking, you will be capable of:1. Selecting objects based on nongraphic data2. Creating text objects based on linked data values3. Executing query operations based on graphic objects4. Creating new database files5. Generating reports

Use of SQL

SQL stands for Structured Query Language. It is a standard language used by databases and inapplication for multiple platforms. In database model, a table is a two dimensional data structuremade of rows & columns. A row describes one of the elements in the table. The description is a listof 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 oramount 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 afterselecting Custom installation, AutoCAD will be installed and configured for connecting tothe sample database. You can also connect AutoCAD to the sample database during anAutoCAD session. If you want to access either the ORACLE or ODBC databases using thesupplied DBMS drivers, run the configuration program by double-clicking the ExternalDatabase 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

Page 73: A Cad

69

operations include viewing a row, adding a row, deleting a row, or changing the values ofthe data, and creating selection sets. Other operations affect the drawing directly bychanging 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 cursoris a mechanism that identifies the current position in the table for a set of rows that meet aquery condition. In AutoCAD, the cursor has one of three states: scrollable, updatable, orread-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. Youcannot update read-only rows, but you can use the SQL UPDATE command on updatablerows.

You can operate on only one row at a time. The row you select for manipulating is thecurrent row. The simplest way to make a row current is to select all rows (this is equivalentto SELECT * FROM <current table> in SQL) and then locate a particular row using theFirst, Last, Next, and Previous options for scanning the table. Another way is to use a keyto search for a row or rows using an SQL WHERE clause. You can also select a rowgraphically 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 TABLEstatement from the SQL Editor or from another user or application on a network, that tableor other database object will not be immediately visible in the lists in the ASE dialogboxes.To view or access the new database object, you must select a different superior databaseobject, and then select the new database object. Selecting the new database object adds it tothe database objects list. For example, if your current database object settings areDB3.CAT.SCH.TABLE1 and a new TABLE2 was just added to the SCH schema, youshould choose a different schema, catalog, or environment. The new table will becontained in the lists the next time they are viewed. If only one scheme, catalog, andenvironment 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 selectingthe AutoCAD object linked to itUsing Path in the Administration dialog box, when Catalog and Schema are turned off (thecurrent driver does not support catalog and schema)

Page 74: A Cad

70

Modifying External Data

The data in your database is likely to require updating eventually. For example, a databasecontaining an EMPLOYEE table might contain the names of employees whose addresseshave 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 onethat appears on the screen or in a list box.To edit a table rowCommand: ASEROWS

Page 75: A Cad

71

You can also change the database by deleting rows from the table. For example, if anemployee 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 anew 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 rowor rows in the database table by using a key. The key specifies a column or set of columnsin the table and a value against which the column values are matched. A key is used tosearch for and select specific information in the database. For example, in the sample tablebelow, if the key column is Inv_ID and a value of 173 is specified, the Inv_ID column ofthe table must have a value of 173 to match. The key identifies one or more database rowsto attach to the object.

Inventory Table

INV_ID TYPE DESCRIPT MFR PRICE ROOM EMP_ID1 furniture 6x3 couch FutonsRu 800 101 1000119 furniture file cabinet MetalWork 35 118 1024173 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 canidentify more than one row in a table. The uniqueness of a key depends upon the data inthe table.A compound key consists of more than one column, for example, Type = furniture andPrice = 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 locatesonly one row in the table. For example, two rows in the previous inventory table both

Page 76: A Cad

72

contain the Type column value furniture. In the first row, the value for a second columncalled 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 queryretrieves 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 queryretrieves 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. Alink path name specifies key columns for the current table identified by its link path. Youmight register it by selecting LAST_NAME and FIRST_NAME as the key columns. Alink path name is used to distinguish between multiple instances of a registered table. Alink path name is an alias for the link path. It is recommended that key values and link pathnames be determined by their relevance to a particular project and that all drawings use thesame 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 linkpath, or it can define different link paths.

Page 77: A Cad

73

For example, if in a block the name for the link path having LAST_NAME and ROOM askey columns is EMPLOYEE_NAME instead of EMPLOYEE_LOCATION, and that blockis imported into a drawing with links to EMPLOYEE_NAME, all links in the block wouldbe discarded. To avoid losing any link information, you should give unique link pathnames 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 samelink path name and different key column information, it is considered a duplicate. To avoidconfusion with the same link path name in the main drawing, the link path name is given aprefix 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 sharethe same key columns by creating two link path names that have the same key column orcolumns. You make one a primary link path name and the other a secondary link pathname. The secondary link path name becomes an alias or a map to the first (primary) linkpath name. Thus, a single link points to multiple tables that have the same key columndefinition 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 forthis table is WATER_LPN.

Water table

PIPE_ID MATERIAL AGE1234 Cast Iron 252123 Cast Iron 303215 PVC 10

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

Maint table

PIPE_ID DATE MAINT_DESC1234 0494 Replaced Pipe2123 0392 Fixed Break3215 0893 Replaced Pipe

Page 78: A Cad

74

Because both tables have the same key column, you can create a secondary link path namefor the Maint table. This new link path name is called MAINT_LPN. You can then accessthe data in the Maint table using either the primary or the secondary link path namewithout having to relink the object to the Maint table, thus without having to duplicate linkdata.When you link a drawing object to a database record using either the primary or thesecondary link path name, the primary link path name's key values are always used. Whenyou create a link using a secondary link path name, you will not be able to access recordsfrom tables referenced through the primary link path name by using this link. In order toaccess multiple tables from one link path name, all links must be created using the primarylink 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 whenmultiple 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, usingdatabases and tables from one or several DBMS programs, you can link more than one rowto one AutoCAD object. You cannot create links to OLE objects.

Links to databases are stored in the AutoCAD drawing. You can modify links only whenthe drawing is loaded into AutoCAD, but you can modify the linked database values andview 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 inAutoCAD.

Page 79: A Cad

75

One advantage of using external database commands is being able to manipulate databasedata from AutoCAD. Another is the ability to link that data to graphic objects in thedrawing. By linking external data to AutoCAD objects, you can manipulate data morequickly by selecting the AutoCAD objects that are linked to the data. (You can link morethan one AutoCAD object to a single row and link more than one row to a singleAutoCAD 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 adatabase.

In addition to maintaining link information in the main drawing, AutoCAD can accesslinks to objects in xrefs and blocks. You can create a link to one or more objects and thenlater include them in a block or an xref. Furthermore, you can have multiple levels ofnesting 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 asthey are for objects in the main drawing. The current database object settings in the maindrawing are not affected by the link path name attached to the block or xref. However, thenames of the database objects in the block or xref appear in the database objects list asavailable. A link path name in a block or xref attached to the main drawing has one of thefollowing characteristics:

UniqueThe incoming link path name is contained in the block or xref only and no link path withthe same name exists in the main drawing.

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

DuplicateThe incoming link path name is already contained in the main drawing but has a differentstructure--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 maindrawing, can change the characteristic of an xref's link path name and put it into a differentcategory. However, its original characteristic will be maintained throughout an ASEediting 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 isdisplayed the same as any other link path name of the main drawing. If a block or xrefcontains a link path name identical to one in the main drawing, these xref link path namesare combined into one operable link path name in the main drawing. This one link pathname then supports common operations such as linked object selection and links export

Page 80: A Cad

76

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

Using the Bind option of XREF may cause problems when you are attempting to renameor 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 witha prefix of the xref file name, as it does for blocks. Thus, they are temporarily uniqueduring their attachment. However, duplicate link path names should be the exception ratherthan the rule.

Creating Links to Xrefs

You can create links directly to objects and then include them in xrefs, and you can makelinks 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 maindrawing floorplan.dwg, you can attach the drawing office.dwg as an xref. You can thenmake a link to office.dwg itself, but not to an object within the xref. You can then changethe links so that they associated with another xref.

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

Creating Links to Blocks

Command: ASEROWWindows: Choose rows from External Database Toolbar.

You can create links directly to objects and then include them in blocks, and you can makelinks 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

Page 81: A Cad

77

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 arow"), but not to any objects within the block. You can then change links from one blockto another block.

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

A block definition and its associated link information is maintained when you useWBLOCK. Objects containing links that become nested within a block maintain their linkinformation 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 drawingusing ASELINKS. When you change a link, you specify the scope of the change: all linksto the object or only those within the environment, catalog, schema, or table. You selectthe object in the drawing whose link you want to modify. Then you select the row youwant to link the object to. Changing a link does not change the data in the externaldatabase.

To edit a link

Command: ASELINKSWindows: Choose LINKS from External database Toolbar.

Use ASELINKS command then select the object whose link is desired to be changed. Thekey value list in the links dialogue box displays the key value of the row linked to theobject. Choose rows to open the rows dialogue box. Select Rows and use the navigationkeys to select the row desired to link the object to. To update the link, choose OK in therow dialogue box.

To delete a link to the selected objectCommand: ASELINKSAt 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 deleteall to delete all link information if more than one link has been created for the selectedobject.

Page 82: A Cad

78

You can also delete a link by selecting the row an object is linked to instead of selectingthe object.To delete a link to the current rowCommand: ASEROWSSelect the row whose link is to be deleted. Then Select Link. Choose delete to delete thelink 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 theSelected Object list in the Links dialog box to view its linked values. The list shows thename 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 isnested 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 objectsassociated with Chair. The Key Values list does not display any linked values becausefurnitur.dwg does not contain links. Similarly, when the base object Line, which is used tocreate the Chair block, is selected, the Key Columns list remains empty because Line is notlinked to a row. Key values are displayed only when Chair is selected in the list or whenNested Links is checked under Selected Object.

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

Page 83: A Cad

79

By default, you can view links only to the selected object and not to its nested objects. Ifyou want to change or delete links in a block or to view links to nested objects, selectNested Links. All links are displayed in the Key Values list. You cannot create, change, ordelete 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 todatabase files, and selecting objects linked to nongraphic data. The simplest and mostcommon use of external data is to view it with the graphic objects it relates to. Use eitherASEROWS or ASESQLED to modify rows.Several important issues arise when objects are linked to a row in a table (see "To edit atable 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 theASEADMIN command to update the displayable attributes with the new values (see "Tocreate a displayable attribute").If you edit a column, ASEROWS prompts you to update the links. If you edit a columnusing ASESQLED, the links between the drawing objects and the external data are notmaintained.

If you want to change data for only one of the linked objects, use ASEROWS to create anew row for that object only and enter the new information. Once you have created a newrow, 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 externaldatabase, you may find it helpful to add a visual link near the linked drawing object so thatyou know which row it is linked to. A displayable attribute is an AutoCAD blockcontaining text that is linked to a row in the database. Adding displayable attributes to yourdrawing 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 displayableattribute in the drawing near the object it describes.

Inventory table

INV_ID TYPE DESCRIPT MODEL PRICE ROOM EMP_ID1 furniture 6x3 couch lounger 800 101 100038 furniture adjustable chair comp pro 200 129 1017119 furniture file cabinet fc 15x27d 35 118 1024

Page 84: A Cad

80

If you modify the data in the external database, you can update the displayable attributesby 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. Forexample, you can find all the vacant offices in a building or a specific fastener in anassembly. You can select graphic objects by their nongraphic attributes, highlight theselected objects, or create a selection set of objects.Two options in the Rows dialog box--Select and Unselect--add highlighted objects to orremoves them from the selection set. Displaying highlighted objects makes it easy to seewhen you have the correct row selected.

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

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

A Union BCreates a selection set made up of all AutoCAD objects linked to rows meeting searchcriteria and all the selected graphic objects.

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

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

To create a selection set from graphic and nongraphic dataIf the PICKFIRST system variable is set to 0 (off), use the Previous option of SELECT toobtain the selection set created with either ASESELECT or ASEROWS.

Exporting Associated Data

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

Page 85: A Cad

81

report-writer software. However, AutoCAD's external database commands simplify theprocess.With AutoCAD you could structure your data so that each object in the drawing is linkedto only one row and each row is linked to only one object. Although tables do not storeinformation on the objects linked to them, you can produce reports easily because each rowrepresents 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 youhave structured your data this way--with shared rows--there is no way to know how manyobjects are linked to a single row from the DBMS. ASEEXPORT provides a way toretrieve that count information by exporting link information in the drawing, and in anyxrefs 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 thedata in the tables to produce a report.

Exporting Associated Data

With external database commands, you can produce reports and materials lists based oninformation linked to your drawings. AutoCAD does not provide direct reportingcapability. Reports are generated by the products best suited to the task--the DBMS andreport-writer software. However, AutoCAD's external database commands simplify theprocess.With AutoCAD you could structure your data so that each object in the drawing is linkedto only one row and each row is linked to only one object. Although tables do not storeinformation on the objects linked to them, you can produce reports easily because each rowrepresents 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 youhave structured your data this way--with shared rows--there is no way to know how manyobjects are linked to a single row from the DBMS. ASEEXPORT provides a way toretrieve that count information by exporting link information in the drawing, and in anyxrefs 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 thedata in the tables to produce a report.

Accessing External Data with SQL

The external database commands available through AutoCAD are primarily for queryingthe database as it relates to objects in a drawing. However, you might need to manipulatedata as it relates to other tables within the database. When you need greater datamanipulation capabilities, you can issue SQL statements from AutoCAD to query externaldatabases directly. For example, to add rows to an external database table directly withoutusing the Edit or Insert options of ASEROWS, you could include these two lines in a textfile:

Page 86: A Cad

82

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

To query external databasesCommand: ASESQLED

All external database commands except ASESQLED have options you can use to changethe current database objects. ASESQLED changes only the environment, catalog, andschema. 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 thedrawing or the data in the database are altered in some ways. These conflicts are the resultof a loss of data integrity when links still exist to a record that has been deleted from thedatabase. 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 inAutoCAD or when AutoCAD is not loaded. AutoCAD is a single drawing fileenvironment, and the database management systems are not aware of the graphics linksstored in the AutoCAD drawing.Use an SQL DELETE FROM statement in ASESQLED. The SQL DELETE statement isprocessed directly by the driver, and AutoCAD does not know which rows have beendeleted.

Page 87: A Cad

83

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 notknow which rows have been deleted.Choose Delete in the ASESQLED SQL Cursor dialog box. If you delete the row by usingASEROWS, then AutoCAD removes associated links to the deleted row automatically.

To report on and restore data integrity, use ASEADMIN with the Synchronize option. Thisoption is available only for synchronizing links that do not have secondary link pathnames. If they do, you must first delete the secondary link path name and thenresynchronize the database with the drawing.

To check data integrityCommand: ASEADMIN

To ensure drawing integrity, you can limit a specific operator's ability to edit external databy using the access permission capabilities of your DBMS or operating system. WithAutoCAD, 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 changesmade to the linked objects. If you won't be working with links in the current drawingsession, you can unload the external database commands after using ASEADMIN andASESQLED by entering at the Command prompt

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

Page 88: A Cad

84

Manually load ase.arx with the ARX command by enteringarx .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 retaintheir link information. However, Release 13 links cannot be saved back to Release 12 withSAVEASR12. You can convert Release 12 drawing links into a Release 14 format byrunning the External Database Configuration utility in the directory or folder where youinstalled AutoCAD.

To convert Release 12 links to Release 14 linksTo remove unneeded data from the Release 12 links

If a Release 12 drawing is attached as a block or xref, associated links are converted toRelease 14 links in memory. If the Release 12 drawing contains a bound xref, AutoCADsaves link information as stated above. Convert Release 12 drawing links by running theExternal Database Configuration utility.You cannot edit links for objects on locked layers. In these cases, AutoCAD displays aWarning dialog box with a message that the selected object is on a locked layer. Thecorresponding layer name and object handle are displayed in the Diagnostic Parameterslist. You must unlock the layers before editing the links. This also applies to readingAutoCAD Release 12 drawings that contain objects with links on locked layers.

NOTE: FIGURES COURTSEY FROM AUTODESK MANUAL.

Page 89: A Cad

85