25.5 Some Final Bits and Pieces about dbConnect

 < Day Day Up > 



25.4 Okay, I'm Attached – Now How Do I Use the Database?

It's all well and good to feel some pride in having attached AutoCAD to a database, but what was the purpose in doing so? Why is this better than simply attaching the database using an OLE connection?

That's a fair question, but the answer requires some additional training before you'll fully understand it. Still, I can give you some hints.

Consider this scenario.

You have a rough draft of a P&ID for a new project. The materials people are screaming for work (or they'll start laying off personnel). You don't want to be the cause of fellow employees having weeks of idle time to spend at the beach, so you create a preliminary database of valves for them to begin ordering. But you explain that the list is subject to change.

You can (and do) add the valve list to your drawing via OLE linking. You understand that you can easily change the list, and that the changes will show up in the original database for the MTO group to see. But you also understand that, over the course of designing anything, changes are often frequent and numerous. This can make your valves difficult to track properly.

So you create a dbConnect link with the database. Through this connection, you link each valve in the database list with the specific valve on the drawing. You try to keep the changes current between the two files, but often lack the time. So once or twice a week, you view the links to be sure you have no listed valves without links, or valves that don't appear in the list. You make corrections as needed. Since you make these corrections to the original database (through your dbConnect link), they appear on the MTO group's computers and, through your OLE connection, on your bill of materials as well.

Occasionally, the MTO lead calls to see how many special-order gate valves you anticipate needing for the project. You could ask your summer intern to count them, but he's filling out job applications. So you perform a database query, which gives you the answer in seconds.

Sound interesting? This scenario requires that you acquire some new skills: linking (and unlinking) database records to AutoCAD objects, and querying a database for specific information. We'll also examine how to use database information to create callouts (labels) on your drawing.

Let's begin with linking objects and records.

25.4.1 Linking AutoCAD Objects to Database Records

Linking AutoCAD objects to database records is as easy as picking a button and selecting an object. You'll follow these steps:

  1. Open the database table (double-click on the database in the dbConnect Manager and then on the desired table).

  2. Select the Link Template you wish to use (or create a new one).

  3. Select the record to link.

  4. Pick the Link! button.

  5. Select the object(s) to which you want to link.

    • Let's begin with Step I: Open the database table.

      To open the database table, double-click on the Data Source (in our case, jet_pid). The dbConnect Manager lists the tables available in that source. Double-click on the table you wish to use. AutoCAD presents the Data View window (Figure 25.4.1a – next page). (It also creates a Data View pull-down menu between the dbConnect and Windows menus.) Let's take a look at the Data View window.

      click to expand
      Figure 25.4.1a

      • The title bar indicates the type of window and the currently opened file.

      • Below the title bar, you'll see the Data View toolbar with several buttons and two control boxes. Let's look at these from left to right.

        BUTTON

        DESCRIPTION

        Link! Button

        Create Attached Label Button

        Create Freestanding Label Button

        The first button is a flyout with three selections:

        • Use the Link! button to create a new link between a record and an object.

        • Use the Create Attached Label button to create a callout, which is attached to an object on the drawing.

        • Use the Create Freestanding Label button to create a callout, which isn't attached to an object on the drawing.

        View Linked Objects in Drawing Button

        Use the View Linked Objects in Drawing button to see which objects are linked to the selected record. (This is one way you'll check for unlinked records.) You'll perform this procedure manually – selecting a record and picking the button each time you wish to identify a link.

        View Linked Records in Data View Button

        Use the View Linked Records in Data View button to see which records are linked to the selected object. (This is one way you'll check for unlined objects.) You'll perform this procedure manually as well.

        Autoview Linked Objects in Drawing Button

        Autoview Linked Records in Data View Button

        Use the AutoView Linked Objects in Drawing button and the AutoView Linked Records in Data View button to perform the same task as the last two buttons, but do it automatically. That is, when one of these buttons is depressed, simply select the record/object to view the link.

        Query Button

        Use the Query button to create a new query or run an existing query. (More on queries in Section 25.4.2.)

        Print Data View Button

        The Print Data View button, of course, prints the contents of the Data View window.

        Data View and Query Options Button

        The last button, Data View and Query Options, presents the Data View and Query Options dialog box (Figure 25.4.1b). This box offers some very useful options for the dbConnect operator.

        click to expand
        Figure 25.4.1b

        • Options in the AutoPan and Zoom frame control what happens when you select a record in the Data View window. A check in the Automatically pan drawing box causes AutoCAD to pan the drawing so that objects linked to the selected record become visible. A check in the Automatically zoom drawing box performs a similar function with the Zoom command. Set the factor for auto zoom in the Zoom factor box.

          These tools provide enormous assistance in a busy drawing.

        • The first option in the Query Options frame – Send as native SQL – involves how a query is handled in programming terms. I strongly suggest leaving this at its default unless you're quite familiar with databases and recognize the need to change it.

          A check in the Automatically Store box causes AutoCAD to automatically store the results of a query in the current drawing. I'd leave this cleared as well. Rerunning a query isn't difficult; storing information that isn't required in a drawing causes its size to increase unnecessarily.

        • The options in the Record Indication Settings frame control which records appear in the Data View.

          When you put the bullet next to Show only indicated records (the default), AutoCAD shows only those records linked to the selected objects in the drawing. If no objects have been selected, all the records appear. This is a handy tool when querying a large database.

          When you put the bullet next to Show all records, select indicated records, the Data View shows all the records. It highlights records linked to selected objects in the color indicated in the Marking Color box.

          This setting works best on small databases.

        • Accumulate selection set in drawing, in the Accumulate Options frame, works something like the Use Shift to Add selection mode. When cleared (the default), the select set in the drawing changes each time a new set of records is selected in the Data View. When checked, selecting additional records simply adds them to the current selection set.

      • To the right of the Data View and Query Options button (back in the Data View window – Figure 25.4.1a), you'll find the Select a Link Template control box. This box shows New Link Template because we haven't created a link template yet. Once you've created a link template(s), you can select the one you wish to use here.

      • Next to the Select a Link Template control box resides the Select a Label Template control box. This performs the same function for label templates.

    • In Step II: Select the Link Template, you'll select an existing link template from the Select a Link Template control box mentioned previously. Alternately, you can create a new link template.

A link template organizes your links into specific categories. It works with the View Linked Objects in Drawing and View Linked Records in Data View buttons to help identify links.

A link template categorizes records by data in a specific, user-identified field. Then, when you pick the View Linked Objects in Drawing button, AutoCAD identifies the value of that field in the selected record and highlights all the linked objects that contain that value.

For example, in our PID drawing, we'll create a link template using Valve as our primary key field. Then while this template is active, we'll select record #1 (a gate valve) and pick the View Linked Objects in Drawing button. AutoCAD will then highlight all the gate valves with links in the drawing.

To view single objects or records, you must create a template using a field whose values remain unique. To do this, I suggest using the key field ID created by MS Access. MS Access numbers each record as it is entered, so the value will be unique for each record.

(If you try to create a link without creating the template first, AutoCAD will automatically start the New Link Template wizard.)

  • In Step III: Select the record to link, simply select any value in the desired record to identify the record to link.

  • In Step IV: Pick the Link! button, pick the Link! button in the Data View window.

  • In Step V: Select the object, you'll select the drawing object to which you want to link the record.

Let's put all of this together in an exercise. We'll use our five-step procedure to link our database records to objects in our drawing.

Do This: 25.4.1.1 Linking Records and Objects

  1. Be sure you're still in the pid25.dwg file in the C:\Steps\Lesson25 folder. If not, please open it now.

  2. Follow these steps.

    TOOLS

    COMMAND SEQUENCE

    STEPS

     

    Command: dbc

    1. Step I: Open the database.

    If you haven't left the drawing, the dbConnect Manager probably is still open. If not, open it now.

    2. Access the appropriate table. Begin by double- clicking on the jet_pid listing.

    3. AutoCAD lists the available table(s) in the pid database. Double-click on the valves table. AutoCAD displays the Data View window seen in Figure 25.4.1a.

    New Link Template Button

     

    4. Step II: Select the Link Template.

    Since we haven't created a link template, we must do so now.

    Pick the New Link Template button on the dbConnect Manager toolbar (move the Data View window to one side if necessary). (Note: You could also access the New Link Template wizard by cursor menu option when you right-click on the valves table.)

    5. The New Link Template wizard begins with the New Link Template dialog box. Enter the name Valves in the New link Template name text box.

    If we wanted to base this template on another (existing) template, we'd identify an existing template in the Start with template control box. But we don't want to do that now, so pick the Continue button to proceed.

    click to expand

    6. AutoCAD needs to know which field to use as the key for this template. Put a check in the box next to the word Valve.

    (Note: Valve is not a unique field as suggested in the dialog box. We'll use this template to identify all valves. We will, however, set up a unique template next.)

    Pick the OK button to complete the procedure.

      

    7. Repeat Steps 4 through 6 to create a link template called UniqueLinks. Use ID as your key field in Step 6.

    8. Now we'll use the Data View window to edit the table. We want to use the UniqueLinks template when we assign our first links, so select it from the list in the dbConnect Manager.

    Edit Table Button

     

    9. Pick the Edit Table button on the dbConnect Manager toolbar. (Alternately, you could access the Data View window by cursor menu option when you right-click on the UniqueLinks listing.)

    10. To complete Step II, be sure that AutoCAD shows the UniqueLinks template in the Links Template control box in the Data View window.

    click to expand

    11. For Step III: Select the record, select record 1 in the Data View window.

     

    12. Step IV: Pick the Link! button in the Data View window.

     

    Select objects:

    Select objects: [enter]

    13. Step V: Select the object(s) to which you want to link.

    AutoCAD returns to the graphics screen and prompts you to Select objects to which you want to link. Select valve A (as indicated in Figure 25.4.1.1.13a), and then hit enter to complete the selection.

     

    click to expand
    Figure 25.4.1.1.13a

    Note 

    To remove a misplaced link,

    • Select the drawing object that contains the link.

    • Right-click in the drawing.

    • Select Link from the cursor menu.

    • Select Delete Link from the flyout menu.

      

    14. AutoCAD returns to the Data View window and moves to the next record in the list. It marks the first record to show that it has been linked (Figure 25.4.1.1.14a).

    Continue to link the records to the corresponding valve (record 2 to valve B, record 3 to valve C, etc.).

     

    click to expand
    Figure 25.4.1.1.14a

    Command: qsave

    15. Save your work.

      

    16. Repeat Step s 10 through 15 using the Valves template.

Now that you've created links in two templates, let's take a look at how they'll help you keep track of materials in your drawing.

We'll use the templates and links you created in Exercise 25.4.1.1 to be sure we haven't lost or duplicated any information on our PID design efforts. We'll also use the dbConnect Manager to identify specific valves in our drawing.

Note 

To edit a template, use the dbConnect pull-down menu. Follow this path:

    DbConnect – Templates – Edit [type of template] Template…

(Note: You can't edit a link template if it contains links. You must delete the links it contains before attempting to modify it.)

Do This: 25.4.1.2 Reading the Links

  1. Be sure you're still in the pid25.dwg file in the C:\Steps\Lesson25 folder. If not, please open it now.

  2. Be sure the dbConnect Manager is running and that the Data View window is open.

  3. Follow these steps.

    TOOLS

    COMMAND SEQUENCE

    STEPS

     

    1. First, let's be sure we have a fresh view in our Data View window. Right-click anywhere in the gray area to the left of any record and select Clear all marks from the cursor menu.

     

    2. The lead engineer has noticed that you have used some globe valves and wants to know where they are. We'll use our links to show him.

    Set Valves as current in the Link Template control box.

    click to expand

    3. Select one of the globe valves as shown (I'll use valve 3).

     

    4. Pick the View Linked Objects in Drawing button.

    • AutoCAD reads the value in the Valves field (as we told it to do in Step 6 of our last exercise). (The value in our selected record is Globe.)

    • It then searches the links for all of the records whose value in the Valves field is the same (it looks for all the Globe valves).

    • Finally, AutoCAD highlights and places grips on the linked objects that match the desired value (it shows you where the globe valves are located in the drawing). See Figure 25.4.1.2.4a.

     

    click to expand
    Figure 25.4.1.2.4a

     

    5. But suppose you want to find an individual valve. Let's see where the first 10" gate valve in our database is located in our drawing.

    Begin by setting the UniqueLinks template current in the Link Templates control box.

    click to expand

    6. Now select the valve to locate (valve 15).

     

    7. Pick the View Linked Objects in Drawing button.

    • This time, the value in the selected field is unique (remember that we used the ID field as the primary key for this template), so AutoCAD will find only the valve we've selected.

    • As before, AutoCAD highlights and places grips on the linked object (valve O) that matches the selected record (it shows you where the 10" gate valve is located in the drawing). See Figure 25.4.1.2.7a.

     

    click to expand
    Figure 25.4.1.2.7a

    AutoView Linked Objects Button

    Note 

    To view valves "on the fly" (as you select the record), depress the AutoView Linked Objects in Drawing button on the Data View toolbar. The AutoCAD will highlight each object as you select its corresponding record.

    8. You've seen how you can locate a valve (or group of valves), but suppose you wanted to know the details of a specific valve (what is it, what size, manufacturer, etc.). Let me show you how to determine the information.

    First, clear the highlighted objects in the drawing. (I'll use the cursor menu method.)

    click to expand

    9. Now, without entering a command, select valve L.

     

    10. Pick the View Linked Records in Data View button on the Data View toolbar.

    AutoCAD follows the link back to the database and shows you the details (Figure 25.4.1.2.10a).

     

    click to expand
    Figure 25.4.1.2.10a

    AutoView Linked Records Button

    Note 

    To view records "on the fly" (as you select the object), depress the AutoView Linked records in Data View button on the Data View toolbar. Then AutoCAD will highlight each record as you select its corresponding object. (You'll need to deselect the previous object before selecting another one.)

    Command: qsave

    11. Save the drawing but don't exit.

What do you suppose would have happened had you followed Steps 8 through 10 of this exercise using the Valves links template? Try it and see.[*]As you can see, AutoCAD's dbConnect provides much more than a simple OLE link.

But wait; there is more!

25.4.2 Creating and Using Queries

In Lesson 10, we discussed object selection filters. Using them, we created selection sets based on object type, layer, linetype, or other category. This convenient tool helped us when we needed to identify certain objects in our drawing for modification or deletion.

Database queries work in much the same way that object selection filters work. That is, they filter the data to find specific records that adhere to user- specified criteria (okay, they help you find just what you want to find).

Creating a query can be complex, but it doesn't have to be complicated. Follow this procedure:

  1. Select the table you wish to query.

  2. Pick the New Query button on the dbConnect Manager toolbar.

  3. Name the Query using the New Query dialog box (Figure 25.4.2a).


    Figure 25.4.2a

  4. Using the Query Editor dialog box (Figure 25.4.2b), Tell AutoCAD what filters to use to locate specific records or objects.

    click to expand
    Figure 25.4.2b

  5. Store &/Or Execute the query.

AutoCAD provides several methods for identifying filters for the query. Let's take a look at the Query Editor (Step IV).

  • The first and easiest method is the Quick Query. Follow this procedure:

    • Pick the Quick Query tab.

    • Identify the field you'll use for your filter in the Filed list box.

    • Determine the operator you'll use by selecting it in the Operator control box. Operators work like their mathematical counterparts.

    • Assign a Value to the field. (AutoCAD will show you the values used by this field if you pick the Look up values button.)

      [You can read the query much as you would a mathematical equation, as in "find all of the valves (field) equal to (operator) 4" (value) in size."]

    • Use the two checkboxes – Indicate records in data view, and Indicate objects in drawing – to tell AutoCAD where you want to see the results of the query.

  • Begin the Range method for defining a query by selecting the Range Query tab (Figure 25.4.2c). The Range method returns a list of records and/or a group of objects that fall within a range of values. For example, I can look up valves that cost between $35 and $125.

    click to expand
    Figure 25.4.2c

    Select the field to search, and then identify the upper and lower limits of the search. [The upper and lower values will be included in the results (in this example, the results would include the From and Through values – 35 and 125).]

    You can also use the Look up values buttons here as you did on the Quick Query tab.

  • Whereas the first two queries (Quick and Range) allow you to filter for a single field, the Query Builder allows multiple filters.

    The Query Builder tab (figure 25.4.2d – previous page) allows you to identify data in two different ways: by filter reference (or cross- reference) in the top half of the dialog box, or by field in the bottom half. (Of course, you can combine the two. For example, you might show just the ratings field of 4" gate valves.)

    click to expand
    Figure 25.4.2d

    • The filters in the top section work just like their counterparts on the other tabs – select a field, identify the operator, and value. However, notice the last field – Logical. Use this field to combine sets of filters with either And or Or. So you might set an initial filter for globe valves and a second filter for 3" valves. Using the logical filter And, you can find 3" globe valves. Using the logical filter Or, AutoCAD will look for globe valves or 3" valves. The Data View will show both!

    • The Fields section across the bottom of the tab allows you to show only selected fields of information. For example, I might need to see only the prices of valves used in this drawing. To do that, I would select Price in the Fields in table list box and add it (using the Add button) to the Show fields box. I could then sort the list from least to greatest (or vice versa) using the Sort by box.

  • The SQL Query tab (Figure 25.4.2e) works much like a combination of the two sections of the Query Builder tab. But here, as you can see, AutoCAD writes out what you're doing in the SQL programming language.

    click to expand
    Figure 25.4.2e

  • Once you've set up the query, you'll use the buttons down the right side of the Query Editor (Figure 25.4.2b) to run it.

    • Use the Store button to save the query setup. If you wish to save the query, you must do so before executing it.

    • Use the Execute button to run the query.

    • Use the Close button to exit the Query Editor without executing the query.

    • The Options button presents the Data View and Query Options dialog box discussed in Section 25.4.1.

    • The handy Check button (available only for the SQL Query) has AutoCAD check the program syntax (check the wording of the query) for errors.

Let's create a couple queries to see how they work, and to see how they might be of use to us.

Do This: 25.4.2.1 Creating Queries

  1. Be sure you're still in the pid25.dwg file in the C:\Steps\Lesson25 folder. If not, please open it now.

  2. Be sure the dbConnect Manager is running and that the Data View window is open.

  3. Follow these steps.

    TOOLS

    COMMAND SEQUENCE

    STEPS

    New Query Button

     

    1. To access the Query wizard, select the table you wish to query (valves) and pick the New Query button on the dbConnect Manager toolbar. Alternately, you can right- click on the table and select New Query… from the cursor menu.

     

    2. Our first query will filter the drawing for globe valves, so call it Globe Valves.

    Pick the Continue button to go on.

     

    3. We'll do a quick query first. Pick the Quick Query tab.

     

    4. Select Valve in the Field list box.

    5. Leave the operator set to = Equal, and pick the Look up values button.

    6. AutoCAD presents the Column Values dialog box. Select the value for which to filter (select Globe).

    Pick the OK button to continue.

     

    7. Store the query for use later. (Note that AutoCAD now lists your query under pid25.dwg in the dbConnect Manager. You can execute it anytime after leaving the wizard by simply double-clicking on it.)

      

    8. Run the query by picking the Execute button in the Query Editor. AutoCAD presents the resulting records in the Data View (Figure 25.4.2.1.8a). Behind the Data View window, AutoCAD highlights the globe valves (C and K) in the drawing (indicated by the arrows in Figure 25.4.2.1.8b).

     

    click to expand
    Figure 25.4.2.1.8a

     

    click to expand
    Figure 25.4.2.1.8b

      

    9. Let's see how many valves we have used that cost less than $100. We'll use a Range Query. Repeat Steps 1 (double-click on the Valves table to clear the last query) and 2, but call the query Prices.

     

    10. Pick the Range Query tab.

     

    11. We'll use the Price field to create our filter.

    12. Since our price range isn't specific, we'll ignore the Look up values buttons and simply enter the range manually as shown.

     

    13. Store the query.

     

    14. Close the Query Editor.

     

    15. Execute the query by double-clicking on it in the dbConnect Manager. AutoCAD presents the resulting records in the Data View.

    For an interesting trick, double-click on the Price column header. Notice that AutoCAD rearranges the listing to order the records from least to greatest (Figure 25.4.2.1.15a). (Double-click again to reverse the order.)

     

    click to expand
    Figure 25.4.2.1.15a

      

    16. Now we'll search for ¾" gate valves. This requires filtering two fields, so we'll use the Query Builder. Begin by repeating Steps 1 (again, double-click on Valves to clear the last query) and 2. Call the query 3_4 Gates – you can't use a"/" in the name.

     

    17. Pick the Query Builder tab.

     

    18. Begin by selecting the first value (row) in the Field column. Notice that AutoCAD offers a control arrow. Pick that to see a list of available fields from which to choose. Select Valve (we'll filter using the Valve field).

      

    19. Use the method you used in Step 18 to complete two rows of filters (Refer to Figure 25.4.2.1.19a).

     

    click to expand
    Figure 25.4.2.1.19a

      

    20. Store and execute the query. See the results in Figure 25.4.2.1.20a.

     

    click to expand
    Figure 25.4.2.1.20a

    Command: qsave

    21. Save the drawing but don't exit.

Once you've run the query and located a specific record, what do you do next? Let's find out.

25.4.3 Once I've Found the Record, What Do I Do with It? Adding, Deleting, or Modifying Records

If you have ever worked with a spreadsheet (Excel, Lotus, etc.), you can handle a database. Adding or deleting a record is as easy as a mouse-click.

Changing data in a specific cell is as easy as selecting the cell and typing the new data.

Let's take a look.

So what do you think of queries? Can you think of other uses? Make a list of industries/disciplines that use databases and how they might use queries. Compare and discuss your list with your peers.

Our engineer has decided that the 2" drain line below the horizontal vessel won't be required. We'll remove it from the drawing and remove its valve from the database. He also wants to resize the 8" line feeding the vertical vessel to 10".

Do This: 25.4.3.1 Modifying Records

  1. Be sure you're still in the pid25.dwg file in the C:\Steps\Lesson25 folder. If not, please open it now.

  2. Be sure the dbConnect Manager is running and that the Data View window is open. (UniqueLinks link template should be current.)

  3. Follow these steps.

    TOOLS

    COMMAND SEQUENCE

    STEPS

    Command: z

    1. Zoom in below the horizontal vessel. Your drawing will look like Figure 25.4.3.1.1a.

     

    click to expand
    Figure 25.4.3.1.1a

     

    2. Select valve L and pick the View Linked Records in Data View button on the Data View toolbar. AutoCAD presents the linked record in the Data View.

     

    3. Right-click in the gray area (with the black arrow) to the left of the record, and select Delete Record from the cursor menu. (Notice that you can also use this cursor menu to Add a new record.)

     

    4. AutoCAD asks you to confirm the deletion. Pick the Yes button.

    Close the Data View window.

    Command: e

    5. Erase the 2" line, valve, drawing, and callouts. Your drawing looks like Figure 25.4.3.1.5a. (You've removed the objects from the drawing and the materials from the database.

     


    Figure 25.4.3.1.5a

      

    6. Adjust the display so you can see the 8" line entering the vertical vessel (Figure 25.4.3.1.6a).

     

    click to expand
    Figure 25.4.3.1.6a

      

    7. Reopen the Data View window (double- click on the Valves table), and repeat Step 2 for Valve F.

     

    8. Pick the cell in the Size column (where it says 8") and change the value to 10" as shown.

      

    9. Close the Data View window.

    Command: ed

    10. Change the line number to 10"-C2-109- J51. Your drawing looks like Figure 25.4.3.1.10a.

     

    click to expand
    Figure 25.4.3.1.10a

    Command: qsave

    11. Save the drawing but don't exit.

Can you see that queries alone might make the dbConnect tool an invaluable addition to the AutoCAD stable? Remember – the changes you make to the database are visible to the MTO group immediately.

But wait! There's another use for dbConnect – creating callouts!

25.4.4 Using Object/Record Links to Create Labels

Note 

To make proper use of dbConnect's labels, you should anticipate their use and not use visible attributes to create callouts.

When we first set up this drawing, we used visible attributes to place specific callouts such as size and rating on our valves. Then we exported data from those attributes (together with the data from some invisible attributes) to create our database. Now I'll show you how to close the circle; that is, I'll show you how to use data in the database to create the callouts (referred to as Labels by dbConnect).

Here's the procedure for creating labels.

  1. Select the table you wish to use.

  2. Select the Label Template you wish to use (or create a new one).

  3. In the Data View window, set AutoCAD to create an attached or freestanding label.

  4. Pick the Create… Label button.

  5. Locate the label.

    • Step I: Select the table is simple. Select the table by picking on it (or you can double-click to open the Data View window).

    • You'll Select the Label Template (Step II) just as you selected a link template – using the Select a Label Template control box in the Data View window. However, if a label template hasn't been created, you must create one before labeling anything.

      (If you try to create a label with no template, AutoCAD will automatically launch the Create Label Template wizard.)

    • To begin the Create Label Template wizard, you can pick the New Label Template button on the dbConnect Manager toolbar. You can also select New Label Template… from the cursor menu when you right-click on the table. AutoCAD presents the New Label Template dialog box (Figure 25.4.4a – previous page).


      Figure 25.4.4a

      Here you'll name your label template. You can base the creation process on an existing template if you wish by selecting it from the Start with template control box.

    • Once you've named the template, AutoCAD presents the Label Template Editor (Figure 25.4.4b). The editor is very similar to the MText Editor in function (although no longer in appearance), but this one has some new options. Let's take a look.

      click to expand
      Figure 25.4.4b

      • At the bottom of the dialog box is the status line, which contains useful information for the CAD operator.

        • The left corner of the status line gives a brief description of the currently selected tab.

        • The right corner provides a toggle for the AutoCAPS tool. When toggled On, AutoCAPS will convert any new text (typed or imported) into uppercase letters.

        • To the left of the AutoCAPS toggle is the Ln/Col box. This shows the location of the cursor in the text window. Ln refers to the number of the line down from the top, and Col refers to the number of spaces over from the beginning (left end) of the line.

      • The right side of the dialog box has four buttons.

        • The top two buttons – OK and Cancel – are the same buttons standard to most dialog boxes.

        • The Import Text… button presents Windows Open dialog box. You can insert any text file or file saved in Rich Text Format (.rtf).

        • Help, of course, calls AutoCAD's Help window.

      • Let's look at the tabs.

        • The Character tab (Figure 25.4.4c) allows you to select a font independently of the current style. In fact, styles The Symbol button will present the Character Map we discussed in Lesson 4.

          click to expand
          Figure 25.4.4c

        • The Properties tab (Figure 25.4.4d) provides the opportunity to set (or reset) the Style, Justification, or Rotation of can be mixed within the Label Template dialog box allowing you more independence in creating the final appearance of the callout.

          click to expand
          Figure 25.4.4d

          Depending on the font selected, the Character tab also gives you access to the more common tools of emphasis in word processors – Bold, Italics, or Underlining. You can even make use of color changes within the text for emphasis.

          Notice the a/b button on this tab. Use this to stack your fractions.

          the callout. You can also adjust the Width of the callout.

        • On the Find/Replace tab (Figure 25.4.4e), you can search the drawing for existing text and replace it if you wish.

          click to expand
          Figure 25.4.4e

        • You'll use the Label Fields tab (Figure 25.4.4f) to define your labels by field. Select the field you want to include in the Field control box. Then pick the Add button to add it to the label definition. It'll appear in the text box as a field definition. Add as many fields as you like. Feel free to add or import additional text you wish to appear in the labels.

          click to expand
          Figure 25.4.4f

        • The Label Offset tab (Figure 25.4.4g) provides the means for you to define how the label will be inserted.

          click to expand
          Figure 25.4.4g

          • The setting in the Start control box works only on attached labels. Use it to control where the leader begins.

            It references the object to which the label is attached – so a Middle Center setting will cause the leader to begin in the center (vertically) of the middle (horizontally) of the object.

          • The Leader offset setting also works only on attached labels. It locates the text in relation to the end of the leader line.

          • The Tip offset specifies an offset from the insertion point you specify. If you're inserting an attached label, the Tip offset works in relation to the Start setting.

          Note 

          A freestanding label can be attached to an object, and an attached label can be freed using the cursor menu. Do this:

          1. Select the label.

          2. Right-click to acquire the cursor menu.

          3. Follow this path:

              Label – Detach Label (or Attach to an Object…)

    • Setting AutoCAD to create an Attached or Freestanding label (Step III) is quite easy. In the Data View window, pick the down arrow next to the Link! button and pick an option. AutoCAD provides two methods for creating labels – Attached or Freestanding.

      • An Attached label is closely linked to the object to which it is attached. Modifications (such as copying, moving, or erasing) will affect the label as well as the object. Attached labels use a leader.

      • Freestanding labels exist independently of other objects.

    • Once you've set the Attached/Freestanding option, pick the Create… Label button (Step IV). The button replaces the Link! button in the Data View. AutoCAD will prompt you to Select an object (for an attached label) or to Specify point for label (for a freestanding label).

Whew! That was a lot of information to absorb. Well, wipe your brow and let's create some labels in our pid drawing.

Do This: 25.4.4.1 Creating Labels

  1. Be sure you're still in the pid25.dwg file in the C:\Steps\Lesson25 folder. If not, please open it now.

  2. Be sure the dbConnect Manager is running.

  3. Set the TEXT layer current.

  4. Follow these steps.

    TOOLS

    COMMAND SEQUENCE

    STEPS

    Command: v

    1. Restore the CONT_STATION1 view (figure 25.4.4.1.1a).

     

    click to expand
    Figure 25.4.4.1.1a

     

    2. Select the Valves table in the dbConnect Manager (Step I of the Creating Labels procedure).

     

    3. (Step II) Pick the New Label Template button on the dbConnect Manager toolbar. AutoCAD begins the New Label Template wizard.

     

    4. Enter the name for the template – Size_Rating – (as shown) and then pick the Continue button to continue. AutoCAD presents the Label Template Editor.

     

    5. Begin on the Character tab. Set the font to Times New Roman and the size to 0.125.

     

    6. On the Properties tab, set the Justification to Middle Left.

     

    7. On the Label Fields tab, pick the down arrow in the Field control box and select Size from the list.

     

    8. Pick the Add button to add Size to the label template definition. Notice that #(Size) appears in the text box.

      

    9. Repeat Steps 7 and 8 to add Rating to the label template definition. The text box looks like Figure 25.4.4.1.9a.

     

    click to expand
    Figure 25.4.4.1.9a

     

    10. Pick the OK button to complete the procedure. Notice that the Size_Rating label template now appears in the dbConnect Manager (Figure 25.4.4.1.10a. (To edit the template, simply double-click on it in the dbConnect Manager.)

     


    Figure 25.4.4.1.10a

    click to expand

    11. Now we'll add some labels. Double-click on the Valves table to open the Data View window. Be sure the Select a Label Template control box indicates that the Size_Rating template is current and that the Select a Link Template control box indicates that the UniqueLinks template is current.

     

    12. (Step III) Pick the down arrow next to the Link! button and select Create Freestanding Labels from the menu.

      

    13. Select the first record in the Data View.

     

    14. (Step IV) Pick the Create Freestanding Label button on the Data View toolbar (it took the place of the Link! button when you selected it in Step 12).

     

    Specify point for label:

    1 Record(s) linked with 1 Label(s)

    15. (Step V) AutoCAD prompts for a location. Place the label slightly north and west of the gate valve (Figure 25.4.4.1.15a).

    Congratulations! You've created your first freestanding label. Now let's create an attached label.

     


    Figure 25.4.4.1.15a

     

    16. Repeat Step 12, but select the Create Attached Labels option.

      

    17. Select the first globe valve in the database (ID #3).

     

    18. Pick the Create Attached Label button on the dbConnect Manager toolbar (It took the place of the Create Freestanding label button when you selected it in Step 16).

     

    Select objects:

    19. Select the globe valve on the bypass line (valve "C").

     

    1 Record(s) linked with 1 Object(s)

    20. Close the Data View window. Notice where AutoCAD has placed the label (Figure 25.4.4.1.20a).

     


    Figure 25.4.4.1.20a

      

    21. Let's change the location of the attached label. Select it (select the label itself, not the leader).

      

    22. Select the grip and move the label down about 1.5" and west about 0.5". Clear the grip. Notice that the leader adjusts accordingly (Figure 25.4.4.1.22a).

     


    Figure 25.4.4.1.22a

    Command: m

    23. Now let's see how attached versus freestanding labels behave. Move valves A and C to the west about 2". Notice that the attached label moved with the valve, but the freestanding label didn't (Figure 25.4.4.1.23a). Can you name some times when you might need attached labels? Freestanding labels?

     

    click to expand
    Figure 25.4.4.1.23a

    Command: u

    24. Undo the move.

    Command: qsave

    25. Save the drawing.

Here are some additional notes concerning labels.

  • You can hide all labels (just as you did all attributes with the ATTDisp system variable) by right-clicking on its template in the dbConnect Manager. Simply select the Hide Labels option from the cursor menu. (Show the labels again by repeating the procedure and selecting Show Labels.)

  • You can delete all labels related to a specific template by following the previous procedure and selecting Delete Labels from the cursor menu.

  • You can remove a single label using the Erase command (or selecting the label and hitting the Delete key on your keyboard.)

  • If you change the value of the record on which the label was based, you can automatically update the label by selecting Reload from the same cursor menu. However, this method has produced some undesirable effects and isn't always reliable. I suggest watching the labels closely if you use this method. It might be best, however, to simply erase and replace the affected labels.

[*]AutoCAD will follow the link back to the database, read the value in the Valve field, and reveal all the records that share that value.



 < Day Day Up > 



AutoCAD 2004. One Step at a Time
3D AutoCAD 2004/2005: One Step at a Time
ISBN: 0975261371
EAN: 2147483647
Year: 2003
Pages: 96

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net