connect databases to autocad® with dbconnect · 2011-08-27 · see acad_dpg.chm for configuring...

18
1 Connect Databases to AutoCAD® with dbConnect Nate Bartley Test Development Engineer autodesk, inc. GD22-4

Upload: others

Post on 05-May-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Connect Databases to AutoCAD® with dbConnect · 2011-08-27 · See acad_dpg.chm for configuring specific databases for use with AutoCAD Demo - Configuring Data source. 7 Connecting

1

Connect Databases to AutoCAD® with dbConnect

Nate BartleyTest Development Engineer

autodesk, inc.

GD22-4

Page 2: Connect Databases to AutoCAD® with dbConnect · 2011-08-27 · See acad_dpg.chm for configuring specific databases for use with AutoCAD Demo - Configuring Data source. 7 Connecting

2

Agenda

IntroductionOverview of dbConnectConfigure a data sourceConnect database to AutoCAD drawingCreate a link templateCreate links between drawing objects and rows in the databaseCreate labels in drawingQueriesLink SelectShare link and label templates and queries with others

Overview

AutoCAD database connectivity feature – dbConnect• Little to no database knowledge required• Intelligent objects• Access a database from within AutoCAD without having database software

• Only available if Database feature of AutoCAD is installed (part of typical installation).

Not covering the creation of databases or database design

Page 3: Connect Databases to AutoCAD® with dbConnect · 2011-08-27 · See acad_dpg.chm for configuring specific databases for use with AutoCAD Demo - Configuring Data source. 7 Connecting

3

Overview

5 main features of external database accessLinking of AutoCAD objects to external dataView data in external databaseEdit data in external databaseDisplay external database data in drawingCreating queries

Terms

Environment = file cabinetCatalog = drawersSchema = foldersTable = paperRecords = RowsFields = ColumnsCells = Individual fieldsData Source = individual table or a collection of tables

Page 4: Connect Databases to AutoCAD® with dbConnect · 2011-08-27 · See acad_dpg.chm for configuring specific databases for use with AutoCAD Demo - Configuring Data source. 7 Connecting

4

dbConnect

Database feature of AutoCAD

Drawing nodeData Source nodeAssociate linksAssociate labelsAssociate queries

All from within AutoCAD

Data View

Displays records from a database table within an AutoCAD session

Page 5: Connect Databases to AutoCAD® with dbConnect · 2011-08-27 · See acad_dpg.chm for configuring specific databases for use with AutoCAD Demo - Configuring Data source. 7 Connecting

5

Demo – First Look at Data View window

Grid, Column, Record header

ActionsResize, Move, Hide, Freeze ColumnsSort records• Ascending (low to high)• Descending (high to low)

Align textFormat text

Configuring a data source

Microsoft ODBC (Open Database Connectivity)OLE DBFormat independentPoints to collection of data and provides information about the drivers necessary to access the dataVaries depending on the database • Server-based• File-based

Page 6: Connect Databases to AutoCAD® with dbConnect · 2011-08-27 · See acad_dpg.chm for configuring specific databases for use with AutoCAD Demo - Configuring Data source. 7 Connecting

6

Supported databases

Microsoft AccessdBaseMicrosoft ExcelOracleParadoxMicrosoft Visual FoxProSQL Server

See acad_dpg.chm for configuring specific databases for use with AutoCAD

Demo - Configuring Data source

Page 7: Connect Databases to AutoCAD® with dbConnect · 2011-08-27 · See acad_dpg.chm for configuring specific databases for use with AutoCAD Demo - Configuring Data source. 7 Connecting

7

Connecting database to AutoCAD drawing

Data View window• View database

• View objects• View records• AutoView

• Edit database• In place• Change notification• Commit/Restore

Connects to parent database

Demo – more Data View window

View tableEdit table

Notes:Be sure to turn AutoView off when performing other tasks other then viewing.Customize how AutoCAD displays linked rows and how AutoCAD pans (AutoPan) and zooms (AutoZoom).Changes have to be committed to the database. AutoCAD automatically commits change if AutoCAD closed

Page 8: Connect Databases to AutoCAD® with dbConnect · 2011-08-27 · See acad_dpg.chm for configuring specific databases for use with AutoCAD Demo - Configuring Data source. 7 Connecting

8

Creating a link template

2 main purposesIdentifies which fields are associated with link between the data and drawing objectIdentifies the database being used

RulesAssociates an object or objects with a row in databaseProvide a field that does not contain duplicate data• Uses first row found first

Can open data directly from Link templateMultiple link templates to associate data from more than one database to a single objectOnly change key fields of link templates that do not have any links defined in associated drawing. Implies links must first be deleted

Demo - Creating a Link Template

Steps for creating link template1. dbConnect > Template > New Link Template2. AutoCAD opens the Select Data Object dialog if a

data table is not already open3. New Link Template dialog

• Provide a name• Start with an existing template (optional)

4. Link Template dialog check Key field

Link Template is created

Page 9: Connect Databases to AutoCAD® with dbConnect · 2011-08-27 · See acad_dpg.chm for configuring specific databases for use with AutoCAD Demo - Configuring Data source. 7 Connecting

9

Linking drawing objects to rows in the database

Link drawing object to many records in a databaseLink one database record to many drawing objectsCannot link to nongraphical objects

AutoCAD provides a message on command about the success or failure of providing link

Links follow the object when edited

Demo – Linking objects and rows

Steps for creating links1. Open Data View window2. Select one or more records3. Choose Data View > Link and Label Settings >

Create Links4. Choose Data View > Link5. Select drawing objects to link

AutoCAD returns results

Page 10: Connect Databases to AutoCAD® with dbConnect · 2011-08-27 · See acad_dpg.chm for configuring specific databases for use with AutoCAD Demo - Configuring Data source. 7 Connecting

10

Editing Links

Link ManagerEnables you to edit key values for linked objects

Demo – Link Manager

Steps for using link manager1. Choose dbConnect > Links > Link Manager2. Select a drawing object3. In Link Manager, choose the Link Template4. In the Value column, type a new value5. OK to close.

AutoCAD updates the link.

Page 11: Connect Databases to AutoCAD® with dbConnect · 2011-08-27 · See acad_dpg.chm for configuring specific databases for use with AutoCAD Demo - Configuring Data source. 7 Connecting

11

Exporting Links

Exports a list of linksExports handle of the associated links’ objectsExports results in the same format as the database or in space-or comma-delimited formats

A handle is a unique name that AutoCAD gives to each object in the drawing.

Recommend synchronizing links in drawing periodicallyUpdates or deletes broken links

Demo – Exporting link information

Steps for using link manager1. Choose dbConnect > Links > Export Links2. Choose objects whose links are to be exported3. Select the fields to included in the Include Fields

section4. Navigate to the location to save5. Choose Save-as file type6. Enter filename7. Save

AutoCAD creates the file

Page 12: Connect Databases to AutoCAD® with dbConnect · 2011-08-27 · See acad_dpg.chm for configuring specific databases for use with AutoCAD Demo - Configuring Data source. 7 Connecting

12

Creating labels in drawing

Label is multiline text (Mtext)Choose which fields are to be displayed

Two types of labelsAttached labels – attached to objects and displays a leader pointing to objectFreestanding labels – independent of any object

Both are pointers to external database table

Must first create a Label Template

Creating labels in drawing

Label is multiline text (Mtext)Choose which fields are to be displayed

Two types of labelsAttached labels – attached to objects and displays a leader pointing to objectFreestanding labels – independent of any object

Must first create a Label Template

Page 13: Connect Databases to AutoCAD® with dbConnect · 2011-08-27 · See acad_dpg.chm for configuring specific databases for use with AutoCAD Demo - Configuring Data source. 7 Connecting

13

Creating Label Template

Label Template specifiesWhich fields to include in labelText formattingLabel offsets (Attached labels only)

Demo – Creating a Label Template

Steps for creating label template1. Choose dbConnect > Template > New Label

Template2. Choose a link template to use with the label

template in Select a Database Object dialog3. New Label Template dialog

• Provide template name• Start with existing template (optional)

4. AutoCAD opens the Label Template editor with Label Fields tab displayed. Add fields.

5. Format label text and configure offsets as needed.

Page 14: Connect Databases to AutoCAD® with dbConnect · 2011-08-27 · See acad_dpg.chm for configuring specific databases for use with AutoCAD Demo - Configuring Data source. 7 Connecting

14

Demo – Creating Labels

Must have a table open with a link and label templates defined

Steps for attached labels• Select record in Data View window• Choose Data View > Link and Label Settings > Create

Attached Labels (for freestanding labels choose Create Freestanding Labels)

• Choose Data View > Link• Select drawing objects

AutoCAD automatically places label. More than one object can bedone at a time.

Using Queries

Query editor to define queries such as:View a specified subset of the dataView a subset that falls within a specified range of valuesAccess all the tables in one data source with a series of SQL commands

Link Select dialog creates a selection set of objects by combining selected objects with SQL queries

Page 15: Connect Databases to AutoCAD® with dbConnect · 2011-08-27 · See acad_dpg.chm for configuring specific databases for use with AutoCAD Demo - Configuring Data source. 7 Connecting

15

Queries

Four types of queriesQuick QueryRange QueryQuery BuilderSQL Query (SQL 92 standard)

Queries are case sensitiveEach tab in the Query Editor builds on the previous tab

Query Operators

Equal (=)Not Equal (<>)Greater than (>)Less than (<)Greater than or equal (>=)Less than or equal (<=)Like (%)InIs nullIs not null

Page 16: Connect Databases to AutoCAD® with dbConnect · 2011-08-27 · See acad_dpg.chm for configuring specific databases for use with AutoCAD Demo - Configuring Data source. 7 Connecting

16

Demo - Queries

Four types of queriesQuick QueryRange QueryQuery BuilderSQL Query (SQL 92 standard)

Link Select

Enables selection sets to be created by the Query Editor or by selecting objects, or a combination of both methodsAs you work, the status area at the bottom of dialog displays results. Results are displayed in terms of the number of linked objects and the number of records that meet specification

Page 17: Connect Databases to AutoCAD® with dbConnect · 2011-08-27 · See acad_dpg.chm for configuring specific databases for use with AutoCAD Demo - Configuring Data source. 7 Connecting

17

Demo - Link Select

Steps for using link select1. Choose dbConnect > Links > Link Select2. Link Select dialog

• Choose either Use Query or Select In Drawing• Use Query uses the Query Editor• Select In Drawing prompts for object selection

3. Execute to add query or selection to the Link Select operation4. Create a second selection set5. Choose logical operator from Do drop-down list6. Create additional selection sets as needed7. Finish to complete process

Sharing link and label templates and queries

Link templates, label templates, and queries are stored under the Drawing node in dbConnect.

Queries and can be exported and imported. Queries are stored in the location specified Tools > Options > Files tab > Data Sources Location

Page 18: Connect Databases to AutoCAD® with dbConnect · 2011-08-27 · See acad_dpg.chm for configuring specific databases for use with AutoCAD Demo - Configuring Data source. 7 Connecting

18

How to configure data sourceHow to view and edit databases through Data View windowHow to connect database table with a drawingHow to create a link templateHow to create links between drawing objects and database rowsHow to create labels containing information from databaseHow to define and execute queries

Thank You