Revit API Techniques for Managing Building Data

Preview:

DESCRIPTION

Revit API Techniques for Managing Building Data. Mario Guttman. Code Examples in C#. Introduction to Building Data - 1. Introduction to Building Data - 2. Commercial Products Affinity ( Trelligence ) Onuma Planning System CodeBook dRofus ( Nosyko ). Introduction to Building Data - 3. - PowerPoint PPT Presentation

Citation preview

Revit API Techniquesfor

Managing Building Data

Mario Guttman

Code Examples in C#

Introduction to Building Data - 1

Introduction to Building Data - 2

Commercial Products

• Affinity (Trelligence)

• Onuma Planning System

• CodeBook

• dRofus (Nosyko)

Introduction to Building Data - 3WhiteFeet RevitDbLink

Ribbon Menu and Connection Screen for RevitDbLink Tool

Revit API Customization

Visual Studio

RestoringSettings

Quick Select Buttons

Visual StudioIntegratedDevelopment Environment (IDE)

Structuring Data – 1Relational Database Design Tables• Rows and Columns• Keys

Primary

Foreign

Relationships• One-to-Many• Referential Integrity

Normalizing Data

Access Objects and Relationships

Relational Database

Table Table

Relationship

Room ID Type Floor Area

10101 Office - A Floor 01 200

20101A Office - B Floor 02 220

20102 Office - B Floor 02 220

30103 Kitchen Floor 03 140

30110 Library Floor 03 230

20111 Lobby Floor 03 400

Rows(Records)

Columns (Fields)

Room Table

Table

A Primary Key Field uniquely identifies a record.

It must be:

• Not Null

• Unique

Room ID Type Floor Area

10101 Office - A Floor 01 200

20101A Office - B Floor 02 220

20102 Office - B Floor 02 220

30103 Kitchen Floor 03 140

30110 Library Floor 03 230

20111 Lobby Floor 03 400

Room Table

Primary Key Field

Room ID Type Floor Area

10101 Office - A Floor 01 200

20101A Office - B Floor 02 220

20102 Office - B 220

Floor ID Area

Floor 01 32200

Floor 02 34220

Floor 03 34220

A Foreign Key Field

• Points to the Primary Key of another table.

• May be Null.

• May be a Primary Key.

Room Table

Floor Table

Foreign Key

Room ID Type Floor Area

10101 Office - A Floor 01 200

20101A Office - B Floor 01 220

20102 Office - B 220

Floor ID Area

Floor 01 32200

Floor 02 34220

Floor 03 34220

A One-to-many Relationship is defined by a Foreign Key.

• A value can only occur once on the “one” side.

• A value may occur many times on the “many side.

1

Room Table

Floor Table

One-to-Many Relationship

Room ID Type Floor Area

10101 Office - A Floor 01 200

20101A Office - B Floor 01 220

40102 Office - B 220

Floor ID Area

Floor 01 32200

Floor 02 34220

Floor 03 34220

Referential Integrity requires that the “one” side exist before the “many” side is used.

• Changes can be cascaded from the one to the many.

• Deletions can cascade, but will delete the whole record.

1

Cannot use value “Floor 04” here.Room Table

Floor Table

Referential Integrity

Name Office

Adam Smith Acme Construction

Betty Jones Acme Construction

Clark Kent Best Engineering

Office ID Address

Acme Construction

123 North Main St.Culver City, CA

Best Engineering

2100 Flagship Wy.Sacramento, CA

A table is Not Normalized If it has redundant data.

Contact Table Office Table

Name Office Address

Adam Smith Acme Construction 123 North Main St., Culver City, CA

Betty Jones Acme Construction 123 North Main St., Culver City, CA

Clark Kent Best Engineering 2100 Flagship Wy., Sacramento, CA

Contact Table with Office Addresses

The data can be Normalized by using two tables.

1

Normalizing Data

Structuring Data - 2

Formalizing theSpace Program• Data From Client

Formatted visually.

Excel or hard-copy.• Program

Characteristics

Room Types.

Organizational Uses.

• Space Program

Type – Use Pairs.

Count each. SpaceProgram

• RoomsEach room instance.Type – Use that room.

Room List with Types and Uses

CLIENT REQUIREMENTS(EXCEL WORKSHEET)

SPACE PROGRAM(ACCESS TABLE)

D O C U M E N T:• R E A D A B L E F O R M A T• U N S T R U C T U R E D D A T A

D A T A T A B L E :• S P A C E N E E D S• T Y P E O F R O O M• W H O I S U S I N G I T• H O W M A N Y O F E A C H

ROOM LIST(ACCESS TABLE)

BIM MODEL(REVIT PROJECT)

D A T A T A B L E :• I N D I V I D U A L R O O M S• T Y P E O F R O O M• W H O I S U S I N G I T

R O O M O B J E C T S :• G E O M E T R Y• D A T A A T T R I B U T E S

3 2 - B I T

6 4 - B I T

Linking Revit to a Database - 1

Using Access and Revit• Windows Memory Space

Revit: 64-bit.

Access: 32-bit.• Connection

OLE: ACE (JET) Drivers.

COM: Interop Mode.

ACE Pass-through Service• Service

TCP-IP interface.ACE Pass- through Serv ice

A C C E S S

S E RV I C E – A C E PA S S - T H R O U G H

O L E – A C E D R I V E R

R E V I T

T C P / I P P R O TO C O L

Linking Revit to a Database - 2RevitDbLink Overview• The “Link”

The “Link” is actually a logical relationship, based on conventions in both programs.

Linking Revit to a Database - 3RevitDbLink Overview• Main Menu• Synchronization Menu

The Main Menu (left) is used to select the link and query data. The results are shown on the Synchronization Menu (right), where discrepancies can be resolved.

Code Example 1

Working with Data

• Linking to a Database

Access.

SQL Server.

• Using Excel

• Data Objects in C#

Excel Worksheet – Fields in First Row

Database Tables - Named Columns

Build connection string.

Create connection.

CREATING A DATABASE CONNECTION

Set connection type.

Make Data Objects.

Work with data.

Defi ne:

• Primary Key.

• Update/Delete Commands.

Update database

Defi ne Excel objects.

Link to Excel Session:

• Start new session.

• “Bind” to existing or start new session.

CONNECTING TO EXCEL

Defi ne “ShowWindow” call to Windows.

Apply it to every “Excel” process

Use minimize option.

HIDING EXCEL APPLICATION

Use a Worksheet:

• Existing.

• New.

Get a list of existing worksheets.

WORKING WITH EXCEL WORKSHEETS

Defi ne C# data objects.

Use the fi rst row of the Excel worksheet to create columns in the data table.

Add the row to the data table.

For each column in Excel:

• Get the Excel value.

• Set the row value.

For the remaining rows in Excel:

• Get a row from Excel.

• Make a row in the data table.

Create a data table.

Create a new row.

Work with the rows.

Add columns.

WORKING WITH DATA IN C#

Creating Areas and Solid Forms - 1

AbstractingMajor Spaces

• Major Planning Groups

• Space Requirements

• Classification

Planning Groups Derived from Space Program

Creating Areas and Solid Forms - 2

Importing Areas• Unplaced Areas• Parameters

Key Value.Descriptive Name.ClassificationRequired AreaFloor

• Revit Schedule

Place Unplaced Areas Menu

Creating Areas and Solid Forms - 3

Placing Areas

• Area Boundary Lines

• Shape

Squares.

Modular Rectangle.

• Classification Color

Areas Placed as Squares and using a Planning Module

Creating Areas and Solid Forms - 4Parti

• Site Constraints

• Plan Dimensions

• Number of Floors

• Floor Heights

Building Geometry Constraints

Creating Areas and Solid Forms - 5Manipulating Areas

Areas Moved to Plan Locations

Creating Areas and Solid Forms - 6Converting Areasto Solid Forms• Standard Block Shape

Area extremities.

Height, Width, Depth.• Extruded Boundary

Area boundary.

Fixed Height

Areas Converted to Solid Forms

Creating Areas and Solid Forms - 7

Basic Area and Massing Diagram

Code Example 2

Making Solids• Based On

Areas.

Rooms.• Family

Standard Rectangle.

Extrusion.• Setting Material Solid Families Made From Areas and Rooms

Use an existing room.

Create a new family.

Make a new material.

MAKING SOLID SHAPE FROM ROOM

Create a family instance.

Get the location and dimensions of the room.

Adjust dimensions.

Set material.

OPTION 1: A PRE-DEFINED RECTANGULAR SOLID

Get room shape:

• Room boundary: list of curves.

• Each curve: list of segments.

Create CurveArrays.

Build CurveArrArray.

OPTION 2: A UNIQUE FAMILY USING AN EXTRUSION

Get or make a subcategory.

Create new family.

Add extrusion of CurveArrArray.

Apply the material to the subcategory.

Save the Family to a fi le.

BOTH OPTIONS: APPLY MATERIAL AND SAVE FAMILY

Create a new instance:

• Use family symbol.

• Location (0, 0, 0).

Load the new family:

• Use the saved fi le.

• Delete the fi le.

Get the family symbol.

BOTH OPTIONS: MAKE AN INSTANCE OF FAMILY

Get the parameters:

• Room – Source.

• Family – Target.

Transfer values:

• Get source value.

• Convert data type.

• Set target value.

BOTH OPTIONS: TRANSFER PARAMETER VALUES

Creating Rooms - 1

Creating Rooms - 2

Computing RoomsfromProgram Database

Rooms in Access

Creating Rooms - 3

ImportingUnplaced Rooms

Unplaced Rooms in Revit

Placing Rooms

• Array of Squares

• Tagged

• Moved to Plan

Rooms Placed in an Array and then Moved to the Plan

Creating Rooms - 4

Creating Rooms - 5

Validating Program with Database• Discrepancy

No Database Record.No Model Element.Unequal Values.

• ActionsNo Action.Update Model.Update Database.

Synchronization of the Model and the Database

Creating Rooms - 6

Code Example 3

Placing Elements• Based On

Areas.

Rooms.• Boundary

Area Boundary Lines

Walls

Room Separation Lines.

• Parameters

Copying Values.

Classification. Sized Rooms Placed and Dragged to Location

Get the unplaced area.

Calculate points:

• Square.

• Required area.

Build a curve array of lines.

PLACING UNPLACED AREAS

Construct an area boundary line:

• Use the curve array.

Transfer the parameter values.

Place new area inside boundary.

Tag the area.

Delete the unplaced area.

Option 1: walls.

Make new room.

Option 2: room separator lines.

Delete the unplaced room.

PLACING UNPLACED ROOMS

Room Data Sheets - 1

AlternativeMethods• Revit

Views.

Tagged Views.

Sheets• Access

Views.

Images.

Report.

Room Data Sheets Workflows

Room Data Sheets - 2

Batch Process - Creating Views

Creating RoomViews• 2D

Crop.• 3D

Section.

Crop.• Visibility

Section.

Crop.• Naming

Room Data Sheets - 3

TaggingRooms

• Room Tag

• Labels

• Parameters

Batch Process - Tagging Views

Room Data Sheets - 4

PlacingViews on Sheets

• Frame

• Titles

Batch Process - Placing Views on Sheets

Room Data Sheets - 5

Exporting Images

• Raster Type

• File Name

Batch Process - Exporting Images

Room Data Sheets - 6

Access Report• Data Controls• Images

Controls

Control Source

Naming.

Room Data sheet Access Report

Code Example 4

Making Views

• Space Around Room

• 2D View

2D Crop Box.

• 3D View

3D Section Box.

2D Crop.

• View Template

Cropped Room Views Made Automatically

Use bounding box of subject element.

Set new box size with margins.

Create a new view and apply the bounding box to it.

Create new bounding box.

CROPPING A 2D VIEW

Make a new 3D view.

Apply the section box.

Create a new 3D bounding box :

• Get 3D bounds of the subject element.

• Create new 3D box with margins.

SECTIONING A 3D VIEW

Get the closed shell of the room.

Get all vertices:

• For each object in the shell.

• For each edge in the object.

• For each vertex in the edge.

CROPPING A 3D VIEW IN 2D

Get the room to crop to.

Make the new view.

Project all of the verticies.

Find the extreme X and Y points.

Get the inverse of the view transform.

Create new bounding box with margin.

Add the crop box to the view.

Apply a view template.

Set the underlay to none.

S E T T I N G U N D E R L AY A N D A P P LY I N G A V I E W T E M P L AT E

Color Fill Plans - 1

Flattening RelationalData• Related Tables

Room.

Room Type.

Room Type Category

Calculating ParameterValues• Math

Roll up areas.• String

Concatenate.

Color Fill Plan with Calculated Values

Color Fill Plans - 2

Room Data sheet Access Report

ROOM ROOM TYPE ROOM TYPECATEGORY

SUM ROOM AREA:ΣDESCRIPTION

• BY ROOM TYPE CATEGORY• BY FLOOR

Color Fill Plans - 3

Math Calculation Tool

Signage

Interactive SelectionMulti-line Text Edit

Specialty EquipmentSignage

Questions?

Mar io .Gut tman@Perk insWi l l . com

Recommended