Since I talked about the Revit MEP API yesterday, I should be fair and mention the Revit Structure API as well, shouldn't I?
Last year, we provided an overview over a number of Revit Structure resources, including pointers to the structure related webcasts, samples, trainings and Autodesk University classes available in the Revit 2010 timeframe.
Here is a quick tour by Joe Ye of what has changed in the Revit Structure 2011 API as well as new enhancements.
Changes in the Revit Structure API
The main change in this version is the reorganization of Revit Structure API classes. This change has two main aspects: renaming of namespaces and the consolidation of the different analytical model related classes to one single class. You can find the detailed description of the Revit Structure API changes in the topic 'Replacement for AnalyticalModel' in the 'Revit Platform API Changes and Additions.doc' documentation.
Structure related API classes were previously located in the Autodesk.Revit.Elements namespace. They have now been moved to the new Autodesk.Revit.DB.Structure namespace, which makes the relationship of classes and namespace clear.
The following analytical model classes have been consolidated into one single class AnalyticalModel:
- AnalyticalModel3D
- AnalyticalModelFloor
- AnalyticalModelFrame
- AnalyticalModelLocation
- AnalyticalModelWall
The new class offers a more streamlined interface and more capabilities to read data and modify analytical model settings.
A couple of new methods are added to the AnalyticalModel class:
- Get support priority by AnalyticalModel.GetPriority().
- Get adjustment information both manual and automatic by GetManualAdjustmentMatchedElements() method.
- Get and set the structure analytical offset.
- Get parameter information, including projection information, hard points, approximation, and rigid links.
Other changes that have been made include renaming of classes, properties, methods and enumerations. This was done to make them easier to understand and avoid the confusion of having two classes with the same name in different namespaces.
The method to retrieve the analytical model, previously accessible through the Element.AnalyticalModel property, is replaced by Element.GetAnalyticalModel(). The AnalyticalModelProfile class was renamed to AnalyticalModelSweptProfile.
The following enumerated types were available in previous releases of the API:
- Autodesk.Revit.Structural.Enums.InstanceUsage
- Autodesk.Revit.Structural.Enums.Material
- Autodesk.Revit.Structural.Enums.WallUsage
They have now been replaced with new enumerations:
- Autodesk.Revit.DB.Structure.StructuralInstanceUsage
- Autodesk.Revit.DB.Structure.StructuralMaterialType
- Autodesk.Revit.DB.Structure.StructuralWallUsage
Enhancements in the Revit Structure API
There are also some new APIs and classes added to provide more functionality.
AnalyticalConsistencyChecking, AnalyticalSupportChecking and StructuralSettings classes were added. We can start analytical consistency checking by calling the AnalyticalConsistencyChecking CheckAnalyticalConsistency method for the specified document, and begin analytical support checking by calling the AnalyticalSupportChecking CheckMemberSupports method.
The StructuralSettings class provides 29 methods to read and write almost all structural settings displayed in the structural settings dialogue.
The rebar related API is greatly enhanced. The following three new methods were introduced to create new types, which replace the previous way to create new types by calling the Duplicate method:
- NewRebarBarType()
- NewRebarHookType()
- NewRebarCoverType()
To make it easy to access the properties of RebarBarType, this class exposes nine properties and methods to access corresponding parameters. Rebar has an enhanced interface, which has extra eleven methods and properties to access its array functionality. These properties were previously only available through parameters. Six properties and methods have been introduced to work with spiral rebar:
- Rebar.Height
- Rebar.Pitch
- Rebar.BaseFinishingTurns
- Rebar.TopFinishingTurns
- Rebar.ScaleToBoxForSpiral()
- RebarShapeDefinitionByArc.SetArcTypeSpiral()
The following filter classes were introduced to help quickly retrieve specific structural elements using the new element filtering:
- FamilyStructuralMaterialTypeFilter
- StructuralInstanceUsageFilter
- StructuralWallUsageFilter
- StructuralMaterialTypeFilter
The Truss class has more functionality: the AttachTopChord and DetachTopChord methods have been replaced by AttachChord and DetachChord methods. The new methods operate on both top and bottom chords. The new method Truss.DropTruss() was introduced to disassociate all members from the truss and delete the truss.
Some small enhancements and new features are not mentioned here. Once again, 'Revit Platform API Changes and Additions.doc' summarizes those changes. Complete information is available from chapter 23 of the Revit 2011 API developer guide.pdf, which is dedicated to the Revit Structure API.
Thank you very much, Joe, for this overview!
Hello Sir,Is there a methord to import a outside .rvt file into the current document as a Revit links.
Posted by: peng | May 13, 2010 at 02:30
Dear Peng,
Nope, sorry to say, we have a wish list item for this request which is still open.
Cheers, Jeremy.
Posted by: Jeremy Tammik | May 13, 2010 at 02:49
Hello Jeremy,
I just installed Revit Structures, Architecture 2011 and the SDK, but I can not find RevitAPI.dll and RevitAPIUI.dll in their installation folder or anywhere else on my Computer!
Where are they?
Posted by: Cosmas | May 14, 2010 at 22:44
I will answer my own question!
Apparently the installation utility creates two program folders for Autodesk_Revit_Structure. One directly on C:/Autodesk/ and the other on C:/Programs Files/Autodesk. The dlls are under the C:/Programs Files/Autodesk (as they should be), and not in C:/Autodesk where I was looking!
Posted by: Cosmas | May 14, 2010 at 23:01
Hi,
Im guessing if its possible to use the Revit API to create an external program that launch Revit, opens a rvt file , modify some parameters and then renders it.
Is it possible or it can only be used to create add-ins?
Thank you very much,
Alvaro
Posted by: Alvaro | May 16, 2010 at 10:58
Dear Cosmas,
Right you are, the directory structure under C:/Autodesk contains temporary installation files. Glad you found the right place!
Cheers, Jeremy.
Posted by: Jeremy Tammik | May 16, 2010 at 17:53
Dear Alvaro,
I am sorry to say that your guess is wrong, and the API can currently only be used to create add-ins.
You may be able to achieve what you want anyway, by launching Revit by some other means and then making use of an add-in that is launched on start-up or when the initial document is opened. Please refer to numerous posts on this subject, e.g.
http://thebuildingcoder.typepad.com/blog/2010/04/asynchronous-api-calls-and-idling.html
Journal files may also help.
Cheers, Jeremy.
Posted by: Jeremy Tammik | May 16, 2010 at 18:03
Hi Jeremy,
I am a Revit API newbee and would like to learn from you. Followed some of your example and Audesk's sample codes, I am able to create a tab, panel and commands to load a family symbol. However, I do not know how to 1) set the loaded family symbol as the current default symbol; 2) how to place a loaded family symbol, e.g., the column, into the project at around the mouse point; 3) how to get the XYZ of the current mouse point position?
Thank you in advance for the help.
Posted by: Karl | May 17, 2010 at 00:36
Hello Jeremy,
Can you give a VB example of how to search through a Revit document for different structural elements (Structural Beams, Columns, Floors, Walls and Footings)? I have used before the 2009 RstLabs, but now it has to be modified for the new 2011 API. Can we now use regular VB.net collections (that can be iterated using For Each)?
Thank you for your help.
Posted by: Cosmas | May 18, 2010 at 00:10
Dear Cosmas,
I am working on an update of the RST labs which I plan to publish soon.
I have sent you a snapshot of my current 2011 version of it by private mail.
Cheers, Jeremy.
Posted by: Jeremy Tammik | May 19, 2010 at 05:35
Dear Karl,
I believe you cannot programmatically define which symbol should be the current default, so you will have to forget number 1, I'm afraid.
Regarding number 2, you might want to have a look at the method UIDocument.PromptForFamilyInstancePlacement to prompt the user to interactively place one or more instances of a particular FamilySymbol.
Regarding number 3, you can use Selection.PickPoint to prompt the user to pick a point on the view active work plane. You cannot query the current cursor position without picking, though, except using the Windows API, but that will not give you access to any Revit coordinates. There is actually no way to determine a 3D position from a 2D mouse cursor without additional picking or some other assumptions about how the mouse cursor should be projected into the model.
Cheers, Jeremy.
Posted by: Jeremy Tammik | May 19, 2010 at 05:45
hello jeremy can you give me an example how to get the analytical model for a wall in Resit Str 2011 API
Posted by: Tony | June 10, 2010 at 03:27
Dear Tony,
Sure, you can simply search globally through the Revit SDK samples for the GetAnalyticalModel method.
I see examples of this call in 27 places in 13 different sample applications.
Cheers, Jeremy.
Posted by: Jeremy Tammik | June 10, 2010 at 14:44
hi,jeremy
is there a way to get the settings of the "column top's connection types or the "column base's connection types"in the structural settings dialogue which the user define.
for example the user set 3 structural connection types for COLUMN TOP ,and set 5 structural connection types for COLUMN BASE,how can i get the 3 types or the 5 types , for now i can only use the filter to filter all the structural connections types ,but can not classify them.
Posted by: jude2012 | March 10, 2012 at 06:36
Dear Jude,
Are you aware of the StructuralSettings class? I was under the impression that it provides access to all the properties affected by the Structural Settings dialogue.
Cheers, Jeremy.
Posted by: Jeremy Tammik | June 03, 2012 at 15:06