Slide 1 Revit Structure API Analysis Link, Rebar and Detailing Jeremy Tammik Developer Technical Services About the Presenter Jeremy is a member of the AEC workgroup of the Autodesk Developer Network ADN team, providing developer support, training, conference presentations, and blogging on the Revit API. He joined Autodesk in 1988 as the technology evangelist responsible for European developer support to lecture, consult, and support AutoCAD application developers in Europe, the U.S., Australia, and Africa. He was a co-founder of ADGE, the AutoCAD Developer Group Europe, and a prolific author on AutoCAD application development. He left Autodesk in 1994 to work as an HVAC application developer, and then rejoined the company in 2005. Jeremy graduated in mathematics and physics in Germany, worked as a teacher and translator, then as a C++ programmer on early GUI and multitasking projects. He is fluent in five European languages, vegetarian, has four kids, plays the flute, likes reading, travelling, theatre improvisation, and carpentry, loves mountains, oceans, sports, and especially climbing. Jeremy Tammik Developer Technical Services EMEA Autodesk SARL Introduction It is my pleasure to work in for the Autodesk Developer Network, ADN, in the AEC workgroup. ABCs of Revit Programming Prerequisite Knowledge of Revit API basics Basic Revit API recordings are available DevTV Introduction to Revit Programming Revit API 2011 Introduction webcast (May 20,2010) ADN web site > Revit product > Knowledgebase > Whitepapers and Training Videos http://adn.autodesk.com/adn/servlet/item?siteID=4814862&id=15228661&linkID=4901650 Revit API - what's new in 2011 webcast ADN web site > Revit product > Knowledgebase > Whitepapers and Training Videos http://adn.autodesk.com/adn/servlet/item/user?siteID=4814862&id=15051692&linkID=4901650 DevTV Introduction to Revit 2010 Programming http://usa.autodesk.com/adsk/servlet/index?id=2484975&siteID=123112 Introduction This course assumes basic knowledge of Revit programming. We will not cover basics such as how to define an external command, add menus, use filtering, etc. VSTA is also not covered. If you are not familiar with the basic Revit API and have missed Revit API Introduction course we had last week, a recording is available on the ADN web site as well as on the developer center training schedule page. The download link is on the right side of the page. Agenda Analysis Link Overview - workflow, rac versus rst, physical versus analytical model RstLabs - analysis link requirements and labs RstLink - sample analysis link application Rebar Revit Structure rebar workflow Generate and extract rebar and its information Detailing Generate views and sheets Import and export dwg and other external file formats Add text, dimensioning and annotation Introduction Our discussion here proceeds in three steps. First, look at the workflow and how it is supported by Revit Structure or RST. Secondly, walk through a series of labs related to extracting and analysing the data managed by RST. Finally, we will look at a sample application linking RST with an external application. In this case, the external stress analysis package is simulated by AutoCAD. Analysis Link Overview Completing the Building Information Model Building Information Modeling (BIM) - The creation and use of coordinated, internally consistent, computable information about a building project in design and construction Image Courtesy of DDB Architectural International Ltd. BUILDING INFORMATION MODELING Overview Building information modeling (BIM) is the creation and use of coordinated, consistent, computable information about a building project in design that yields reliable digital representations of the building - representations used for design decision-making, production of high-quality construction documents, performance predictions, cost-estimating and construction planning, and, eventually, for managing and operating the facility. The focus of this presentation is on the structural part of it with Revit Structure. Revit Structure Target Projects Buildings - Any Type, any Size, any Complexity made of any kind of Materials Overview Even if structural engineers can design any type of structures including bridges, tunnels, plants etc., RST focuses on building design. It does not mean that a user cannot design other type of structures, but the marketing that we do, the training and documentation materials that we provide are positioning RST on building design. Current Analysis Process Overview Currently, the analysis of a building involves a lot of manual data transfer with accompanying loss of information and additional cost. The aim of Revit and its building information model and Revit Structure and its linked physical and analytical model is to preserve more information, support communication between all parties involved, and reduce cost. Structural Market Definition Designer Structural Analysis Construction Documentation Engineer Drafter Contractor Steel Detailer Fabrication and Shop Drawings Overview The structural industry is extremely fragmented. We segment is into 2 parts: design and fabrication. The design is composed of 2 tasks (analysis and construction drawings) done by 3 actors and the fabrication focuses on shop drawings. Tasks and User Focus Designer Engineer Drafter Revit Structure Focus Construction Documentation Contractor Steel Detailer Fabrication and Shop Drawings Fabrication Structural Analysis Modeling Overview The focus that we have for RST is on the design part only where we do modeling for drawings and analysis. We do not do analysis. Issues to Address Problems addressed by Revit Structure Same information is duplicated for different tasks Lack of coordination tools Between drafters and engineers Between architects and engineers Lack of standard software modelling platform How are these problems addressed? Overview Introduction Overview Revit Structure is used by a structural engineer to manage and combine data from several different sources: Architectural data, the building design, which can come from Revit Architecture, but also from other Autodesk or non-Autodesk products. Analysis data for stress analysis in external packages. Details which are designed based on the analysis results. Structural BIM Workflow: The 4 Cs ARCHITECTS STRUCTURAL ENGINEERS BUILDERS FABRICATORS Coordination Calculations Construction Documents Construction Overview In the context of the structural BIM, we focus on four C's which require significant coordination between architects, structural engineers, fabricators and builders: Coordination Calculations Construction Documents Construction Developers and ADN partners can develop applications for each of the four Cs: - Coordination with other disciplines Using the rich information in RST and process it against other disciplines Calculations or Analysis Link analysis and design applications Construction documentations Focus on local standards Automation Construction Use the information downstream for fabrication Application Development Opportunities Integration of analysis and design software Automatic modeling Reinforcement Framing Connections (Steel, precast) Portal frames Bridge/tunnels Special structures (towers, retaining walls) Data exchange (with other AutoCAD based applications) Scheduling Drawing automation ... Overview As the API is becoming more and more robust, there are many areas of opportunity to port existing applications to RST or to develop new ones. The API is a great way to automate repetitive manual tasks such as reinforcement, framing modeling. There is also an opportunity to create dedicated Revit families and to drive their generation with the API such as steel connections. You can also imagine building wizard type applications that generate civil structures including soil, geometry reinforcement etc. The API is also built so you can link the RST model to your existing application and complete what RST does not do such as local standard drawings or schedules. With the API you can drive an application to generate a dwg file and then import it automatically in RST. Application Development Opportunities Integration of analysis and design software Automatic modeling Reinforcement Framing Connections (Steel, precast) Portal frames Bridge/tunnels Special structures (towers, retaining walls) Data exchange (with other AutoCAD based applications) Scheduling Drawing automation ... Overview Today we will focus on the three highlighted areas. Comparison with Revit Architecture General User Interface Command organization Category filtering Functionality added Analytical model (generation and adjustment) Load modelling API specific model and load objects Rebar modelling Composite metal deck Graphical column schedule ... Overview Revit Architecture and Structure have a lot of common features. The differences are visible in the user interface in the command organisation and the category filtering. Some structure-specific functionality has been added. Comparison with Revit Architecture Functionality removed Reflected ceiling plans Room related functionalities Model text ... Overview Some functionality has also been removed. Analytical Model Structural analysis model differs from drawing model Revit Structure solves this problem Physical model is used for drawings, coordination and construction Analytical model is the simplified model used for analysis Overview The most important problem of the structural industry is the fact that the information used for structural analysis is physically different than the one used for drawings. Revit Structure solves this problem. The physical model is the model that we use for drawings, coordination and construction, and the analytical model is the simplified model used for analysis. Some examples show the discrepancies between the analytical and physical models. For example, consider a plan view where the walls need to be aligned for the analysis and the beams need to join the centre of columns to end of walls. Another example is an elevation where the analytical model is horizontally projected even if the physical model of the beam has a slope. Finally, consider a situation where the physical model of the beam is curved and the analytical model is segmented. Revit Structure maintains the coordination between the 2 models and will keep the analytical model of each element connected. As a third party analysis developer, you just need to work with the analytical model. What is in the analytical model? Members that need to participate in the analysis Geometry (location) Sections Materials Release conditions Reference to level (optional) Loads Load cases Load combinations Point, line, area loads Boundary conditions Support data Overview In this presentation, we explain how to access all this information. Analytical vs Physical Model Overview Revit Structure combines the physical model which drives the modeling and documentation process with the analytical model which drives the analysis process and export to third party analysis software. The Revit Structure analytical model can be adjusted for analysis purposes while the physical model stays accurate for documentation. Analytical vs Physical Model Overview Here are examples of different cases highlighting the difference between the physical and the analytical models and the need for flexibility in linking the two: The end points of two beams may are not at the same location. We want to the end points of their analytical models to be located at the same point. An engineer decides to move the end of one beam. Remodelling an old historic building, walls may not be straight. An engineer decides to approximate them by planes for analysis. Two walls with different thicknesses but aligned analytical planes. A wall with a parapet that does not need to be included in the analysis. Adjusting the location of analytical columns horizontally. The cases are taken from AE_CD_RST2008/Analysis_workflows/Analysis_Workflows.pdf. Data Exchange Workflow Geometry Physical Analytical Loads Connectivity Material Project parameters Overview In general, we start off with a physical model. This can be used to automatically generate the analytical one. The analytical model is exported to an external analysis package, which adds its own data. As a result of the analysis, the analytical model may be modified, resulting in changes in the physical model as well. New changes may be added in the physical model as well. All of these processes may continue over many iterations. The example presented displays the following steps: RST defines the physical model, analytical model composed of geometry, loads, connectivity (release and boundary conditions), material properties, project parameters. This is information is accessible via the API In the analysis software we get the analytical model Analytical model initializes specific properties not present in RST (here they are symbolized with X and Y) and the user can change them. We can do an analysis, delete specific members, change sections and then the analysis software updates the RST model Changes can be add, delete, create, and move members and also add new properties to RST members If we select a column and duplicate it, it will have the Y parameter that was defined in 3) So the next time we round trip the data to the 3rd party, we retrieve the Y parameter. Analysis Requirements Extract the analytical model geometry Extract the load cases, load combinations, loads Extract release and boundary conditions Update the model with changes and new and deleted elements Add load cases and load combinations Add loads and reactions Add project information, shared parameters Add shared parameters on structural objects Overview Now we understand the structural workflow and its needs, we can start looking at the API features provided to address these needs. Here is an overview of the typical requirements for implementing a link to an external analysis package using the RST API. In the following slides, we will look at the Revit samples and a series of labs demonstrating how to address these issues one by one. Finally, the results of these labs will be integrated into the sample link application. Adding local parameters to Revit Shared parameters Can be defined in an external file Can be added with the API Can be defined per element Can be project specific, e.g. building codes Templates Can contain specific information such as load combinations Overview Here are some different strategies for a third party application to add new properties in the database. Analytical model access How to get the ... ... thickness of a wall with multiple layers? SDK sample TestWallThickness ... analytical model of an in-place family? SDK sample AnalyticalViewer ... analytical model defined in an external family? SDK sample AnalyticalViewer ... multiple analytical segments of a curved beam? Tessellate the underlying curve Overview Here are some typical frequently asked questions and examples on how to solve them. Useful Revit SDK Samples Parameters BrowseBindings CreateShared FireRating InvisibleParam Analytical Model AnalyticalSupportData_Info AnalyticalViewer BoundaryConditions InplaceFamilyAnalyticalModel3D Loads RotateFramingObjects SlabProperties SpanDirection Overview Currently, information on how to combine Revit API calls to achieve certain complex tasks is contained mainly in the SDK samples. Here is a list of some of the Revit SDK samples which address areas related to structure. Revit Structure Analysis Labs Revit Structure Analysis Labs Loads 1-1 Load cases, natures, combinations, usages 1-2 Point, line and area loads 1-3 Load parameters and modification 1-4 Load symbols 1-5 Creating load objects Structure 2-1 Columns 2-2 Framing 2-3 Foundations 2-4 Structural standard family instances 2-5 Structural system family instances: walls, floors, footings Analytical Model 3 Analytical model RstLabs In the section, we demonstrate step by step how to implement the functionality required for an application linking Revit Structure with an external analysis package. The first group of labs addresses access and modification of load data, the second examines the building structure, and the third addresses the entire analytical model. Load Grouping Objects Load Cases Load Natures Load Combinations Load Usages Lab 1-1 To retrieve load case, nature, combination and usage objects, simply filter for the corresponding object class LoadCase, LoadNature, LoadCombination and LoadUsage To create new objects, use the Autodesk.Revit.Creation.Document methods NewLoadCase(), NewLoadCombination(), NewLoadNature(), NewLoadUsage() accessible through ActiveDocument.Create RstLabs This first lab extracts and lists the load cases, natures, combinations and usages defined in the Revit model. Loads Grouping Code Retrieve objects public static List GetAllLoadNatures( Application app ) { List a = new List(); Filter filterType = app.Create.Filter.NewTypeFilter( typeof( LoadNature ) ); app.ActiveDocument.get_Elements( filterType, a ); return a; } Create objects ActiveDocument.Create. LoadCase NewLoadCase( string name, LoadNature nature, Category category ); LoadNature NewLoadNature( string name ) LoadUsage NewLoadUsage( string name ) LoadCombination NewLoadCombination( string name, int typeInd, int stateInd, double[] factors, LoadCaseArray cases, LoadCombinationArray combinations, LoadUsageArray usages ) RstLabs Loads Grouping Demo RstLabs Todo: add image of model. To run the demo, install and compile RstLabs, add Lab 1-1 to Revit.ini, start Revit, and select the external command. [ExternalCommands] ECCount=1 ECName1=RS Lab1-1 Load Natures, Cases and Combinations ECDescription1=Lab1_1... ECClassName1=RSSolvedLabsCode.Lab1_1 ECAssembly1=C:\a\j\adn\rst\rst_api\RSSolvedLabsCode\bin\RSSolvedLabsCode.dll Access to Load Objects Point Loads Line Loads Area Loads Lab 1-2 Shows how to access all load objects using the base or specific classes All three load classes are derived from LoadBase Creation through NewAreaLoad (3 overloads), NewLineLoad (2), NewPointLoad RstLabs Lab 1-2 shows how to access all load objects using the base or specific classes. All three load classes are derived from LoadBase. They are creation through NewAreaLoad() (3 overloads), NewLineLoad() (2), and NewPointLoad(). Retrieve Load Objects public static void GetAllSpecificLoads( Application app, ref ElementSet pointLoads, ref ElementSet lineLoads, ref ElementSet areaLoads ) { List a = new List(); Filter filterTypeLoad = app.Create.Filter.NewTypeFilter( typeof( LoadBase ), true ); app.ActiveDocument.get_Elements( filterTypeLoad, a ); foreach( Element elem in a ) { if( elem is PointLoad ) { pointLoads.Insert( elem ); } else if( elem is LineLoad ) { lineLoads.Insert( elem ); } else if( elem is AreaLoad ) { areaLoads.Insert( elem ); } } } RstLabs Just like in the preceding lab, we iterate over all Revit elements and pick out the object types of interest. For each load type object, a number of properties are defined for extracting and modifying data. Load Objects Demo RstLabs Todo: add image of model. Open RstLabs.rvt to obtain a model with a few predefined loads. Run the external command Lab 1-2 after adding RstLabs.dll to Revit.ini. Load Object Parameters Lab 1-3 Shows more details about loads, this time from selected objects How to access load parameters How to modify load objects Dim iter As ElementSetIterator = doc.Selection.Elements.ForwardIterator While iter.MoveNext Dim elem As Revit.Element = iter.Current If TypeOf elem Is PointLoad Then ListAndModifyPointLoad(CType(elem, PointLoad)) ElseIf TypeOf elem Is LineLoad Then ListAndModifyLineLoad(CType(elem, LineLoad), app) ElseIf TypeOf elem Is AreaLoad Then ListAndModifyAreaLoad(CType(elem, AreaLoad), app) End If End While RstLabs Lab 1-3 continues the exploration about loads. Get Parameter by Display Name Direct parameter access by display name Parameter para = elem.get_Parameter( name ); Some parameters are accessible via display name only Using BuiltInParameter enum is language independent elem.get_Parameter( BuiltInParameter.LOAD_IS_REACTION ) RstLabs Some element parameters can be accessed via display name only. In general, we try to use the BuiltInParameter enum to access parameters whenever possible, since it is language independent. Point Load Parameters Equivalent LOAD_IS_REACTION "Is Reaction" LOAD_CASE_ID "Load Case" Similar LOAD_USE_LOCAL_COORDINATE_SYSTEM "Orient to" Built-in only LOAD_USE_LOCAL_COORDINATE_SYSTEM_HOSTED LOAD_IS_CREATED_BY_API Display name only "Fz" RstLabs Parameters vary from Revit version to version. Other Load Parameters See list of 59 load-relevant built-in parameters at end of Labs1.vb LOAD_ALL_NON_0_LOADS LOAD_AREA_AREA LOAD_AREA_FORCE_FX1 LOAD_AREA_FORCE_FX2 LOAD_AREA_FORCE_FX3 LOAD_AREA_FORCE_FY1 LOAD_AREA_FORCE_FY2 LOAD_AREA_FORCE_FY3 LOAD_AREA_FORCE_FZ1 LOAD_AREA_FORCE_FZ2 LOAD_AREA_FORCE_FZ3 LOAD_ARROW_SEPARATION LOAD_ATTR_AREA_FORCE_SCALE_FACTOR LOAD_ATTR_FORCE_ARROW_TYPE LOAD_ATTR_FORCE_SCALE_FACTOR LOAD_ATTR_LINEAR_FORCE_SCALE_FACTOR LOAD_ATTR_MOMENT_ARROW_ARC LOAD_ATTR_MOMENT_ARROW_LINE LOAD_ATTR_MOMENT_SCALE_FACTOR LOAD_CASE_CATEGORY LOAD_CASE_ID LOAD_CASE_NAME LOAD_CASE_NATURE LOAD_CASE_NATURE_TEXT LOAD_CASE_NUMBER LOAD_COMBINATION_FACTOR LOAD_COMBINATION_NAME LOAD_COMBINATION_STATE LOAD_COMBINATION_TYPE LOAD_COMMENTS LOAD_COMMENT_TEXT LOAD_DESCRIPTION LOAD_FORCE_FX LOAD_FORCE_FY LOAD_FORCE_FZ LOAD_IS_CREATED_BY_API LOAD_IS_PROJECTED LOAD_IS_REACTION LOAD_IS_UNIFORM LOAD_LINEAR_FORCE_FX1 LOAD_LINEAR_FORCE_FX2 LOAD_LINEAR_FORCE_FY1 LOAD_LINEAR_FORCE_FY2 LOAD_LINEAR_FORCE_FZ1 LOAD_LINEAR_FORCE_FZ2 LOAD_LINEAR_LENGTH LOAD_MOMENT_MX LOAD_MOMENT_MX1 LOAD_MOMENT_MX2 LOAD_MOMENT_MY LOAD_MOMENT_MY1 LOAD_MOMENT_MY2 LOAD_MOMENT_MZ LOAD_MOMENT_MZ1 LOAD_MOMENT_MZ2 LOAD_NATURE_NAME LOAD_USAGE_NAME RstLabs LOAD_USE_LOCAL_COORDINATE_SYSTEM LOAD_USE_LOCAL_COORDINATE_SYSTEM_HOSTED Here is a full list of parameters relevant to loads given in the comment at the end of Labs1.vb. Point Load Properties LoadBase HostElement LoadCaseName LoadCategoryName LoadNatureName PointLoad Force Moment Point Explore Help file Debugger RvtMgdDbg Reflection RstLabs Some of the values accessible through parameters are also exposed directly as properties on the object class. Whenever you are looking for a specific property, you will need to explore the Revit API and one or more suitable sample models to determine what exactly you are looking for and how to access it. More Point Load Properties RevitLookup Included in Revit SDK RstLabs Modify Load Demo // Scale Fz by factor 2 Parameter paramFz = ptLd.get_Parameter( "Fz" ); double Fz_old = paramFz.AsDouble(); paramFz.Set( 2.0 * Fz_old ); RstLabs In "RS Labs.rvt", select a point, line and area load, then run the external command for Lab 1-3. One new property in 2008 is the HostElement. Many other properties are also available. Here is an example of a line load element. Load Symbols Lab 1-4 Retrieve load symbols aka types available in the project Determine load symbol family One utility for all load symbols (point, line and area) Another one specifically for point loads Load symbols are system families, not standard ones RstLabs Retrieve Load Symbols Use filtered element access Pick out ElementType instances Check for structural loads category Make use of new classes LoadTypeBase, PointLoadType, LineLoadType, AreaLoadType Search for the base class instead of the category public static List GetAllLoadSymbols( Application app ) { List a = new List(); Filter filter = app.Create.Filter.NewTypeFilter( typeof( LoadTypeBase ), true ); app.ActiveDocument.get_Elements( filter, a ); return a; } RstLabs Determine Load Symbol Family No dedicated classes Examine family name parameter BuiltInParameter.SYMBOL_FAMILY_NAME_PARAM equals "Point Loads", "Line Loads", "Area Loads" RstLabs Creating Load Objects Lab 1-5 Show how to create a new Load object, specifically PointLoad One as reaction, simulating analysis result One as standard external load Also show how to Set a selected symbol for this new load Assign the load to a selected load case RstLabs Lab 1-5 shows how to create a new load object, specifically a point load. It creates two new point loads by calling NewPointLoad() with somewhat arbitrary parameters. One as reaction, simulating an analysis result, the other is a standard external load. It also shows how to set a selected symbol for this new load and assign the load to a selected load case. To assign a selected symbol to it, all point load symbols in the document are retrieved and the user is allowed to select one of them. Its id is then assigned to the newly created point load ELEM_TYPE_PARAM. Similarly, to assign a load case, all load cases are retrieved and displayed and the selected one's id is assigned to the LOAD_CASE_ID parameter. Point Load Creation Create Revit.Creation.Document.NewPointLoad( reference As Reference, force As XYZ, moment As XYZ, isReaction As Boolean, symbol As PointLoadType, plane As SketchPlane ) As PointLoad Revit.Creation.Document.NewPointLoad ( point As XYZ, force As XYZ, moment As XYZ, isReaction As Boolean, _ symbol As PointLoadType, plane As SketchPlane ) As PointLoad Assign Symbol Iterate over all point load symbols Assign selected one's id to parameter BuiltInParameter.ELEM_TYPE_PARAM Assign Load Case Iterate over all load cases Assign selected one's id to parameter BuiltInParameter.LOAD_CASE_ID RstLabs Structure Load Creation Load creation methods Revit.Creation.Document.NewPointLoad( reference As Reference, force As XYZ, moment As XYZ, isReaction As Boolean, symbol As PointLoadType, plane As SketchPlane ) As PointLoad Added a load type and sketch plane argument Optional, can be null (Nothing in VB) = Default load type Point (Line/Area) LoadType and *LoadTypeSet objects added Supports creation of hosted loads Overloads for assignment of a host element or geometry reference of a host element to create the hosted loads NewPointLoad(), NewLineLoad() and NewAreaLoad() RstLabs Revit Structure has enhanced load elements by adding their symbols. In the API, parameters used for load creation have changed: all load creation methods now take an optional load type and sketch plane argument. Both of these arguments are optional and can be supplied null (Nothing in VB) to use the default load type for the category of load being created. Point(Line/Area)LoadType and Point(Line/Area)LoadTypeSet objects are added. In addition, the Autodesk Revit API now supports creation of hosted loads. Several overloads have been added for NewPointLoad(), NewLineLoad() and NewAreaLoad() permitting assignment of a host element or geometry reference of a host element to create the hosted loads. Columns and Framing Structural Elements Standard families Lab 2-1, 2 Retrieve all structural 'line segment' or 'stick' elements Columns belong to a separate standard family Others such as beam, brace, joist, etc. belong to the framing standard family RstLabs The next section explores accessing and modifying structural elements and their data in RST. Select all columns Select all standard family instances for category OST_StructuralColumns BuiltInCategory bicSc = BuiltInCategory.OST_StructuralColumns; List columns = RacUtils.GetAllStandardFamilyInstancesForACategory( app, bicSc ); . . . public static List GetAllStandardFamilyInstancesForACategory( Application app, BuiltInCategory bic ) { List elements = new List(); Filter filterType = app.Create.Filter.NewTypeFilter( typeof( FamilyInstance ) ); Filter filterCategory = app.Create.Filter.NewCategoryFilter( bic ); Filter filterAnd = app.Create.Filter.NewLogicAndFilter( filterType, filterCategory ); app.ActiveDocument.get_Elements( filterAnd, elements ); return elements; } RstLabs To select all columns in the model, we once again use filtering to select all standard family instances for category OST_StructuralColumns. We can display generic element and column properties such as element id, symbol name, structural type and analytical model type. Select all framing elements Select all standard family instances for category OST_StructuralFraming Dim catStructuralFraming As Category = doc.Settings.Categories.Item(BuiltInCategory.OST_StructuralFraming) Dim frmEls As ElementSet = RBUtils.GetAllStandardFamilyInstancesForACategory(app, catStructuralFraming.Name) sMsg = "There are " & frmEls.Size & " Structural FRAMING elements:" & vbCrLf Dim frmEl As FamilyInstance For Each frmEl In frmEls sMsg += " Id=" & frmEl.Id.Value.ToString & " Type=" & frmEl.Symbol.Name & _ " Struct.Usage=" & frmEl.StructuralUsage.ToString & _ " Struct.Type=" & frmEl.StructuralType.ToString & _ " Analytical Type=" & frmEl.AnalyticalModel.GetType.Name & vbCrLf Next MsgBox(sMsg) RstLabs Foundations Structural Elements Foundations standard family Lab 2-3, 4 Retrieve structural foundation elements May not be needed for analysis package Alternative approach retrieves all standard family instances having structural usage, i.e., having an analytical model RstLabs Foundations are structural elements and also make use of a standard family. Lab 2-2 demonstrates how to retrieve all structural foundation elements. This may not be required for every analysis package. An alternative approach would be to retrieve all standard family instances having structural usage, i.e., having an analytical model. Retrieve Foundations Get all standard structural foundation elements Category OST_StructuralFoundation Excludes 'Wall Foundation' System Type under 'Structural Foundations' category in the Browser These belong to 'Continuous Footing' system family, Lab 2-3 Excludes 'Foundation Slab' System Type under 'Structural Foundations' category in the Browser These are internally implemented as Revit 'Floor' system family, Lab 2-3 RstLabs To retrieve all foundations in the model, we can use the same approach as above, getting all standard structural foundation elements, using the category OST_StructuralFoundation. This excludes the 'Wall Foundation' system type under 'Structural Foundations' category in the browser, because these belong to the 'Continuous Footing' system family, and also the 'Foundation Slab' system type under the 'Structural Foundations' category in the browser, which are internally implemented as Revit 'Floor' system family. These are examined in Lab 2-3. Retrieve Structural Family Instances Alternative approach Select all standard family instances with an analytical model Filter filter = app.Create.Filter.NewTypeFilter( typeof( FamilyInstance ) ); List instances = new List(); app.ActiveDocument.get_Elements( filter, instances ); string sMsg = "All structural family instances (generic check):"; foreach( FamilyInstance fi in instances ) { // // note that instead of looping through and checking for a // non-null analytical model, we might also be able to use some // other criterion that can be fed straight into the Revit API // filtering mechanism, such as structural usage: // if( null != fi.AnalyticalModel ) { sMsg += "\r\n " + RstUtils.StructuralElementDescription( fi ); } } RstLabs As an alternative approach, we can also iterate over the document elements and select all FamilyInstance objects having an analytical model. Walls, Floors, Footings Structural Elements System families Wall, Floor (Slab), Continuous Footing Lab 2-5 Retrieve structural elements from these system families Not all instances will have analytical model (user-definable!) RstLabs The structural elements walls, floors, and footings also all make use of system families, specifically Wall, Floor (Slab), and Continuous Footing, respectively. Lab 2-3 shows how to retrieve all structural elements from each of these system families. Please note that some instances may not have an analytical model, since this property is user definable. Analytical Model Abstract API base class AnalyticalModel Specific derived classes, gone in 2011 Wall AnalyticalModelWall Floor AnalyticalModelFloor Cont.Footing AnalyticalModel3D Column, Framing AnalyticalModelFrame Foundation AnalyticalModelLocation RstLabs The analytical model makes use of a separate little class hierarchy derived from the abstract base class AnalyticalModel. It defines specialised derived classes for various structural elements. Retrieve Structural Walls Retrieve all Wall elements having an analytical model Filter filterWall = app.Create.Filter.NewTypeFilter( typeof( Wall ) ); List walls = new List(); app.ActiveDocument.get_Elements( filterWall, walls ); ElementSet elems = app.Create.NewElementSet(); foreach( Wall w in walls ) { if( null != w.AnalyticalModel ) { elems.Insert( w ); } } Same for ContFooting elements RstLabs To retrieve all Wall elements having an analytical model, we perform the normal Revit document elements iteration, pick out wall elements, and check for the presence of an analytical model using the Wall.AnalyticalModel property. The same approach can be used for ContFooting elements. Retrieve Structural Floors Retrieve all Floor elements having a non-empty analytical model Filter filterFloors = app.Create.Filter.NewTypeFilter( typeof( Floor ) ); List floors = new List(); app.ActiveDocument.get_Elements( filterFloors, floors ); ElementSet elems = app.Create.NewElementSet(); foreach( Floor f in floors ) { AnalyticalModel anaMod = f.AnalyticalModel; if( null != anaMod ) { // // For floors, looks like we need to have additional check: // for non-structural floors anaMod is NOT null, but it IS empty! // AnalyticalModelFloor floorAnaMod = anaMod as AnalyticalModelFloor; if( 0 < floorAnaMod.Curves.Size ) { elems.Insert( f ); } } } RstLabs A similar approach as for walls can also be used for floor elements. However, in the case of floors, the analytical model may well be non-null, but still be empty, so we need to add an additional check that the number of curves in it, given by AnalyticalModelFloor.Curves.Size, is actually greater than zero. Analytical Model Investigate geometry contained in model Lab 3 Retrieve detailed analytical model geometry for selected elements, depending on the family and/or category RstLabs Lab 3 implements some code to investigate the geometry contained in the analytical model. It retrieves detailed analytical model geometry for selected elements, depending on their family and/or category. Retrieve Analytical Model Iterate over selected elements Wall Floor ContFooting FamilyInstance with category OST_StructuralColumns OST_StructuralFraming OST_StructuralFoundation Get AnalyticalModel and list Curves Support data - cf. AnalyticalSupportData_Info SDK sample RstLabs Retrieve Analytical Model RstLabs Structural Analysis Link Structural Analysis Link Introduction Export and import Practical examples Sample application RstLink Now we have assembled all the tools we might need, let us put them together into an actual Revit Structure Analysis link application. First we discuss some general questions regarding applications linking Revit with external programs, followed by some practical examples. Analysis Link Introduction There are MANY ways in which the link can be designed There are MANY implementation scenarios concerning Which structural elements are passed between the applications Which kind of model changes are automatically supported in either of them It is up to the particular 3rd party package and its implementer to design, code and document the link Revit Structure API provides the tools to do this RST does not pre-determine the design of the link application RstLink There are many different implementation scenarios in which it might be useful to link a Revit building model with some external data, both RST-specific for analysis as we are discussing here, and also generic for other situations. Obviously, there are also many ways in which such a link can be designed. For the RST analysis link, we need to decide which structural elements are passed between the applications and what kind of model changes are automatically supported in either of them. It is obviously up to the individual third party package and its implementer to design, code and document the link. The Revit Structure API provides the required tools to do this, and does not pre-determine the design of the link application in any way. Analysis Link Export Data export from Revit to 3rd party A&D application Use a custom Revit external command to export relevant data App's native file/DB format — typically proprietary App's neutral file/DB format — typically public Public neutral file/DB format supported by the app Intermediate file/DB format purpose-designed for the link ... The choice depends on the combination of technical, functional, commercial and political requirements... RstLink For data export from Revit to a third party A&D application, one will generally use a custom Revit external command to export relevant data. The format used for this communication is once again completely up to the implementer, and could be any one of the following. Analysis Link Import Define another custom Revit external command The choice of options and reasoning is basically the same as for the export The chosen file format need not be the same as for the export, though typically it would be RstLink For importing the updated and modified data from the external application back into Revit, one would generally define another custom Revit external command. The choice of options and reasoning is basically the same as for the export. The chosen file format does not need to be the same as for the export, though typically it would be. Practical Examples RstLink Simple demonstration application MidasLink Simple but real FireRating Minimal generic Revit RDBLink Generic Revit BIM, not RST specific RstLink Practical Example AutoCAD simulates A&D 3rd party app AutoCAD.NET API utilities used on the 'other' side Xdata used to store Revit Structure specific info on standard AutoCAD entities AutoCAD Dynamic Properties COM API used for the link-specific UI within AutoCAD Intermediate, purpose designed XML Used in both directions For simplicity, based on .NET SOAP serialization Custom .NET neutral classes utilized by both sides' export/import commands RstLink We have implemented a custom designed practical example of a Revit Structure analysis link application called RstLink to accompany this presentation. We use AutoCAD 2008 with an AutoCAD.NET plug-in to simulate the external third party analysis and design application and extended entity data, also known as xdata, to store Revit Structure specific information on standard AutoCAD entities. We use the AutoCAD Dynamic Properties COM API and the Object Property Manager OPM for the link-specific user interface within AutoCAD. AutoCAD.NET API utilities used on the 'other' side Xdata used to store Revit Structure specific info on standard AutoCAD entities AutoCAD Dynamic Properties COM API used for the link-specific UI within AutoCAD The data exchange in both directions between the Revit model and the A&D simulation in AutoCAD is implemented using an intermediate, custom designed XML format. For simplicity, the XML format is based on .NET SOAP serialization. Some neutral custom .NET classes are utilised by both sides' export and import commands. Used in both directions For simplicity, based on .NET SOAP serialization Custom .NET neutral classes utilized by both sides' export/import commands Before running the demo, the following applications need to be present: RstLink - helper dll shared by both acad and revit client RSLinkRevitClient - command implementations RSLinkRevitApp - external application RSLinkAcadClient - AutoCAD client RSLinkAcadClientDynProps - dynamic Revit properties for AutoCAD objects Here are possible steps to run the demo: Set up Revit.ini to load either the client or the external application or both. Open or create a sample model in Revit Structure. Run the export command. You are prompted for a file location. A dialogue box pops up, reporting the number of exported elements. Start up AutoCAD and load the client and the dynamic property application. This can be achieved automatically by setting up AutoCAD to start in the RVT sample directory and placing an acad.lsp file there containing: (defun s::startup() (command "_netload" "RSLinkAcadClient.dll") (princ "\nAutoCAD RSLink client loaded.") (arxload "RSLinkAcadClientDynProps.arx") (princ "\nAutoCAD RSLink dynamic properties loaded.") (princ) ) If it does not load automatically, you can load it manually by calling (load "C:/a/j/adn/revit/rst_api/RVT/acad.lsp") with the appropriate full path, and then call (s::startup). The commands defined by the AutoCAD client are RSImport, RSExport and RSMakeMember. Use RSImport to load the xml file just exported from Revit. Modify some cross sections in the model using the OPM, simulating modifications made by the A&D application, and optionally RSMakeMember to add some new elements. Use RSExport to write the model back out again. Back in Revit, use the import command to read the modifications and update the Revit model accordingly. Dialogue boxes are displayed to report the number of elements imported and modified. Note that the column types were swapped. Currently, the new elements defined by RsMakeMember are ignored. RstLink Modules RstLink Helper dll shared by both acad and revit client RSLinkRevitClient Revit command implementations RSLinkImport, RSLinkExport RSLinkRevitApp Revit external application RSLinkAcadClient AutoCAD.NET client RSImport, RSExport, RSMakeMember RSLinkAcadClientDynProps Dynamic Revit properties for AutoCAD objects RstLink RstLink Revit Export RstLink RstLink AutoCAD Import Invoke RSImport command RstLink Modify Cross Section Edit dynamic properties Change cross section RstLink Add new Members and Data Invoke RSMakeMember command RstLink Import Modified Data into RST RSExport from AutoCAD Import into Revit Column type was swapped New elements are ignored RstLink Another Practical Example MidasLink Subscription only module Old source code available on ADN, but no update Search for "MidasLink" http://adn.autodesk.com/adn/servlet/item?siteID=4814862&id=9628885&linkID=4901650 Includes Analysis package executable Documentation Source code Installer RstLink MidasLink is a Revit Structure add-in program that exports and imports the Revit model to and from the MIDAS/Gen structure analysis application. The source code is provided to help developers integrating analysis programs with Revit Structure. The compiled add-in is available to Revit Structure subscription customers. Analysis Software ADAPT www.adaptsoft.com/releases.php RISA www.risatech.com/partner/revit_structure.asp RAM www.bentley.com/structural CSC MIDAS - MidasLink subscription module Autodesk ROBOBAT http://www.extensions4revit.com/n/e4r Complete updated list in the developer guide Section 29.4 Analysis Link Analysis Partners site http://usa.autodesk.com/adsk/servlet/item?id=8447050&siteID=123112 RstLink Here is an overview of some other available analysis link packages. An up-to-date list is available on the analysis partners site. Robot Millennium is an analysis software by Robobat, which is recently acquired by Autodesk. Rebar Sample and API feature walkthrough in the rebar and detailing workflow context Revit Structure Rebar Workflow Revit Structure 3D Object Model Physical Model Analytical Model 3D Rebar Model User Input 3rd Party Analysis Design Concrete Drawings Specific Rebar Details Specific Rebar Details Shop Drawing Typical Rebar Details 3D Design QTO User Input User Input Manual Automated Rebar Working with reinforcements in Revit Structure involves two phases. The initial phase is the building analysis, which may result in design changes. In the second phase, reinforcements are added, analysed, and detailed. Both phases may include multiple iterations. Many of the tasks required can be automated. This is where our applications can save a lot of time, effort, and eliminate sources for errors. The central hub is the Revit Structure three-dimensional object model which integrates the physical and analytical models used respectively for the building design and analysis. The 3D rebar model is integrated in this database. The physical model is used to generate concrete drawings including rebar specific details. The rebar model can be used to generate rebar specific details and quantity takeoffs. The analytical model is used to connect to third party analysis and design packages, which in turn can help define the rebar model. The 3D Rebar Model Revit Structure has a 3D rebar model composed of Single bars Sets (array of bars with rules) Area reinforcement for slabs and walls Path reinforcement for slabs 3D rebar model can be generated Manually by user Loaded from a group that defines a cage Generated with the API from analysis and design software or from macros Advantages of 3D rebar model Quantities Complex layout Automatic reinforcement drawings Basic scheduling Scheduling is specific to each country Opportunity for third party developers to use the 3D rebar model to generate DWG schedules and import them back as a drafting view in Revit Structure Rebar Relationship Between Topics Rebar Generate rebar and define rebar shape Extract rebar information Truss Detailing Generate a section view Generate a drafting view Create a sheet Import and export external file formats (e.g., dwg) Add text, dimensioning and annotations Rebar Here are some relationships between these rebar topics and the rebar workflow: after the structural framing analysis part is done, an engineer will take the values of the load and stress information for each element and design the rebar for each element. You design the size of the column, number of rebars, and number of rib-bars. Based on this information, a rebar can be generated externally. It may need modification, which requires extraction and analysis of existing information. The extracted information may also be used for estimation purposes. To show the rebar placement in a column or beam, you need a section view. The Revit SDK samples CreateSimpleAreaRein and CreateComplexAreaRein generate reinforcement elements, and can be used to demonstrate the kinds of section view required. For structure detailing, we need a drafting view where we may want to import a dwg file. Adding text, annotations and dimensioning is further typical detailing functionality. Some of the items listed here are general, but especially useful as part of the rebar workflow for structural detailing. The underlined topics are new or updated in Revit 2009. Generate Beam or Column Rebar Sample: Reinforcement Create reinforcement bars in selected non-reinforced concrete beam or column Beam rebar: top, bottom or transverse Column rebar: transverse or vertical Class Autodesk.Revit.Elements.Rebar Methods Rebar // rebar creation in 2008: Rebar r = doc.Create.NewRebar( rebarType, startHook, endHook, m_hostObject, ref origin, ref normal, curves, (int)startOrient, (int)endOrient ); // two overloaded functions in 2009 // useExistingShapeIfPossible, createNewShape // demonstrated in NewRebar sample Rebar r = doc.Create.NewRebar( RebarStyle.Standard, rebarType, startHook, endHook, m_hostObject, normal, curves, (int)startOrient, (int)endOrient, false, true ); r = doc.Create.NewRebar( barShape, barType, m_rebarHost, origin, xVec, yVec ); We can use the Revit SDK sample Reinforcement to demonstrate the creation of new reinforcement elements. It creates a bar set in a selected concrete beam or column element that does not have any reinforcement. Three kinds of beam rebar are created: top, bottom and transverse rebar. Two kinds of column rebar are created: transverse and vertical. It uses the Autodesk.Revit.Creation.Document.NewRebar() method to create rebar for the selected host. The NewRebar() method expects two parameters RebarBarType and RebarHookType. Suitable values for these two parameters can be retrieved by iterating the active document elements. [MH] This sample shows how to create Rebar in concrete element (Beam or Column) which does not have any reinforcement. The method used to create Rebar, Create.NewRebar, has been changed in 2009. The first argument RebarStyle.Standard is an enumeration value - you can choose either standard/stirrupTie (stirrup or tie bar). The style affects the bend radius and the set of allowable hooks. It also affects the rebar instance auto-constraining behavior. ... Reinforcement Implementation FrameReinMakerFactory class manages all the work Precondition checks Is the selected object a beam or column? Is it made of concrete? Does it already contain any rebar elements? Create a corresponding FrameReinMaker and the reinforcement rebars Host-dependant working classes BeamFramReinMaker and ColumnFramReinMaker GeomUtil Basic geometric utility methods GeometrySupport Base class for BeamGeometrySupport and ColumnGeometrySupport, manages the solid of beam or column, the extend or sweep path of the beam or column, the beam or column direction vector, lists to store the edges and points, the transformation etc. ParameterUtil Utility methods find or set certain parameter Rebar Generate Rebar Demo Ensure only one beam or column is selected Retrieve all rebar types and all hook types Retrieve and analyse member geometry Run worker method Rebar This is demonstrated by the sample Reinforcement. The sample can create rebar for both beam and column. Register the command: [ExternalCommands] ECCount = 16 ECName16=Rebar - Reinforcement ECClassName16 = Revit.SDK.Samples.Reinforcement.CS.Command ECAssembly16 = C:\a\lib\revit\2008\sdk\Samples\Reinforcement\CS\bin\Debug\Reinforcement.dll ECDescription16 = Create bar set in a selected concrete element (beam or column) that does not have any reinforcement. Draw a Concrete Beam or Column elements without any reinforcement and select it. Please make sure the beam or column section size is big enough, e.g. for column it can be 24x32. Run the command. Set the parameters for the rebar in the pop up dialog. Click Ok, Rebar for the selected element (Beam or Column) will be created. If you want to debug, this can be done from SDKSamples10.0.sln. Rebar API Enhancement in 2009 Rebar is an instance of RebarShape Added Revit.Symbols.RebarShape - topological layout of rebar Revit.Symbols.RebarShapeDefinition(ByArc/BySegments) - helper class to define RebarShape Revit.Symbols.RebarCoverType - rebar cover setting, name and value pair Revit.Elements.RebarHostData - helper class to access to a host cover setting Changed Revit.Symbols.RebarType - cleaned up, no new functionality Samples: NewRebar Rebar RebarHostData and RebarCoverType: Clear cover is now associated with individual faces of valid rebar hosts. Access to the cover settings of a host is through the Autodesk.Revit.Elements.RebarHostData object. A simpler, less powerful mechanism for accessing the same settings is provided through parameters. Cover is defined by a named offset distance, modeled as an element Autodesk.Revit.Symbols.RebarCoverType. NewRebar Sample Rebar Create a Rebar Define a custom Rebar shape NewRebar Sample (cont.) Rebar Instructions under NewRebar/CS/Customize RebarShapes Step by step Arc with radius(*) (*) known issues - places rebar out side of a host objects both in UI and API Collection of straight segments Arc with chord length (*) Lapped circle (*) NewRebar Sample (cont.) Rebar RebarShapeDefinitionBySegments Create a RebarShape RebarShape myShape = rvtDoc.Create.NewRebarShape() Create a RebarShapeDef RebarShapeDefinitionBySegment myDef = myShape.NewDefinitionBySegments(segmentCount) Add shared parameters by external def myDef.AddParamater( externalDef, value ) Add constraints to shape definition myDef.AddConstraintToSegment myDef.AddConstraintParallelToSegment myDef.AddBendDefaultRadius myDef.SetSegmentFixedDirection myDef.AddListingDimentionBendToBend Set Hook to RebarShape myShape.set_HookAngle myShape.set_HookOrientation ExternalDefinition The parameter. To obtain this object, the following calls are required: Application.OpenSharedParameterFile(); Parameters.DefinitionFile.Groups.get_Item() or .create(); and Parameters.DefinitionGroup.Definitions.get_Item() or .create(). Generate Floor or Wall Rebar Sample: NewPathReinforcement Create path reinforcement Class Autodesk.Revit.Elements.Rebar Method Rebar XYZ p1, p2; Line curve; CurveArray curves = m_appCreator.NewCurveArray(); for( int i = 0; i < points.Count - 1; ++i ) { p1 = new XYZ( points[i].X, points[i].Y, points[i].Z ); p2 = new XYZ( points[i + 1].X, points[i + 1].Y, points[i + 1].Z ); curve = rvtDoc.CreateNewLine( ref p1, ref p2, true ); curves.Append( curve ); } // type is no longer needed, default is used in 2009: return rvtDoc.Create.NewPathReinforcement( m_host, curves, flip ); We can use the Revit SDK sample NewPathReinforcement to demonstrate how to create a new PathReinforcement element through the API. The PathReinforcement host is a floor or a wall. The method used is NewPathReinforcement( PathReinforcementType, Element, CurveArray, bool ); We can use Document.Create.NewPathReinforcementType() method to create a PathReinforcementType if there is none in current document. The Element argument is the host of the PathReinforcement. The CurveArray stores its path. The Boolean value indicates which side of the path the PathReinforcement is located on. To run the sample, draw a Structure wall or slab, select it, and run this command. Draw the path of PathReinforcement you want to create. You can click right mouse button to finish drawing. Click the "Preview" button to preview the path reinforcement to be created. Select or unselect the "Flip" check box to create the PathReinforcement on the left or right side of the path. Click the "Create" button to create the PathReinforcement. You can clean and redraw the sketch of the path using the "Clean" button. Here is the central code snippet given an array of points defining the path. Extract Rebar Information AreaReinParameters Sample Provides starting point Extended to list rebar information Uses built-in parameters BarDescriptions Sample AreaReinforcement has a BarDescription property Same functionality as above Generic Tools BuiltInParameterChecker RvtMgdDbg Rebar All the generic data extraction and debugging utilities such as RvtMgdDbg and BuiltInParameterChecker can be used to read parameters and other information from a rebar element. In addition, the Revit SDK sample AreaReinParameters shows how to use the API to display and modify AreaReinforcement parameters. We have expanded the sample to list rebar elements and their parameters as well in a separate command RebarParas. The enhanced sample is included in the presentation material. Another sample for extracting rebar information is the BarDescriptions sample. It shows how to find all BarDescriptions in the project, display their properties in a DataGridView, and export their parameter information to an external comma delimited *.csv file. BarDescription is a property of an AreaReinforcement element, so some AreaReinforcement elements should be drawn first. Some rebar information is accessible through built-in parameters and can be determined using BuiltInParameterChecker, some is accessible only through hard-coded localised parameter names. The AreaReinParameters sample only works with floor or wall area reinforcements, not with rebar. Not all rebar parameters are accessible as built-in parameters. We can however retrieve almost all necessary information with its instance parameters, hence the RebarParas enhancement. Rebar Information Demo Rebar Register the command: [ExternalCommands] ECName32 = RebarParas ECClassName32 = Revit.SDK.Samples.AreaReinParameters.CS.RebarParas ECAssembly32 = C:\Revit\SDK\Samples\AreaReinParameters\CS\bin\Debug\AreaReinParameters.dll ECDescription32 = Show parameters of a rebar Select a rebar. Run this command. Truss Truss RST, C# Create a truss of a selected truss type Change beam types Edit the profile of the truss Truss Detailing Detailing Detailing Generate a section view Generate a drafting view Create a sheet Import and export external file formats, e.g. dwg Add text, dimensioning and annotations Enhanced Revit SDK samples Detailing Generate Section View Demonstrate creation of a Detail View Using NewViewSection() Creates detail view across the midpoint of selected element Works on linear elements such as slab, wall and beam Create and initialise a bounding box Detailing // create a BoundingBoxXYZ and set the Max and Min properties: BoundingBoxXYZ m_box = new BoundingBoxXYZ(); m_box.Enabled = true; m_box.Max = new XYZ(LENGTH, LENGTH, 0); m_box.Min = new XYZ(-LENGTH, -LENGTH, -HEIGHT); // setting the Transform property is the most important thing. // it defines the origin and the directions RightDirection, // UpDirection and ViewDirection) of the created view: Transform transform = GenerateTransform(); if (null == transform) { return false; } m_box.Transform = transform; // Create a section view, pass the bounding box. ViewSection section = m_project.Create.NewViewSection(m_box); The Revit SDK sample CreateViewSection demonstrates the creation of a detail view. Given a linear element such as a wall, floor or beam, it generates a section view across the midpoint of the element using the NewViewSection() method. It performs the following steps: Retrieve the selected linear element Generate a BoundingBoxXYZ instance to be used in NewViewSection() Set its Max and Min properties Generate a Transform instance for the BoundingBoxXYZ Transform property, which defines the origin and directions of the created view, including RightDirection, UpDirection and ViewDirection Create the section view using the BoundingBoxXYZ. The NewViewSection method takes a parameter of type BoundingBoxXYZ. The key part of the code is actually to create the box. And the key part for the box is to create its transform matrix. The actual matrix generated depends on the selected element type. Separate implementations are provided for beam, floor and wall. These are called from within GenerateTransform(). Generate Section View Demo Detailing Use the Revit SDK sample CreateViewSection to demonstrate this. Register the command: ECName19=Rebar - CreateViewSection ECClassName19=Revit.SDK.Samples.CreateViewSection.CS.Command ECAssembly19=C:\a\lib\revit\2008\sdk\Samples\CreateViewSection\CS\bin\Debug\CreateViewSection.dll ECDescription19=Create a section view across the mid point of the selected wall, floor or beam Launch Revit Structure 2008. Open the project Rebar.rvt. Select a beam or column with rebar. Execute the external command. Note that a new section view is added to the detail views in the project explorer. Generate Drafting View Code Document doc = commandData.Application.ActiveDocument; // Create a drafting view ViewDrafting drafting = doc.Create.NewViewDrafting(); Detailing The NewViewDrafting() method does not take any parameters. It creates an empty drawing view. We have added a second external command CreateDraftingView to the Revit SDK sample CreateViewSection to demonstrate this. Import DWG Import Detailing DWGImportOptions opts = new DWGImportOptions(); opts.Placement = ImportPlacement.Centered; // Origin, Center, Shared // other possible options. opts.ColorMode = ImportColorMode.Preserved; // BlackAndWhite, Inverted, Preserved //opts.CustomScale = 1; opts.OrientToView = true; // true or false opts.ThisViewOnly = false; // imports dwg, dgn, and dxf into active view only? opts.Unit = ImportUnit.Default; opts.View = m_revitApp.ActiveDocument.ActiveView; opts.VisibleLayersOnly = false; // true or false Revit.Element newElement = new Revit.Element(); rvtDoc.Import( dbox.FileName, opts, ref newElement ); Importing and exporting DWG files is demonstrated by the Revit SDK sample ImportExportDWG. It shows how to export the current project to dwg files and import a dwg file into Revit. It also demonstrates how to and provides a user interface to set up the import and export options appropriately. To run it, start up Revit, open a suitable project, and execute the command. To export, check the radio button "Export". In the next dialog, specify the file name to export as, set the common options and click the "Option..." button to set the lower priority options; click the "Select..." button to select multi-views to export. Then click the "Save" button to perform the export. To import, check the radio button "Import". In the next dialog, specify the file to import from and set the other options. Then click the "Open" button to perform the import. The last parameter of the Import() method is an element. It is not neccessary to create a new element prior calling the Import() method. You can simply pass a variable of type Element and it can be null. This provides a possibility to return the element that was just imported, so that it can be accessed and modified after the import. For example, if you import an image, the import method gives you no scaling nor rotating options. If you would need this functionality, you can achieve it by manipulating the image after the import. Export DWG Export Detailing opts dwgExportOptions = new DWGExportOptions(); opts.ExportingAreas = false; // export room and areas opts.FileVersion = ACADVersion.R2007; // acad file version opts.LayerMapping = "AIA"; // layer standard: AIA/CP83/BS1192/ISO13567 opts.LineScaling = LineScaling.ModelSpace; // or PaperSpace/ViewScale opts.MergedViews = true; opts.PropOverrides = PropOverrideMode.NewLayer; // or ByLayer/ByEntity opts.SharedCoords = true; opts.TargetUnit = ExportUnit.Millimeter; opts.ExportOfSolids = SolidGeometry.ACIS; exported = rvtDoc.Export( folder, name, views, opts ); Import and Export Demo Detailing ImportExport All, C# ImportExportDWG was enhanced to handle additional file formats Export - dwg, 2D and 3D dwf and dwfx, gbxml and FBX Import - dwg and image file New API classes added Detailing Create New dimensioning Create a dimension between two references CreateDimensions sample Detailing XYZ p1 = newLine.get_EndPoint(0); p1.X += 5; p1.Y += 5; XYZ p2 = newLine.get_EndPoint(1); p2.X += 5; p2.Y += 5; Line newLine2 = app.Create.NewLine( ref p1, ref p2, true ); // set the references . . . // create a dimention Dimension newDimension = rvtDoc.Create.NewDimension( rvtDoc.ActiveView, newLine2, referenceArray ); New dimenioning can be generated through the API using the NewDimension() method. Searching globally through all the samples discovers one single instance of this method, in the CreateDimensions sample. This sample adds a command taking a selection of basic structural walls and adds dimensioning from the start to the end of each. Dimensioning is created between graphical references stored in a ReferenceArray instance. The key part is the creation of the reference array. Once the reference array has been set up, the creation of the dimensioning is simple. Dimensioning Reference Array Create a reference array for a structural wall Detailing ReferenceArray referenceArray = new ReferenceArray(); Options options = rvtApp.Create.NewGeometryOptions(); options.ComputeReferences = true; options.View = rvtDoc.ActiveView; Revit.Geometry.Element geomElem = wallTemp.get_Geometry(options); GeometryObjectArray geoObjectArray = geomElem.Objects; for (int j = 0; j < geoObjectArray.Size; j++) { GeometryObject geoObject = geoObjectArray.get_Item(j); Curve curve = geoObject as Curve; if (null != curve) { //find the two upright lines beside the line if (Validata(newLine, curve as Line)) { referenceArray.Append(curve.Reference); } if (2 == referenceArray.Size) { break; } } } For the basic wall, the location line of the wall is used to discover the two vertical edges at each end of one side of the wall. Some calculation and comparison work needs to be done in order to find the two right reference lines. For each of these two curves, a reference is added to the reference array. Note that the geometry options for obtaining the wall geometry have options.ComputeReferences set to true. Dimension Creation Tips Extend the sample to work with other elements than structural wall Architectural wall cannot get reference from edge Use face instead - not all geometry has reference Detailing Solid solid = geoObject as Solid; if(null != solid) { FaceArrayIterator faceItor = solid.Faces.ForwardIterator(); while (faceItor.MoveNext()) { PlanarFace face = faceItor.Current as PlanarFace; if (null != face) { // find the two upright lines beside the line. // NOTE: overloading this function. We pick up the face in term of its Normal. if (Validata(newLine, face.Normal)) { referenceArray.Append(face.Reference); } if (2 == referenceArray.Size) { break; // . . . Rebar dimensioning Extending the sample to work with rebar Need to dig into geometry elements ... SPR #125909 API wish: create dimension between a column edge and a rebar center Detailing // get rebar reference if (m_rebar != null) { Revit.Geometry.Element gelement = m_rebar.get_Geometry(options); GeometryObjectArray geoObjectArray = gelement.Objects; // enum the geometry element for (int j = 0; j < geoObjectArray.Size; j++) { GeometryObject geoObject = geoObjectArray.get_Item(j); Line line = geoObject as Line; if (line != null && line.Reference != null) { referenceArray.Append(line.Reference); } } } Add Tags Simple Tag sample in RvtMgdDbg's Test Framework Detailing if( elem is Rebar ) { // Cast to Rebar and get its first curve Revit.Elements.Rebar rebar = elem as Rebar; Revit.Geometry.Curve curve = rebar.Curves.get_Item(0); // Create a rebar tag at the first end point of the first curve IndependentTag tag = revitDoc.Create.NewTag( view, // view to place the tag rebar, // host object to tag true, // have a leader? TagMode.TM_ADDBY_CATEGORY, // mode by category, multi-category or material TagOrientation.TAG_HORIZONTAL, // orientation: vertical/horizontal curve.get_EndPoint(0) ); // location point } The NewTag method signature and its parameters: public IndependentTag NewTag( View dbview, Element objelem, bool leader, TagMode tagmode, TagOrientation tagorientation, XYZ pnt ); Parameters dbview The view in which the dimension is to be visible. objelem The host object of tag leader whether have leader tagmode the mode of tag. Add by Category, add by Multi-Category and add by material tagorn The Orientation of the Tag pnt The position of the Tag I used category tag mode and horizontal tag orientation here. Add Text Detailing if( elem is Rebar ) { // cast to Rebar and get its first curve Revit.Elements.Rebar rebar = elem as Rebar; Revit.Geometry.Curve curve = rebar.Curves.get_Item(0); // calculate arguments Revit.Geometry.XYZ origin = curve.get_EndPoint(0); origin.X += curve.Length * 10; // draw the text at the right size Revit.Geometry.XYZ baseVec = new Revit.Geometry.XYZ(1,0,0); Revit.Geometry.XYZ upVec = new Revit.Geometry.XYZ(0,0,1); double textSize = curve.Length / 10; double lineWidth = curve.Length / 50; string strText = "This is " + rebar.Category.Name + " : " + rebar.Name; // create the text Revit.Elements.TextNote text = revitDoc.Create.NewTextNote( view, origin, baseVec, upVec, textSize, lineWidth, Revit.Enums.TextAlignFlags.TEF_ALIGN_CENTER | Revit.Enums.TextAlignFlags.TEF_ALIGN_MIDDLE, strText ); text.Width = curve.Length * 10; // set the width of the text } public TextNote NewTextNote( View pView, XYZ origin, XYZ baseVec, XYZ upVec, double textSize, double lineWidth, TextAlignFlags textAlign, string strText ); Parameters pView Current DBView origin origin of the TextNote baseVec baseVec parameter of the TextNote. upVec upVec parameter of the TextNote. textSize text size. lineWidth line width of the out rectangle. textAlign align style. strText text. TextNote is just text. The textSize parameter of the NewTextNote method is actually not used and can be ignored Tao says 'Our developer has confirmed that this param is no use at all for the internal behavior has been changed. The actual size value comes from Font (family type). So this param should be removed. Our developer will fix it.' Learning More Online Help and SDK Samples Revit Developer Center http://www.autodesk.com/developrevit DevTV Introduction to Revit Programming Revit Programming Introduction Webcasts and Classes http://www.adskconsulting.com/adn/cs/api_course_sched.php Discussion Groups http://discussion.autodesk.com > Revit API API Training Classes http://www.autodesk.com/apitraining Autodesk Developer Network http://www.autodesk.com/joinadn DevHelp Online for ADN members http://adn.autodesk.com Thank you very much! Thank you for your interest and attention! End of Presentation