S09 Revit API Techniques for Managing Building Data

Download Report

Transcript S09 Revit API Techniques for Managing Building Data

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
WhiteFeet RevitDbLink
Ribbon Menu and Connecti on Screen for Rev itDbLink Tool
Revit API Customization
Visual Studio
Restoring
Settings
Quick Select
Buttons
Visual Studio
Integrated
Development
Environment (IDE)
Structuring Data – 1
Relational Database Design
Tables
•
Rows and Columns
•
Keys
Primary
Foreign
Relationships
•
One-to-Many
•
Referential Integrity
Normalizing Data
Access Objects and Relationships
Relational Database
Relationship
Table
Table
Table
Columns (Fields)
Rows
(Records)
Room ID
Type
Floor
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
Area
Primary Key Field
A Primary Key Field
uniquely identifies a record.
It must be:
• Not Null
Room ID
Type
Floor
• Unique
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
Area
Foreign Key
A Foreign Key Field
• Points to the Primary Key of another table.
• May be Null.
• May be a Primary Key.
Room ID
Floor ID
Type
Floor
10101
Office - A
Floor 01
200
20101A
Office - B
Floor 02
220
20102
Office - B
Room Table
Area
220
Area
Floor 01
32200
Floor 02
34220
Floor 03
34220
Floor Table
One-to-Many Relationship
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.
Floor ID
1

Room ID
Type
Floor
Area
10101
Office - A
Floor 01
200
20101A
Office - B
Floor 01
220
20102
Office - B
Room Table
220
Area
Floor 01
32200
Floor 02
34220
Floor 03
34220
Floor Table
Referential Integrity
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

Room ID
Type
Floor
10101
Office - A
Floor 01
200
20101A
Office - B
Floor 01
220
40102
Office - B
Room Table
Area
220
Floor ID
Area
Floor 01
32200
Floor 02
34220
Floor 03
34220
Floor Table
Cannot use value
“Floor 04” here.
Normalizing Data
A table is Not Normalized If it has redundant data.
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.
Name
Office
Adam Smith
Acme Construction
Betty Jones
Acme Construction
Clark Kent
Best Engineering
Contact Table
Office ID

1
Address
Acme
Construction
123 North Main St.
Culver City, CA
Best
Engineering
2100 Flagship Wy.
Sacramento, CA
Office Table
Structuring Data - 2
Formalizing the
Space Program
•
Data From Client
Formatted visually.
Excel or hard-copy.
•
Program
Characteristics
Room Types.
Organizational
Uses.
•
Space Program
Type – Use Pairs.
Count each.
Space
Program
•
Rooms
Each room instance.
Type – Use that room.
Room List with Types and Uses
D O C U M E N T:
• R E A D A B L E F O R M AT
• U N S T R U C T U R E D D AT A
CLIENT REQUIREMENTS
(EXCEL WORKSHEET)
D AT A TA B L E :
• S PA C E N E E D S
• TYPE OF ROOM
• WHO IS USING IT
• HOW MANY OF EACH
SPACE PROGRAM
(ACCESS TABLE)
D AT A TA B L E :
• INDIVIDUAL ROOMS
• TYPE OF ROOM
• WHO IS USING IT
ROOM OBJECTS:
• GEOMETRY
• D AT A AT T R I B U T E S
ROOM LIST
(ACCESS TABLE)
BIM MODEL
(REVIT PROJECT)
Linking Revit to a Database - 1
Using Access and Revit
•
Windows Memory Space
Revit: 64-bit.
Access: 32-bit.
•
32-BIT
ACCESS
OLE – ACE DRIVER
Connection
OLE: ACE (JET) Drivers.
S E R V I C E – A C E PA S S - T H R O U G H
COM: Interop Mode.
ACE Pass-through Service
•
Service
TCP-IP interface.
TCP/IP PROTOCOL
64-BIT
REVIT
ACE Pass-through Service
Linking Revit to a Database - 2
RevitDbLink Overview
•
The “Link”
The “Link” is actually a logical relationship, based on conventions in both programs.
Linking Revit to a Database - 3
RevitDbLink 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#
Database Tables - Named Columns
Excel Worksheet – Fields in First Row
CREATING A DATABASE CONNECTION
Set connection type.
Build connection string.
Create connection.
Make Data Objects.
Define:
•
Primary Key.
•
Update/Delete Commands.
Work with data.
Update database
CONNECTING TO EXCEL
Define Excel objects.
Link to Excel Session:
•
Start new session.
•
“Bind” to existing or start new session.
HIDING EXCEL APPLICATION
Define “ShowWindow” call to Windows.
Apply it to every “Excel” process
Use minimize option.
WORKING WITH EXCEL WORKSHEETS
Get a list of existing worksheets.
Use a Worksheet:
•
Existing.
•
New.
Define C# data objects.
Use the first row of the Excel worksheet to
create columns in the data table.
For the remaining rows in Excel:
•
Get a row from Excel.
•
Make a row in the data table.
For each column in Excel:
•
Get the Excel value.
•
Set the row value.
Add the row to the data table.
WORKING WITH DATA IN C#
Create a data table.
Add columns.
Create a new row.
Work with the rows.
Creating Areas and Solid Forms - 1
Abstracting
Major 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.
Classification
Required Area
Floor
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 - 4
Parti
•
Site Constraints
•
Plan Dimensions
•
Number of Floors
•
Floor Heights
Building Geometry
Constraints
Creating Areas and Solid Forms - 5
Manipulating Areas
Areas Moved to Plan Locations
Creating Areas and Solid Forms - 6
Converting Areas
to 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
MAKING SOLID SHAPE FROM ROOM
Use an existing room.
Create a new family.
Make a new material.
OPTION 1: A PRE-DEFINED RECTANGULAR SOLID
Get the location and dimensions of the room.
Create a family instance.
Adjust dimensions.
Set material.
OPTION 2: A UNIQUE FAMILY USING AN EXTRUSION
Get room shape:
•
Room boundary: list of curves.
•
Each curve: list of segments.
Create CurveArrays.
Build CurveArrArray.
Create new family.
Add extrusion of CurveArrArray.
Get or make a subcategory.
BOTH OPTIONS: APPLY MATERIAL AND SAVE FAMILY
Apply the material to the subcategory.
Save the Family to a file.
BOTH OPTIONS: MAKE AN INSTANCE OF FAMILY
Load the new family:
•
Use the saved file.
•
Delete the file.
Get the family symbol.
Create a new instance:
•
Use family symbol.
•
Location (0, 0, 0).
BOTH OPTIONS: TRANSFER PARAMETER VALUES
Get the parameters:
•
Room – Source.
•
Family – Target.
Transfer values:
•
Get source value.
•
Convert data type.
•
Set target value.
Creating Rooms - 1
Creating Rooms - 2
Computing Rooms
from
Program Database
Rooms in Access
Creating Rooms - 3
Importing
Unplaced Rooms
Unplaced Rooms in Revit
Creating Rooms - 4
Placing Rooms
•
Array of Squares
•
Tagged
•
Moved to Plan
Rooms Placed in an Array and then Moved to the Plan
Creating Rooms - 5
Validating Program
with Database
•
•
Discrepancy
No Database Record.
No Model Element.
Unequal Values.
Actions
No 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
PLACING UNPLACED AREAS
Get the unplaced area.
Calculate points:
•
Square.
•
Required area.
Build a curve array of lines.
Construct an area boundary line:
•
Use the curve array.
Place new area inside boundary.
Transfer the parameter values.
Delete the unplaced area.
Tag the area.
PLACING UNPLACED ROOMS
Option 1: walls.
Option 2: room separator lines.
Make new room.
Delete the unplaced room.
Room Data Sheets - 1
Alternative
Methods
•
Revit
Views.
Tagged Views.
Sheets
•
Access
Views.
Images.
Report.
Room Data Sheets Workflows
Room Data Sheets - 2
Creating Room
Views
•
2D
Crop.
•
3D
Section.
Crop.
•
Visibility
Section.
Crop.
•
Naming
Batch Process - Creating Views
Room Data Sheets - 3
Tagging
Rooms
•
Room Tag
•
Labels
•
Parameters
Batch Process - Tagging Views
Room Data Sheets - 4
Placing
Views 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
CROPPING A 2D VIEW
Use bounding box of subject element.
Create new bounding box.
Set new box size with margins.
Create a new view and apply the bounding
box to it.
SECTIONING A 3D VIEW
Create a new 3D bounding box :
•
Get 3D bounds of the subject element.
•
Create new 3D box with margins.
Make a new 3D view.
Apply the section box.
CROPPING A 3D VIEW IN 2D
Get the room to crop to.
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.
Make the new view.
Get the inverse of the view transform.
Project all of the verticies.
Find the extreme X and Y points.
Create new bounding box with margin.
Add the crop box to the view.
SETTING UNDERLAY AND APPLYING A VIEW TEMPLATE
Set the underlay to none.
Apply a view template.
Color Fill Plans - 1
Flattening Relational
Data
•
Related Tables
Room.
Room Type.
Room Type Category
Calculating Parameter
Values
•
Math
Roll up areas.
•
String
Concatenate.
Color Fill Plan with Calculated Values
Color Fill Plans - 2
Σ
SUM ROOM AREA:
• BY ROOM TYPE CATEGORY
• BY FLOOR
ROOM
ROOM TYPE
ROOM TYPE
CATEGORY
DESCRIPTION
Room Data sheet Access Report
Color Fill Plans - 3
Math Calculation Tool
Signage
Interactive Selection
Multi-line Text Edit
Specialty Equipment
Signage
Questions?
[email protected]