diary of a wimpy bim manager: tales of in-house revit® api development for architects iffat mai...

Post on 26-Mar-2015

221 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Diary of a Wimpy BIM Manager: Tales of In-House Revit® API Development for Architects

Iffat MaiPractice Application Development ManagerPerkins+Will

Thanks to:

Poll

1.Discipline Architect Engineer Programmer Other

2.Revit Experience Very experienced Quite experienced Not experienced

3.Revit API Skill Very experienced Quite experienced Not experienced

Overview

Introduction Overview of Revit API Tool Development Process Demo of sample tools Walk through some codes Resources

Objective

Share in-house Revit API tool development process

Do it in-house or out-source the development work

Inspire BIM Manager to take on the Revit API challenge

Background

Architectural Degree from MIT Worked with MIT media lab (have some programming skills) Twenty plus years of experience of working in the Architectural

field in NYC. Started as an Arris user (Unix) AutoCAD user (DOS, Windows) CAD Manager IT Manager Digital Design Manager BIM Manager Research Manager/Application Developer

Perkins + Will and Autodesk Revit

Began implementation in 2004

Revit Architecture is our Core BIM Application

Team of 24+ Design Applications Professionals supporting Projects

850+ Staff trained in-house

Over 180 projects are completed or underway

Committed to Use BIM Methods for 100% of our Projects

Kempinski Hotel + Residences

Revit Experience

Familiar with Autodesk® Revit® Architecture

Have an architectural design background

Trained and supported architectural teams to use Autodesk®

Revit® Architecture

Began developing with API in 2007

I’m an Autodesk® Revit® BIM Manager who learned API

programming

Why Customize Revit?

Automate repetitive work Processing large quantity of data Facilitate import & export Synchronize data

What is Revit API?

API = Application Programming Interface

AutoCAD API vs. Revit API

Scripts Lisp ObjectARX ActiveX AutoCAD.Net

.Net VSTA

AutoCAD API Revit API

Revit API History

Revit 5

Revit 6

Revit 7

Revit 8

Revit 9

Revit Architecture 2008

Revit Architecture 2009

Autodesk Revit Architecture 2010

Autodesk Revit Architecture 2011

No APINo APINo APIFirst Public API for Building and Structure

More Element Creation Added

Revit API SDK released

VSTA Released. API for MEP added

Developer’s Guide released

RevitAPI.dll and RevitAPIUI.dll split

Revit API Namespace Changes

Revit 2011 divides the API three primary namespaces: Autodesk.Revit.ApplicationServices

Classes accessing application settings and options

Autodesk.Revit.DB Classes accessing file data

Autodesk.Revit.UI Classes accessing or customizing the user interface

Revit API PlatformRevit API Platform

Revit API Namespaces

Structure(Revit.DB.Structure)

Structure(Revit.DB.Structure)

Database (Revit.DB)

Database (Revit.DB)

User Interface (Revit.UI)

User Interface (Revit.UI)

Application Services

(Revit.ApplicationServices)

Application Services

(Revit.ApplicationServices)

Architecture(Revit.DB.Architecture)

Architecture(Revit.DB.Architecture)

MEP(Revit.DB.Mechanical)(Revit.DB.Electrical )(Revit.DB.Plumbing)

MEP(Revit.DB.Mechanical)(Revit.DB.Electrical )(Revit.DB.Plumbing)

.Net vs. VSTA

Editor: Microsoft Visual Studio Program language

VB.net C#

Create external tools/App Exist outside of Revit Use across many Revit

Projects

.Net VSTA

Editor: Built-in inside Revit Program language

VB.net C#

Create Macro Exist inside of Revit Use only in the Projects it was

created or loaded in

DECAF

Microsoft Visual Studio

.Net Framework 3.5 Editor(IDE) Microsoft Visual Studio

(http://www.microsoft.com/express/Downloads)

Parlez Vous C Sharp?

Language Options: C# VB.net C++

Most sample codes in SDK are written in C# VB.net is much more readable VB.net is not case sensitive. VB.net - Intellisense can automatically corrects Keywords and

variable names Use web translator to convert C# to VB (http://www.developerfusion.com/tools/convert/csharp-to-vb/) Both compiles and runs at the same speed You can reference .dll written in other language.

VB.NET vs. C#

Imports System

Namespace Hello   Class HelloWorld       Overloads Shared Sub Main(ByVal args() As String)          Dim name As String = "VB.NET"

  'See if an argument was passed from the command line          If args.Length = 1 Then name = args(0)

          Console.WriteLine("Hello, " & name & "!")       End Sub    End Class End Namespace

using System;

namespace Hello {   public class HelloWorld {      public static void Main(string[] args) {         string name = "C#";

// See if an argument was passed from the command line         if (args.Length == 1)            name = args[0];

         Console.WriteLine("Hello, " + name + "!");      }   }}

VB.NET C#

(Source: http://www.harding.edu/fmccown/vbnet_csharp_comparison.html)

Autodesk Revit SDK

SDK = Software Development ToolKit Install from Autodesk Revit Installation disk Download from Autodesk Developer Center

http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=2484975

.NET code samples and documentation Useful tools

Autodesk Revit SDK

Add-In Manager RevitLookup RevitAPI.chm Revit 2011 Developer Guide.pdf  

Training

DevTV: Introduction to Revit 2011 Programming - Part 1 - New!  http://download.autodesk.com/media/adn/DevTV_Revit_API_2011_English_Part1/Revit_2011_DevTV_EN.html

DevTV: Introduction to Revit 2011 Programming – Part 2 - New! http://download.autodesk.com/media/adn/DevTv_Revit_NET_English-Part2/Revit%20DevTV%20-%20part

%202.html

.NET

Microsoft Visual Studio

VB.Net

Revit API SDK

Tool Development Process

Tool Proposal

Feasibility Study

Specification

Coding

Debugging

Testing

Deployment

Training

Documentation

Maintenance

Tool Proposal

Welcome ideas from all users Showcase your tools to encourage more ideas. End user – task specific tools Design Application Manager – common issue tools Technical Directors

Quality control Standard enforcement Process enhancement

Feasibility Study

Can you do it with Revit API?Can you do it with Revit API?

How long will it take to do it?How long will it take to do it?

What is my ROI?What is my ROI?

Can you do it using Revit API?

Can the steps be done manually via the User Interface? Use Revit LookUp tool to trace the object Check with RevitAPI.CHM reference to see what properties and

methods are available Review the Revit API Developer’s Guide. Look at the SDK sample folder for similar application Search Revit API blogs and Forum on the internet Verify with ADN support that it can be done

How long will it take to develop?

How familiar are you with Revit API? How good are you with .Net programming Is the logic and task very straight forward? Is there an existing sample application that you can modify? Make your best estimate Then multiply by 3x

What is my ROI?

How often will they use the tool on this project? One time only Only during one phase Used through out the entire project

Can this tool be used on other projects? Not at all If parameter and variable are customizable Yes, all the time!

Specification

Clearly define input and output requirement Describe in details all the functions the

application will have. Work out the logics of how the tool will flow Sketch out flow chart for visual overview Cartoon sets of the input and output forms

and reports

Coding, Debugging & Testing

Use Revit API template to start Use SDK sample application as a base Set Microsoft Visual Studio Debug property to start Revit Add option to automatically load test file Use small test file for initial testing Use copies of actual project files for later testing Solicit project team members to test the application Implement feedback to improve design and performance

Documentation, Training & Maintenance

Add comments inside the codes for documentation Create user guide documentation Add Help button that will take the user directly to the

documentation Provide video snippet for self-guided training Maintenance for version upgrade is required for every new

Revit API release.

Deployment

Consolidate all tools into one folder Create a Ribbon ExternalApplication that

contains all the tools as buttons. Copy the DLL folder to the local machines Maintain subfolder for version control Copy .addin manifest file to designated

Revit addins folder Keep icon files in a separate folder

ExternalApplication Ribbon

Create Ribbon file to combine all commands Design Ribbon icons Read Autodesk Icon Guidelines.pdf Check out Ribbon sample file in the SDK

SDK Samples Category

Basics Geometry Parameters Elements Families Materials Annotation Views Rooms/Spaces Data Exchange MEP Structure

Tools Demo

Data Manipulation Tools Data Manipulation Tools Design Tools

Utility Tools Batch Tools

Data Manipulation Tools

Export Drawing List to Excel Import updates from Excel Add new sheets from Excel

Export Drawing List to Excel Import updates from Excel Add new sheets from Excel

Design Tool

SDK – Sample>Massing MeasurePanelArea

SDK – Sample>Massing MeasurePanelArea

Measure Panel Area (Update)

protected IList<Element> GetPanels(){   FilteredElementCollector collector     = new FilteredElementCollector( m_uiDoc.Document);

  BuiltInCategory bic = BuiltInCategory.OST_CurtainWallPanels;  

 collector.OfClass( typeof( FamilyInstance ) ).OfCategory( bic);     IList<Element> panels = collector.ToElements();   return panels; } Source: http://thebuildingcoder.typepad.com/blog/installation/

Batch Tools

Door Renumber Renumber door number to match

room number

Utility Tool – Find Dwg

Find Dwg

Problem: Dwg can be linked and imported Often Dwg files can’t be found after it is inserted I want to be able to find it and delete it if I want to.

Solution: Filter elements till I find DWG Present them in a list Give user the option to View

and Delete

Revit LookUp Tool

RvtMgdDbg Revit Lookup

ArrayArray

DwgList (Form)DwgList (Form)

Anatomy of Find Dwg Tool

CommandIExternalCommand CommandIExternalCommand

Dwg ObjDwg Obj

CommandData

CommandData

Filter

Anatomy of Find Dwg Tool

Command.vb DwgList.vb (Form) DwgObj.vb

Reference Revit Assemblies

Revit required assemblies: C:\Program Files\Autodesk\Revit Architecture 2011\Program\RevitAPI.dll C:\Program Files\Autodesk\Revit Architecture 2011\Program\RevitAPIUI.dll

Set property of the dll to: Copy Local = False Specific Version = True

Command.vbImports Autodesk.Revit

Imports Autodesk.Revit.UI

Imports System.Windows.Forms

<Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Automatic)> _

<Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Automatic)> _

<Autodesk.Revit.Attributes.Journaling(Autodesk.Revit.Attributes.JournalingMode.NoCommandData)> _

Public Class Command

Implements IExternalCommand

Private m_revit As Autodesk.Revit.UI.UIApplication

Public Function Execute(ByVal commandData As Autodesk.Revit.UI.ExternalCommandData, _

ByRef message As String, _

ByVal elements As Autodesk.Revit.DB.ElementSet) _

As Autodesk.Revit.UI.Result Implements Autodesk.Revit.UI.IExternalCommand.Execute

m_revit = commandData.Application

Dim displayForm As New DwgList(commandData)

Using (displayForm)

If displayForm.ShowDialog() <> DialogResult.OK Then

Return Autodesk.Revit.UI.Result.Cancelled

End If

End Using

displayForm.Dispose()

Return Autodesk.Revit.UI.Result.Succeeded

End Function

Protected Overrides Sub Finalize()

MyBase.Finalize()

End Sub

End Class

Imports

Attributes

Command Class Begin

Command Class End

Function Execute

Sub Finalize

Implements IExternalComman

d

callsDwgListFor

m

callsDwgListFor

m

IExternalCommandImplements IExternalCommand

Private m_revit As Autodesk.Revit.UI.UIApplication

Public Function Execute(ByVal commandData As Autodesk.Revit.UI.ExternalCommandData, _

ByRef message As String, _

ByVal elements As Autodesk.Revit.DB.ElementSet) _

As Autodesk.Revit.UI.Result Implements Autodesk.Revit.UI.IExternalCommand.Execute

m_revit = commandData.Application

Dim displayForm As New DwgList(commandData)

Using (displayForm)

If displayForm.ShowDialog() <> DialogResult.OK Then

Return Autodesk.Revit.UI.Result.Cancelled

End If

End Using

displayForm.Dispose()

Return Autodesk.Revit.UI.Result.Succeeded

End Function

Anatomy of Dwg Obj Tool

Dwg ObjDwg Obj

NameName

ElementID

ElementID

TypeType

ViewTypeViewType

BaseLevel

BaseLevel

DwgList Class

Public Class DwgList

'a reference to the external command data.

Private m_commandData As ExternalCommandData

''' <summary>

''' Constructor

''' </summary>

''' <param name="commandData">the external command data</param>

Public Sub New(ByVal commandData As ExternalCommandData) MyBase.New() InitializeComponent() m_commandData = commandData Initialize() End Sub

Filter

Dim ImportInstanceFilter As New ElementClassFilter(GetType(DB.ImportInstance))

iter = New FilteredElementCollector(doc)_ .WherePasses(ImportInstanceFilter)_ .GetElementIterator()

Looping (Do While…Loop)

'Move to the first instance symbol

iter.Reset()

'Create a array of DwgObjList

Do While iter.MoveNext If (Not (iter.Current) Is Nothing) Then

sym = iter.Current

sym_name = sym.Parameter(ImpSymName).AsString

ins_id = sym.Id

ins_size = sym.Parameters.Size

parByName = iter.Current.Parameter(csParamToFind)

Is2D = iter.Current.Parameter(csParam2D)

Linked = sym.IsLinked

LinkedType = "N.A."

viewname = "N.A."

baselevel = "N.A."

Creating DwgObj Array

DwgObjList.Add(New DwgObj(sym_name, ins_id, LinkedType, viewname, baselevel))

Dwg ObjDwg Obj

NameName

ElementID

ElementID

TypeType

ViewTypeViewType

BaseLevel

BaseLevel

Tool Deployment

Compile .dll Create .addin manifest files Pushout the dll and .addin files to local machines

Or

Use Add in Manager to load the external tool manually

Register .addin Manifest file

<?xml version="1.0" encoding="utf-8"?>

<RevitAddIns>

<AddIn Type="Command">

<Text>$projectname$</Text>

<Description>Some description for $projectname$</Description>

<Assembly>$destinationdirectory$\$safeprojectname$.dll</Assembly>

<FullClassName>$safeprojectname$.Commands</FullClassName>

<ClientId>$guid1$</ClientId>

</AddIn>

</RevitAddIns>

GUID

GUID = Globally Unique Identifierhttp://www.guidgenerator.com/online-guid-generator.aspx

Addin File

Revit requires the add-in to be registered BEFORE it starts Open the FindDwg.addin file Edit the <Assembly> to reflect the actual location of .dll Copy the .dll to one of the following locations: - For the current Windows User only

%APPDATA%\Autodesk\REVIT\Addins\2011

- For all users %ALLUSERSPROFILE%\Autodesk\REVIT\Addins\2011

For Windows XP – C:\Documents and Settings\All Users\ApplicationData\Autodesk\Revit\Addins\2011\

For Vista/Windows 7 – C:\ProgramData\Autodesk\Revit\Addins\2011\

How to run the Tool?

Go to Addin Tab > External Commands dropdown, select “FindDwg”

Or

Create a custom Application with a Ribbon button for the command

Blogs

Bolt Out Of The Red – Guy Robinson - http://redbolts.com/blog/

Revit Programming – Ed Pitt - http://revit-programmer.blogspot.com/

The Building Coder – Jeremy Tammik - http://thebuildingcoder.typepad.com/blog/

CAD Application Development – Matt Mason - http://cadappdev.blogspot.com/

Rod Howarth – Rod Howarth - http://roddotnet.blogspot.com/

Revit Resource Guide

Revit Resource Guide – by Rod Howarth(http://blog.rodhowarth.com/2010/03/revit-api-resource-guide-

free-download.html)

Summary

Knowing Revit API gives you an edge over your competition Learning Revit API has become a lot easier than ever before To do or not to do (in-house vs. out-sourcing) ? Give yourself an early Holiday present – Learn Revit API!

Please Complete the Survey!

Email: Iffat.mai@perkinswill.com

Q & A

Autodesk [and other] are registered trademarks or trademarks of Autodesk, Inc., and/or its subsidiaries and/or affiliates in the USA and/or other countries. All other brand names, product names, or trademarks belong to their respective holders. Autodesk reserves the right to alter product and services offerings, and specifications and pricing at any time without notice, and is not responsible for typographical or graphical errors that may appear in this document. © 2010 Autodesk, Inc. All rights reserved.

top related