TM How the Revit API has saved our company time and money Rod Howarth Bornhorst + Ward.

download TM How the Revit API has saved our company time and money Rod Howarth Bornhorst + Ward.

If you can't read please download the document

Transcript of TM How the Revit API has saved our company time and money Rod Howarth Bornhorst + Ward.

  • Slide 1
  • TM How the Revit API has saved our company time and money Rod Howarth Bornhorst + Ward
  • Slide 2
  • Revit Technology Conference 2010 Introduction What you can do with the API Examples of B+Ws commands What others are using it for Technical overview of each macro Where to start learning Learning tools / resources The research process Overview
  • Slide 3
  • Revit Technology Conference 2010 Goals Describe WHAT can be done with the API Overview of HOW Ive implemented the API Show you WHERE to find information on the API Show you how to LEARN how to use it Overarching aim is: teach a man to fish
  • Slide 4
  • Revit Technology Conference 2010 Bornhorst + Ward and Autodesk Revit Began implementation in 2005 Used for all structural documentation Fully customized families Continuously looking for ways to improve
  • Slide 5
  • Revit Technology Conference 2010 My experience with Autodesk Revit I dont claim to know Autodesk Revit in any great detail Im coming from a programming background Began developing with API in 2008 Ive picked up some Autodesk Revit skills along the way As opposed to Autodesk Revit users who learn programming
  • Slide 6
  • Revit Technology Conference 2010 How we have implemented the API Ideas pulled from years of Autodesk AutoCAD experience Had a fully customized Autodesk AutoCAD setup Mentality of surely theres a better way Heres what we want to automate go code it Feedback provided by drafters
  • Slide 7
  • Revit Technology Conference 2010 Various API Examples Load Families Title Block Editor Plotting Model Stripper Element Numberer Visibility Togglers Quick Placer Plan Copier Detail Number Modifier Sheet Setup Family Management
  • Slide 8
  • Revit Technology Conference 2010 LoadFamilies Replacement for built in Load Families dialog Loads multiple families at once Small amount of time saved quickly adds up Adaptable to different file structures
  • Slide 9
  • Revit Technology Conference 2010 LoadFamilies Technical Details WPF (Windows Presentation Foundation) user interface Allowed a nice code design with data binding Looks better than tab based windows forms Pictures from thumbnail Actual API implementation is simple Just calls document.LoadFamily / document.LoadFamilySymbol FamilyLoadOptions to override family already present dialog
  • Slide 10
  • Revit Technology Conference 2010 Title Block Editor Easily update all of your title blocks Huge timesaver Original way was to manually edit a schedule took hours Now this is done in a few clicks
  • Slide 11
  • Revit Technology Conference 2010 Title Block Editor Technical Details Heavily coupled with title block families Parameters setup for revisions 1-rev 1-desc 2-rev etc To allow for history As well as parameters showing current revision Loops through parameters to find latest revision Then adds a new one
  • Slide 12
  • Revit Technology Conference 2010 Plotting - Overview Replaces inbuilt printing dialog PDF, DWF, Paper, DWG Automatically names + moves files Links with document management Saves time issuing documents Keeps print settings standard
  • Slide 13
  • Revit Technology Conference 2010 Plotting Technical Details ViewPrinter example is best place to start here This shows a replication of the inbuilt menu A lot going on, but nothing too complex Uses DSOFile for document properties Has been a few quirks in the API Different default file names Prints dont come out in order Has been improvements with every API release
  • Slide 14
  • Revit Technology Conference 2010 Model Stripper Allows stripping of files down to bare minimum Used for sending models out of the office Removes a lot of our intellectual property Reduces file sizes Still retains BIM data
  • Slide 15
  • Revit Technology Conference 2010 Model Stripper Technical Details Uses FilteredElementCollectors to search document elements ParameterFilter, OfClass, OfCategory Calls Document.Delete method with found elements New Revit 2011 API has vastly improved it
  • Slide 16
  • Revit Technology Conference 2010 Element Numbering Sets mark instance parameter Numbering manually has problems Tedious Human error (C1..C2..C4C4..) Does Beams, Sections or Columns in Structural Architectural does Doors, Stairs, Windows, etc Run the tool, setup and click the elements One after the other will number accordingly Allows control over numbering
  • Slide 17
  • Revit Technology Conference 2010 Element Numbering Technical Details Document.Selection.PickObject(ObjectType.Element) method Used in a loop Allows users to select elements one after the other Accessible by getting the Reference.Element Property returned Then simply set the Mark parameter of each picked element
  • Slide 18
  • Revit Technology Conference 2010 Visibility Togglers Toggles visibility of certain things on/off Simple API, small time saved but adds up Emulates Visibility/Graphics menu Allows use in keyboard shortcuts Saves a number of clicks each time Eased transition from Autodesk AutoCAD
  • Slide 19
  • Revit Technology Conference 2010 Visibility Togglers Technical Details Used manifest file to make customizable toggles possible Create KeyboardShortcut to External Tools menu View.setVisibility method Accepts category and visibility
  • Slide 20
  • Revit Technology Conference 2010 Quick Placer Keyboard shortcuts to place detail components Similar to Autocad functionality Custom shortcuts, not Revit shortcuts Imports family if its not present
  • Slide 21
  • Revit Technology Conference 2010 Quick Placer Technical Details Reads CSV file for shortcut details Searches this based on user input KeyPress event on Windows Form 1 Character shortcut to open form UiDocument. PromptForFamilyInstancePlacement
  • Slide 22
  • Revit Technology Conference 2010 Plan Copier Select Plan Type to use as base Select the plans from that type to duplicate Duplicates it for plan types in template View types are setup in template, any version of Autodesk Revit
  • Slide 23
  • Revit Technology Conference 2010 Plan Copier Technical Details Uses FilteredElementCollector.OfClass to get a ViewPlan Then GetValidTypes() to get the types of plans in model Gets ViewPlans with that Type Document.Create.NewViewPlan to make new plan newPlan.ApplyTemplate(originalView) to copy original newPlan.ChangeTypeId(newTypeId)
  • Slide 24
  • Revit Technology Conference 2010 Detail Number Modifier Detail Number automatically set Our numbering is done by View Name Copies the View Name to the Detail Number Does this for all Sections + Callouts on sheets
  • Slide 25
  • Revit Technology Conference 2010 Detail Number Modifier Technical Details Uses a category filter with BuiltInCategory.OST_Sheets Loops sheets, and loops all Views in sheet.Views Retrieves View Name parameter from view.Parameters Sets Detail Number with parameter.Set
  • Slide 26
  • Revit Technology Conference 2010 Standard Sheet Setup Sets up sheets at start of project Ensures standard names + numbering Based on a text file with company standards Saves time, typing and human error
  • Slide 27
  • Revit Technology Conference 2010 Standard Sheet Setup Technical Details Reads text file line by line Title Blocks from Document.TitleBlocks Document.Create.NewViewSheet newSheet.ViewName newSheet.SheetNumber
  • Slide 28
  • Revit Technology Conference 2010 Selection Filter User selects elements Only wants certain types Runs tool, chooses types, It changes selection
  • Slide 29
  • Revit Technology Conference 2010 Selection Filter Technical Details Reads the categories and types of elements selected Edits the UiDocument.Selection.Elements set
  • Slide 30
  • Revit Technology Conference 2010 Family Management System for managing and documenting families Needed an efficient way of providing documentation Old way (PDF version) was too much manual work Multiple parts Saver saves metadata to files Documenter adds information + pictures to database Documentation Intranet page with live view of families Reloader Updates a project to have the latest families
  • Slide 31
  • Revit Technology Conference 2010 Family Management: Saver Writes metadata to family files Automatically prompts and updates version number parameter Stores Version, Date, Author, Editor Breaks barrier between Autodesk Revit and outside world
  • Slide 32
  • Revit Technology Conference 2010 Family Management: Documenter Does initial import to database Select a family file Automatically gets a thumbnail Can add more pictures Add a comment
  • Slide 33
  • Revit Technology Conference 2010 Family Management: Documentation Web page with documentation on families Retrieves all the information from the database Reads metadata from files Displays in easy to read and reference manner Easily accessed from internal systems
  • Slide 34
  • Revit Technology Conference 2010 Family Management: Documentation
  • Slide 35
  • Revit Technology Conference 2010 Family Management: Documentation
  • Slide 36
  • Revit Technology Conference 2010 Family Management: Documentation
  • Slide 37
  • Revit Technology Conference 2010 Family Management: Reloader Ensures the families in the model are the most up to date Gives the option to replace any superseded families Uses the metadata from library to compare to current families
  • Slide 38
  • Revit Technology Conference 2010 Family Management: Saver Technical Details ExternalApplication that captures events DocumentSaving, DocumentSavingAs DocumentOpened, DocumentCreated, DocumentClosed Gets/Updates the parameters when saving Uses DSOFile.dll to store metadata after closed
  • Slide 39
  • Revit Technology Conference 2010 Family Management: Documenter Technical Details Guy Robinson has a thumbnail grabbing library on his blog Can set which view for preview when saving Imports to SQL database Reads the text file with family for sizes
  • Slide 40
  • Revit Technology Conference 2010 Family Management: Documentation Technical Details ASP.NET intranet site Stored in SQL database Uses a batch update of a database scheduled every night So theres no IO access done when user loads a page
  • Slide 41
  • Revit Technology Conference 2010 Family Management: Reloader Technical Details Loops through the families loaded in the document Find the matching family in the families database Read the Version that was taken from the metadata in database Compare with the matching parameter on family loaded Give the user a list of families that have been updated Use LoadFamiliy to replace if user selects it
  • Slide 42
  • Revit Technology Conference 2010 What others are doing Autodesk Revit Extensions Import/Export to 3 rd party applications Analysis Software Cost Estimation Software Room ReNumberer Google Earth Export Revit Content Browser/Importer
  • Slide 43
  • Revit Technology Conference 2010 What others are doing Room Phase Copier Case Changer Door Mark Updater Sort and Mark tool Wood Framing tools Facilities Management Avatech, Tools4Revit RevitTv
  • Slide 44
  • Revit Technology Conference 2010 Where do I start? How do I start learning the Autodesk Revit API? Question Ive been asked many times There are a number of tools and resources for you to use Handouts lists the ones Ive mentioned here
  • Slide 45
  • Revit Technology Conference 2010 Learning Tools + Resources Started out fairly scarce Now getting a lot better Autodesk and the community actively trying to make it easier to learn But you still have to be prepared to do some trial and error
  • Slide 46
  • Revit Technology Conference 2010 C# / VB.Net Resources First step is going to be to learn how to code in C# or VB.NET Make a hello world application in.NET first Plenty of information online MSDN Stack Overflow As well as lots of good books on C# Read mainly the first few chapters Head First C# (Stellman, Greene OReilly)
  • Slide 47
  • Revit Technology Conference 2010 SDK Samples Lots of samples Majority written in C# Can do conversions online A HTML file lists all of them (useful for searching) An External Application puts them all on your ribbon
  • Slide 48
  • Revit Technology Conference 2010 Developers Guide eBook Shipped with SDK on disk Very good overview Easy to understand Best place to start
  • Slide 49
  • Revit Technology Conference 2010 Compiled HTML Help File A CHM file is included with SDK Technical documentation on the classes Detailed descriptions and some examples Learn the basics first
  • Slide 50
  • Revit Technology Conference 2010 Webcasts Dev TV introduction to API webcast recording Regularly done live with question and answers Do a little research into the basics before viewing Check autodesk.com for new live webcasts
  • Slide 51
  • Revit Technology Conference 2010 Autodesk University AU Virtual Previous years classes are available online Download podcasts and listen to them whilst travelling to work
  • Slide 52
  • Revit Technology Conference 2010 Blogs The community is actively increasing the information out there Best is The Building Coder by Jeremy Tammik of Autodesk Other great blogs: Cad Application Development by Matt Mason Revit Programming by Ed Pitt Bolt out of the Red by Guy Robinson Blog.RodHowarth.com
  • Slide 53
  • Revit Technology Conference 2010 Autodesk Revit API Search Engine Google custom search engine I set up Only indexes API specific sites/blogs Search for API specific information Without the general clutter of the internet http://revitapisearch.com
  • Slide 54
  • Revit Technology Conference 2010 Online Forums Great place for beginners 2 main ones AUGI Revit API Forums (most active) Autodesk Discussion Group Lots of helpful people to answer your queries More importantly... lots of questions already asked!
  • Slide 55
  • Revit Technology Conference 2010 Autodesk Developer Network http://autodesk.com/adn A must for all serious API developers. Direct line to Autodesk when you are stuck If they cant do it chances are its not really possible. Works on a subscription model with online support and downloads
  • Slide 56
  • Revit Technology Conference 2010 RevitLookup Saved the best for last This tool is essential to my API development work Allows you to snoop the database via the API. Pick an element, and see what properties and parameters are exposed via the API. First point of call Available free online Formerly known as RvtMgdDbg
  • Slide 57
  • Revit Technology Conference 2010 The Process A number of steps that I generally follow when given a new task Something to use once youve learnt the basics This is how to fish
  • Slide 58
  • Revit Technology Conference 2010 1. Learn how to do it manually Generally you are trying to automate something Rarely possible to do something you cant manually do What are the steps/menus to do it in Autodesk Revit?
  • Slide 59
  • Revit Technology Conference 2010 2. Identify key words / areas What were the menu names? What type of element are you working with? What is the functionality you are doing? Examples Load Family Beam Level Visibility
  • Slide 60
  • Revit Technology Conference 2010 3. RevitLookup Pick the elements you were manually choosing Snoop the whole database and look for the keywords Try and identify parameters or properties If you can see the property here you are in luck!
  • Slide 61
  • Revit Technology Conference 2010 4. Search SDK Samples + Developers Guide Use your key words to do a search Windows can search inside.cs files Can also use the solution with all samples Or the HTML index of samples If there is a sample, life just got easier!
  • Slide 62
  • Revit Technology Conference 2010 5. Search CHM Find more specifics on what you are after Or use it as a refiner for your keywords For if you havent had any luck yet Do a search on variations of your keywords to find correct one Gives you an idea of methods and how to use them
  • Slide 63
  • Revit Technology Conference 2010 6. Search online For if you are still out of luck or are confused API search engine AUGI forums Autodesk Forums ADN knowledge base
  • Slide 64
  • Revit Technology Conference 2010 7. IntelliSense / Experimentation If you have at least a starting point Use IntelliSense to find your way through Good for when you are using a sample as a base Create a test application Run it, use Message Boxes or Debug.Write to output info VSTA can be helpful to avoid reloading Autodesk Revit
  • Slide 65
  • Revit Technology Conference 2010 8. ADN / Forums Reached the end of the line still stuck If you have ADN subscription, use DevHelp Or AUGI forums can be a great, free, help Usually takes a day or two for responses
  • Slide 66
  • Revit Technology Conference 2010 Conclusion The API is very powerful and can save you time + money! Big investment up front, but pays dividends There is a lot of information out there nowadays See your handouts for links Buy pre-made Hire a programmer Or learn yourself! I will be at AEC booth if you want to chat
  • Slide 67
  • Revit Technology Conference 2010 Rod Howarth Questions... and dont forget your survey form!