3D AutoCAD 2004/2005: One Step at a Time

 < Day Day Up > 


24.4 Working with Linked Objects – Object Linking and Embedding (OLE)

Let's begin with the obvious: Exactly what is OLE? You've probably heard the term since you began using computers, but what does it mean?

OLE stands for Object Linking and Embedding. It refers to the method of creating a compound document – a document that requires more than one application (program) to create. In other words, you might use OLE to show a bill of materials on an AutoCAD drawing by linking directly to the Excel spreadsheet or MS Access database file where the information is stored. (These are Microsoft examples; other programs can be used as well.)

The Object part of OLE refers to something that you'll add to your drawing (or other Windows program file). The object is actually a file, part of a file, or graphic image that originated in another program.

Note 

There are actually three Object terms. The first – OLE Object – I explain below. The second – OLE Server – refers to the source program that originated the object. The third – OLE Container – refers to the program to which you wish to link or embed the object.

The Linking and Embedding part of OLE refers to how you wish to attach the OLE Object from the OLE Server to the OLE Container document. A linked document maintains its ties with the server file. Any changes made to it'll reflect in the original linked document. An embedded document has no ties with the server file. Changes made to it are unique within your compound document.

Both linked and embedded documents require the OLE Server application (program) for editing.

24.4.1 Inserting Other Application Data into AutoCAD Drawings

Microsoft and AutoCAD each provide a method for inserting an OLE Object into a document/drawing. The Microsoft method utilizes the clipboard and an AutoCAD dialog box. It gives greater control over exactly what will be inserted but requires that the server file be opened in the server application. The AutoCAD method utilizes two dialog boxes and doesn't require that the server application be opened, but it doesn't offer as much control over what will be inserted.

We'll see each of these methods in our exercise. But first, let's take a look at the AutoCAD dialog boxes.

AutoCAD presents the Insert Object dialog box (Figure 24.4.1a) when you enter the InsertObj command. Here you find two options for creating the image you wish to insert, and a Display As Icon check box.

Figure 24.4.1a

You'll use the File text box to enter the name and location of the file you wish to insert. Alternately, you can pick the Browse… button to use a Windows standard Open File dialog box to select the file you wish to insert.

A check in the Link box will link the object to your drawing rather than embedding it.

If you're embedding an object (regardless of whether you've used the Create New or Create from File method for inserting your OLE Object), AutoCAD will present the OLE Properties dialog box next (Figure 24.4.1c – next page).

Figure 24.4.1c

Let's insert an Excel spreadsheet into our cutting table drawing. (Note: This exercise requires the use of MS Excel – Office 97 Release or better. If you don't have this software on your computer, read through the exercise, but don't try to do it.)

Note 

The Object Properties Manager won't recognize OLE Objects.

OLE Objects are hidden in a rendered drawing.

You can also access the Insert Object dialog box using the OLE Object… selection on the Insert pull-down menu.

Additionally, you can access the OLE Properties dialog box using the cursor menu when the OLE object has been selected.

Do This: 24.4.1.1 Inserting OLE Objects

  1. Reopen the cutting table24.dwg file in the C:\Steps\Lesson24 folder. If you haven't completed work on that drawing, open the cutting table-done.dwg file in the same folder.

    We'll insert the OLE Object (the Excel spreadsheet) twice to see both methods of insertion and both types of insertion.

    • Using the AutoCAD method, we'll embed the object.

    • Using the Microsoft method, we'll link the object.

  2. Zoom extents.

  3. Follow these steps.

    TOOLS

    OMMAND SEQUENCE

    STEPS

    OLE Object Button

    Command: io

    1. Enter the InsertObj command by typing insertobj or io at the command prompt. Alternately, you can pick the OLE Object button on the Insert toolbar.

     

    2. On the Insert Object dialog box, pick the Create from File option. AutoCAD presents the dialog box you saw in Figure 24.4.1b.

     

    3. Pick the Browse… button.

    4. AutoCAD presents the rowse dialog box (a indows Select File dialog box). Select the Cutting List.xls file (an Excel spreadsheet) in the :\Steps\Lesson24 folder.

    Pick the Open button to continue.

     

    5. AutoCAD returns to the Insert Object dialog box. We'll embed the spreadsheet object into our drawing, so be sure the Link check box is clear.

     

    6. Pick the OK button to complete the command. AutoCAD places the OLE Object in the upper left corner of the screen and presents the OLE Properties dialog box.

    7. Notice the Height and Width in the Size frame, and then change the Width to 5.5. Pick any of the other text boxes and watch as AutoCAD automatically updates the Height and Width in both the Size and Scale frames.

    Pick the OK button to complete the command. Your drawing looks like Figure 24.4.1.1.7a.

     

    Figure 24.4.1.1.7a

      

    8. Move your cursor over the object. Notice that it changes into something like the icon on the Move button. In fact, it's the icon used for moving an OLE Object. Pick on the object and drag it (holding down the left mouse button) to the open area on the right side of the drawing (Figure 24.4.1.1.8a).

     

    Figure 24.4.1.1.8a

    Microsoft Excel Shortcut

     

    9. Open the Cutting List.xls file in Excel.

     

    10. Return to AutoCAD. (You can pick the AutoCAD button on the task bar or hold down the Alt key while tabbing to AutoCAD.)

    11. Double-click on the OLE Object to edit it. Notice that the object opens in Excel for editing. But notice also that the name of the file being edited is Worksheet in Cutting Table.dwg.

    Change the value of cell A3 to read Red Oak. (Be sure to hit enter to finish the procedure.)

      

    12. Repeat Step 10. Notice that the value of the material in the first row has changed (Figure 24.4.1.1.12a). (You may need to Regen the drawing to see the change.) This is how you'll edit embedded OLE Objects.

     

    Figure 24.4.1.1.12a

     

    13. Return to Excel and close the Worksheet in cutting table.dwg file. Excel then presents the original Cutting List.xls file. Notice that it hasn't changed. Remember that the OLE Object was embedded into the OLE Container, not linked to the original file.

    Command: u

    14. Leave Excel running, but return to AutoCAD and undo all the changes (until the OLE Object is no longer in the file).

    15. Now we'll use the Microsoft method for inserting an OLE Object. Return to the spreadsheet and highlight the data cells (A1:F10) as shown.

     

    16. On Excel's Edit pull-down menu, select Copy to copy the highlighted section to the Windows clipboard.

     

    17. Return to AutoCAD.

    Command: pastespec

    18. On AutoCAD's Edit pull-down menu, select Past Special…. (Notice that there is also a Paste option. This one will embed the clipboard material into the document/drawing.) Alternately, you can enter the Pastespec command at the command prompt.

      

    19. AutoCAD presents the Paste Special dialog box (Figure 24.4.1.1.19a). By default, it'll embed the objects. Notice the formats available for embedding objects.

    Pick the Paste Link option. Notice that, when linked, the image must be in the format of the OLE Server application (Figure 24.4.1.1.19b).

     

    Figure 24.4.1.1.19a

     

    Figure 24.4.1.1.19b

     

    20. Pick the OK button to link the clipboard object (the Excel spreadsheet) into your AutoCAD drawing.

    21. AutoCAD places the OLE Object in the upper left corner of the graphics screen. This time, notice that it doesn't open the OLE Properties dialog box. We can, however, open it with a cursor menu.

    Right-click in the OLE Object and select Properties… from the cursor menu.

    22. AutoCAD presents the OLE Properties dialog box. We could resize our OLE Object as we did in Step 7, but this time we'll size the text to be consistent with the rest of the text in our drawing. Enter .125 in the Text size frame as indicated.

     

    23. Pick the OK button to complete the command.

      

    24. Repeat Step 8 to reposition the text. Notice how much better it fits (Figure 24.4.1.1.24a).

     

    Figure 24.4.1.1.24a

     

    25. Return to Excel and exit the program.

      

    26. Now let's see what happens when we edit a linked object. Double-click on the OLE Object. AutoCAD opens the OLE Server application (Excel) with the appropriate file. (Notice that the name of the file is Cutting List.xls – our original file, not an embedded copy.)

    27. To make our OLE Object consistent with our drawing, change the font to Times New Roman (in Excel).

    28.Now change the White Pine materials to Ponderosa Pine.

     

    29. Save the changes in Excel and exit the program.

     

    30. Return to AutoCAD and notice the changes. These changes have been incorporated both in the original document and in the AutoCAD link.

    Command: qsave

    31. Save the drawing. It now looks like Figure 24.4.1.1.31a.

     

    Figure 24.4.1.1.31a

You have now practiced inserting OLE Objects. You've seen the difference between embedding and linking, but you haven't seen some of the OLE editing tools AutoCAD provides. Let's take a look at these now.

24.4.2 Modifying OLE Objects

For many reasons, I prefer OLE to imaging via the Image command. I particularly enjoy the versatility offered by being able to edit an OLE Object using its source application. I'm no longer restricted to AutoCAD's commands and procedures. (Although an impressive program, AutoCAD can't do all things.) But thanks to some brilliant programmers at both Autodesk and Microsoft, I can use all of the programs and applications on my computer in a holistic approach to provide my client with a more complete product.

But AutoCAD does provide some additional tools for controlling the OLE image once it becomes part of our drawing. Let's look at these now.

24.4.3 AutoCAD Data in Other Applications

The methods and procedures for using an AutoCAD drawing in another application (such as Word or Excel) don't differ from what you've already seen. The only limitation involves Paper Space and Model Space views. Remember that you can't select objects in Paper Space if Model Space is active (and vice versa). This presents a problem when copying objects to the clipboard. But let's try an exercise copying our cutting table drawing into a Wordpad document.

Do This: 24.4.3.1 Using AutoCAD Drawings in Other Applications

  1. Be sure you're stil in the cutting table24.dwg file in the C:\Steps\Lesson24 folder. If not, please open it now.

  2. Follow these steps.

    TOOLS

    COMMAND SEQUENCE

    STEPS

     

    1. Pick on the Model tab.

      

    2. Without entering a command, select all of the objects on the screen.

     

    3. Right-click in the graphics area and select Copy from the cursor menu. This places all of the selected objects on the Windows clipboard.

      

    4. Open Wordpad. Follow this path from the Start button on Windows' desktop:

        Start – Programs – Accessories – Wordpad

     

    5. In Wordpad, pick the Paste Special… option on the Edit pull-down menu.

    6. Wordpad presents the Paste Special dialog box.

    Highlight AutoCAD Drawing in the list box, and make sure there is a bullet next to Paste. Then pick the OK button.

     

    7. Return to AutoCAD and close the cutting table drawing. (Leave the application running.)

      

    8. Back in Wordpad, double-click on the drawing image. Notice that AutoCAD launches with Drawing in Document on the title bar. You've embedded an AutoCAD drawing into a Wordpad document!

      

    9. Close both applications without saving.

Of course, linking an AutoCAD drawing into another application's document is as easy!


 < Day Day Up > 

Категории