Changing Element Properties in Revit Structure

When you define Beams in Revit Structure the software automatically draws a driving line on top of the Beam. That line will meet a same line from a Column and their meeting point will actually become a node. So the “z-Direction Justification” is a property of Beams that describes the vertical position of the beam related with the imaginary line that connects the start and end point of the Beam. This parameter can get 3 different values TOP / CENTER / BOTTOM and we imagine the difference.

So using the SAP_2_ RS tool, we needed to set the z-Direction Justification to CENTER in order to be precise and the code is the following.(the default value is on TOP)

‘drawing beam

myBeam = myModel.Create.NewFamilyInstance(myBeamLine, beam_sym, my_level, Autodesk.Revit.DB.Structure.StructuralType.Beam)

‘giving the right z Direction Justification

Dim V_justification As Autodesk.Revit.DB.BuiltInParameter = Autodesk.Revit.DB.BuiltInParameter.BEAM_V_JUSTIFICATION

Dim myParameter As Autodesk.Revit.DB.Parameter = myBeam.Parameter(V_justification)

myParameter.[Set](1)      ’ here: 0 is Top  /  1 is Center  /  2 is Bottom

These lines need to be used after “drawing” the beam and this is the way to approach and change other parameters of elements if needed.. (got a lot of intelligense there)

enjoy

 

Open Dialog Box

The tool Sap_2_Rs asks the User (to the Revit Structure environment) to open the Sap2000 file that he wishes to import the geometry.

This happens by calling the OpenFileDialog box:

‘ Configure open file dialog box

Dim dlg As New Microsoft.Win32.OpenFileDialog()

dlg.FileName = “Select Sap model to import”   ‘ Default file name

dlg.DefaultExt = “.sdb”    ‘ Default file extension

dlg.Filter = “SAP MODEL Files (.sdb)|*.sdb”   ‘ Filter files by extension

‘ Show open file dialog box

Dim result? As Boolean = dlg.ShowDialog()

Dim filename As String = dlg.FileName

If result =  True  Then

‘start the Sap2000 application

SapObject.ApplicationStart()

ret = SapModel.InitializeNewModel             ‘initialize model

ret = SapModel.File.OpenFile(filename)     ‘open specific file

End If

———————————————————————————————

Don’t forget to add the “PresentationFramework” reference (type.NET)

Revit API and SDK files

The Revit SDK file has really useful files in order to get started, scripting with Revit API… This is a video found from autodesk that quickly presents the SDK file  http://download.autodesk.com/us/firstplugin/revit/exploring_the_revit_sdk_1044x828.html

You can download the Revit SDK file from Autodesk website

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

as long as you have an activated Autodesk account…

So between these files the Revit API is included and also a pdf called “Revit 20xx API Developer Guide”  which has many useful details for a new programmer in Revit

creating elements in REVIT VSTA (beams, columns, braces and so forth…) – variables needed

here is a list of variables needed in order to create members in Revit VSTA. I this this might be useful to whoever is new to VSTA…I’d see it as a kind of guide, just to make sure you are not skipping any fundamental variable…

you’ll find how to put togheter all these variables and how to draw a member in VSTA in these following 2 posts:

creating elements in REVIT VSTA (beams, columns, braces and so forth…) – loading path

creating elements in REVIT VSTA (beams, columns, braces and so forth…) – define start and end point and draw member

 

           ‘VARIABLES
                Dim beam_sym As Autodesk.Revit.DB.FamilySymbol = Nothing
                Dim instance As Autodesk.Revit.DB.FamilyInstance = Nothing
                Dim myBeam As Autodesk.Revit.DB.Line = Nothing
                Dim start_point As Autodesk.Revit.DB.XYZ = Nothing
                Dim end_point As Autodesk.Revit.DB.XYZ = Nothing
                Dim my_level As Autodesk.Revit.DB.Level

creating elements in REVIT VSTA (beams, columns, braces and so forth…) – loading path

critical in the process of creating beams or columns or whatever element in Revit VSTA is the load path that stores all the family…it was tricky for me to find it so I’m uploading here the general path that is more or less the same for everyone!

In this example I’m loading metric but you can use Imperial as well…just MAKE SURE that the name of the element you are considering (beam in this case) is the exact same name of the one in the family (“300 x 600mm” in this example)…you can double check this easly by opening Revit and read the names in the family tab!

HAVE FUN CREATING MEMBERS!

 

 ’Loading the family symbol for beams from family located on the C drive
                Dim loaded As Boolean
                loaded = myModel.LoadFamilySymbol(“C:\ProgramData\Autodesk\RST 2011\Metric Library\Structural\Framing\Concrete\M_Concrete-Rectangular Beam.rfa”, “300 x 600mm”, beam_sym)

Revit VSTA – reading values from excel

here is how you access EXCEL from REVIT VSTA and get values (i.e. coordinates of points of whatever you need it) from an excel sheet.

you’ll have to play with the cell numbers in the code because they are specific for my spreadsheet but you get the point!

Enjoy!

 

 ’open Excel and get geometry
        Dim my_excel As Microsoft.Office.Interop.Excel.Application
        my_excel = CType(GetObject(, “Excel.Application”), Application)
        Dim my_sheet As New Microsoft.Office.Interop.Excel.Worksheet
        my_sheet = my_excel.ActiveWorkbook.ActiveSheet
        my_sheet.Activate()
        Dim i As Integer
        Dim j As Integer
        For i = 2 To 4
            j = i + 1
            ‘********** POINT FROM EXCEL ***********
            Dim my_x As Double
            Dim my_y As Double
            Dim my_z As Double
            Dim rangerX As Microsoft.Office.Interop.Excel.Range = Nothing
            Try
                rangerX = my_sheet.Cells(i, 2)
                my_x = rangerX.Value2.ToString
            Catch ex As Exception
            End Try
            Dim rangerY As Microsoft.Office.Interop.Excel.Range = Nothing
            Try
                rangerY = my_sheet.Cells(i, 3)
                my_y = rangerY.Value2.ToString
            Catch ex As Exception
            End Try
            Dim rangerZ As Microsoft.Office.Interop.Excel.Range = Nothing
            Try
                rangerZ = my_sheet.Cells(i, 4)
                my_z = rangerZ.Value2.ToString
            Catch ex As Exception
            End Try

Flag Waving

South Pacific Island represent.

Firstly a .NET developer providing custom applications and commands for architecture firms exclusively working with Autodesk Revit. Loads of great code examples that are well explained and documented.

http://redbolts.com/blog/category/RevitAPI.aspx

Secondly, not too strong on the code examples but doing some very interesting with Revit API add-ons for Families, specifically Catalog families which were reference in an earlier post. Excellent video describing the Add-in, which inherently speaks about the advantage of going to extra step with a GUI.

http://revitfb.blogspot.com/

Nice one NZ. And when they arnt busy coding they have this to look forward too…

Revit API

Rod Howarth has compiled an excellent introduction to the Revit API in the form of a paper entitled “How the Autodesk® Revit API has saved our company time and money, and how it can do the same for yours…”. Cant be bad right?

http://www.rodhowarth.com/storage/revit/Revit%20API%20Resource%20Guide%20by%20Rod%20Howarth.pdf

Another great API code resource with plenty of code examples is the Autodesk Users Group International.

http://forums.augi.com/forumdisplay.php?f=218

N

VSTA for Revit

VSTA stands for Visual Studio Tools for Applications. It is a Microsoft technology that provides the .NET framework for creating macros in C# and VB.NET based on specific applications.VSTA is the next evolution of Visual Basic for Applications (VBA) that appears in several existing Autodesk applications. For an overview of how VSTA Macro’s work inside of Revit see Jeff Rayhorn’s post here:

http://lwcoffee.blogspot.com/search/label/VSTA%20macros

Rod Howarth has approached VSTA is a very similar vein, but has included C# code examples here:

http://blog.rodhowarth.com/2011/02/revit-apiintroduction-to-vsta-as-rapid.html

N

Excel/ OpenOffice to Revit Schedule

The following discussion thread muses over the potential of a better link between Excel and Revit. The general theme emerges that although the link is desired, the more practical solution is to bring the capabilities of Revit Schedules closer to that of Excel, or at least migrate some features across platforms (eg. Formatting tools, Fill Down cmd). For more see as well as a C# example of this proposed link:

http://insidethefactory.typepad.com/my_weblog/2009/08/is-excel-part-of-your-bim-toolbox.html

C# code example and .exe file developed using AutoHotKey to transfer contents on Excel or OpenOffice workbook into a Revit Schedule. Note: .ahk file contains the code, which can be opened by Notepad.

http://bim.nichitecture.com/

N