Combining Data from Different Sources


Imagine being able to import and display spreadsheet data in an AutoCAD drawing. Further imagine that you can easily update that spreadsheet data, either directly from within the drawing or remotely by editing the source spreadsheet document. With a little help from a Windows feature called Object Linking and Embedding (OLE), such a scenario is within your grasp. The data is not limited to spreadsheets; it can be a word- processed document, a database report, or even a sound or video clip.

To import data from other applications, you use the Cut and Paste features found in virtually all Windows programs. You cut the data from the source document and then paste it into AutoCAD.

When you paste data into your AutoCAD file, you can link it to the source file or you can embed it. If you link it to the source file, the pasted data is updated whenever the source file is modified. This is similar to an AutoCAD cross-referenced file. (See Chapter 12 for more on cross-referenced files.) If you embed data, you are pasting it into AutoCAD without linking it. You can still open the application associated with the data by double-clicking it, but the data is no longer associated with the source file. This is similar to a drawing inserted as a block; changes in the source drawing file have no effect on the inserted block.

Using OLE to Link a Spreadsheet to AutoCAD

Let's see firsthand how OLE works. The following exercise shows how to link an Excel spreadsheet to AutoCAD. You will need a copy of Microsoft Excel 2002 or later, but if you have another application that supports OLE, you can follow along.

 On the CD       Follow these steps:

  1. Open the file called 14a-plan-xls.dwg from the companion CD. This is a copy of the plan you might have created in earlier exercises.

  2. Open the Excel worksheet called 14a-plan.xls , also from the companion CD.

  3. In Excel, highlight the door data, as shown in Figure 14.7, by clicking cell A1 and dragging to cell G17.

    click to expand
    Figure 14.7: The Excel worksheet

  4. Choose Edit   Copy to place a copy of the selected data into the Windows Clipboard.

  5. Switch to AutoCAD, either by clicking a visible portion of the AutoCAD window or by clicking the AutoCAD button in the Taskbar at the bottom of the Windows Desktop. You may also use Alt-Tab.

  6. Choose Edit   Paste Special to open the Paste Special dialog box.

    click to expand
  7. Click the Paste Link radio button to tell AutoCAD that you want this paste to be a link. Notice that the list of source types changes to show only one option: Microsoft Excel Worksheet.

  8. Click OK. You are prompted to select an insertion point.

  9. Click a point just above the UCS icon in the lower-left corner of the drawing. The worksheet data appears in the drawing, though it is so small that it appears as a dot (see Figure 14.8).

    click to expand
    Figure 14.8: The AutoCAD drawing with the worksheet pasted in

  10. Click the inserted worksheet. Then click and drag the upper-right corner of the worksheet to the right until you can read the worksheet, as in Figure 14.9. You can use the Move tool to move the worksheet into a better position.

    click to expand
    Figure 14.9: Resizing the work- sheet within Auto- CAD

  11. Zoom in to the worksheet so you can read its contents clearly.

As you saw in step 10, you can resize a pasted object by using the corner or side grips. The corner grips maintain the original proportion of the inserted object.

You now have a linked object inserted into the AutoCAD drawing. You can save this file and send it off to someone else, along with the pasted document, 14a-plan.xls . The other person will be able to open the AutoCAD file and view the drawing with the spreadsheet.

Warning  

Objects that are pasted into AutoCAD are maintained within AutoCAD until you use the Erase command to delete them. They act like other AutoCAD objects where layers are concerned . One limitation to pasted objects is that they do not appear in prints or plots unless you use the Windows system printer or plotter.

Now let's see how the Link feature works by making some changes to the worksheet data:

  1. Go back to Excel by clicking the Excel button in the WindowsTaskbar.

  2. Click the cell just below the column heading D-RATE.

  3. Change the cell's contents by typing No Rating .

  4. Go back to AutoCAD and notice that the corresponding cell in the inserted worksheet has changed to reflect the change you made to the original document. Because you inserted the worksheet as a linked document, OLE updates the pasted copy whenever the original source document changes.

  5. Now close both the Excel worksheet and the AutoCAD drawing.

In addition to using the Edit   Paste Special option, you can also import an OLE object by choosing Insert   OLE Object to open the Insert Object dialog box.

click to expand

You can then select the type of object you want to import from the Object Type list box. Two radio buttons to the left of the list box let you import an existing object or create a new object of the type listed in the list box. If you choose the Create New radio button, the application associated with the object type will start and open a new file. If you choose the Create From File radio button, the dialog box changes to show a filename and a Browse button.

click to expand

You can then browse for an existing file to import. The Link check box lets you specify whether the imported file is to be linked. If you choose Insert   OLE Object to import an Excel worksheet, the entire worksheet is imported.

Tip  

In prior versions of AutoCAD, you could not insert OLE objects beyond a certain size limit. The good news is, starting with AutoCAD 2004, there is no longer a limit on the OLE insert size . However, you must use Windows XP and the XP version or later of Microsoft's Office Suite.

start sidebar
Adding Sound, Motion, and Photos to Your Drawings

You've already seen how you can include scanned images in AutoCAD drawings through the Raster Image tools. Through OLE, you can also include sound files, video clips, and animation. Imagine how you might be able to enhance your AutoCAD files with these types of data. You can include voice annotation or, if the file is to go to a client, an animated walk-through of your building or mechanical design. The potential for this feature is enormous .

end sidebar
 

Editing Links

After you've pasted an object with links, you can control the links by choosing Edit   OLE Links (Olelinks). If there are no linked objects in the drawing, this option does nothing; otherwise it opens the Links dialog box.

click to expand

The options available in the Links dialog box are as follows :

Cancel     Cancels the link between a pasted object and its source file. After this option is used, changes in the source file have no effect on the pasted object. This is similar to using the Bind option in the Xref command.

Update Now     Updates an object's link when the Manual option is selected.

Open Source     Opens the application associated with the object and lets you edit it.

Change Source     Lets you change the object's link to a different file. When you select this option, AutoCAD opens the Change Link dialog box, which lets you select another file of the same type. For example, if you are editing the link to a sound file, the Change Link dialog box will display files with the .wav file extension.

Automatic and Manual     Radio buttons control whether linked objects are updated automatically or manually.

Break Link     Disconnects the link between the inserted data and the source document. The inserted data then becomes embedded, rather than linked.

Importing Worksheets as AutoCAD Tables

Although it can be beneficial to import worksheets as linked OLE objects, you might prefer to import worksheets as AutoCAD entities. You might not need the direct link to the source material that OLE linking offers. The ability to edit the imported spreadsheet directly within AutoCAD might have a higher priority for you.

In Chapter 8, you saw how you could create tables in AutoCAD by using the new Table tool. You can import an Excel worksheet as an AutoCAD table by using the AutoCAD Entities option in the Paste Special dialog box. By importing worksheets as tables, you have more control over the layout and appearance of the worksheet data.

Try the following exercise to see how a table can be created from a worksheet:

  1. As in the earlier exercise, open the Excel worksheet called 14a-plan.xls from the companion CD and highlight the door data, as shown in Figure 14.7.

  2. Choose Edit   Copy to place a copy of the selected data into the Windows Clipboard; then switch back to AutoCAD.

  3. Choose Edit   Paste Special to open the Paste Special dialog box.

  4. With the Paste radio button selected, click AutoCAD Entities from the list and then click OK.

  5. At the insertion point prompt, click a point in the lower-right area of the drawing. The work- sheet data appears in the drawing, though it is very small. You also see the Text Formatting dialog box.

  6. Click OK in the Text Formatting dialog box to close it.

  7. Use the Scale tool to enlarge the table to a readable size.

    click to expand

This imported worksheet can be edited by using the editing methods for AutoCAD tables described in Chapter 8. In that chapter, you learned that you can edit the text format, border line weight and color , and the background of cells . You can add rows and columns and rotate text so that it fits more uniformly in a vertical column.

In this exercise, the worksheet was imported by using the default standard table style. This gives you a simple-looking table using the AutoCAD Txt font. You can set up a custom table style with the fonts and borders you want, and then import the table for a more custom appearance. Make sure your custom table style is the current style before you import the worksheet.

Understanding Options for Embedding Data

The Paste Special dialog box offers several other options that might better suit your needs. Here is a brief description of each format that is available:

Picture (Metafile)     Imports the data as vector or bitmap graphics, whichever is appropriate. If applicable , text is also maintained as text, though you cannot edit it within AutoCAD.

Bitmap     Imports the data as a bitmap image, closely reflecting the appearance of the data as it appears on your computer screen in the source application.

AutoCAD Entities     Converts the data into AutoCAD objects such as lines, arcs, and circles. Text is converted into AutoCAD single-line text objects. Worksheets are converted into AutoCAD tables.

Image Entity     Converts the data into an AutoCAD raster image. You can then edit it by using the raster image- related tools found in the Modify   Object   Image cascading menu of the menu bar. See Chapter 11 for more on how to use raster images.

Text     Converts the data into AutoCAD multiline text objects.

The options you see in the Paste Special dialog box depend on the type of data being imported. You saw how the Microsoft Excel Worksheet option maintains the imported data as an Excel work- sheet. If the contents of the Clipboard come from another program, you are offered that program as a choice in place of Excel.

Tip  

Choosing Edit   Paste embeds OLE data objects into AutoCAD, as does the Paste From Clipboard tool in the Standard toolbar.

Using the Clipboard to Export AutoCAD Drawings

Just as you can cut and paste data into AutoCAD from applications that support OLE, you can also cut and paste AutoCAD images to other applications. This can be useful as a way of including Auto- CAD images in word-processing documents, worksheets, or desktop-publishing documents. It can also be useful in creating background images for visualization programs such as Autodesk's 3D Studio Max or VIZ, or paint programs such as MetaCreation's Painter.

Tip  

If you cut and paste an AutoCAD drawing to another file by using OLE and then send the file to someone using another computer, they must also have AutoCAD installed before they can edit the pasted AutoCAD drawing.

The receiving application does not need to support OLE, but if it does, the exported drawing can be edited with AutoCAD and will maintain its accuracy as a CAD drawing. Otherwise, the AutoCAD image will be converted to a bitmap graphic.

To use the Clipboard to export an object or a set of objects from an AutoCAD drawing, choose Edit   Copy. You are then prompted to select the objects you want to export. If you want to simultaneously export and erase objects from AutoCAD, choose Edit   Cut.

If you want the AutoCAD image to be linked to AutoCAD, choose Edit   Copy Link. You won't be prompted to select objects. The current visible portion of your drawing will be exported. If you want to export the entire drawing, choose View   Zoom   Extents before using the Copy Link option. Otherwise, set up AutoCAD to display the portion of your drawing you want to export, before using Copy Link.

In the receiving application, choose Edit   Paste Special. You'll see a dialog box similar to Auto- CAD's Paste Special dialog box. Select the method for pasting your AutoCAD image and then click OK. If the receiving application does not have a Paste Special option, choose Edit   Paste. The receiving application converts the image into a format it can accept.

Tip  

You can copy multiple viewport views from Paper Space into the Clipboard by using the Edit   Copy Link option.




Mastering AutoCAD 2005 and AutoCAD LT 2005
Mastering AutoCAD 2005 and AutoCAD LT 2005
ISBN: 0782143407
EAN: 2147483647
Year: 2004
Pages: 261
Authors: George Omura

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