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