Application: Truss
Revit Platform: Structure
Revit Version: 2011.0
First Released For: 2009.0
Programming Language: C#
Skill Level: Medium
Category: Structure , Geometry
Type: ExternalCommand

Subject: Create truss, edit truss Profile and Members.
Summary:
This sample demonstrates how to create a truss and modify its truss members and profile.
 
Classes: 
Autodesk.Revit.DB.Structure.Truss
Autodesk.Revit.DB.Structure.TrussType
Autodesk.Revit.DB.FamilyInstance
Autodesk.Revit.DB.FamilySymbol
Autodesk.Revit.DB.ViewPlan
Autodesk.Revit.DB.Strucure.TrussMemberInfo
Autodesk.Revit.DB.Line
Autodesk.Revit.DB.CurveArray

Project Files: 
Command.cs
This file contains a class Command that implements the IExternalCommand interface, creates TrussForm and gets ExternalCommandData.

TrussForm.cs
·	This file contains a class TrussForm which inherits from Form. This Form has a TabControl which contains three pages: “View”, “Truss Member” and “Profile Edit”. 
·	In “View” page, User can draw the start point and end point of Truss in a PictureBox to create truss on selected level, all available levels should be listed in a ComboBox. 
·	In “Truss Member” page, after user created truss, all the curves of truss should be displayed in a picture box, user can select truss member (beam) by clicking the curve in picture box, and user can change the beam type of selected truss member, all beam types should be listed in a ComboBox. 
·	In “ProfileEdit” page, user can edit profile of the new created truss in a picture box which displays geometry information of the truss, and user can withdraw the editing by clicking “Restore” button. This page also gives a “Update” button use to update the geometry of truss after profile been edited.

TrussGeometry.cs
This file contains a class TrussGeometry which used to calculate the geometry info of new created truss and change profile of truss. TrussGeometry consists of methods Draw2D() and SetProdile(). Draw2D() is used to draw truss curves on the picture box, and SetProfile() is used to reset the profile of truss by user input.

LineTool.cs
This file contains a class named LineTool which provides some methods to draw lines on the form and store the data of drawn lines.

MathTools.cs
This file contains Verctor4 and Matrix4 two classes. These two classes are used to transform points between 3D and 2D.

Description: 
This sample shows user how to create Truss by 
Autodesk.Revit.Creation.Document.NewTruss(Symbols.TrussType trussType, Elements.SketchPlane sketchPlane, Geometry.Curve baseCurve, Elements.View dbView) method:
n	TrussType will specify the type of truss, can be get from Autodesk.Revit.Document.TrussTypes property.
n	sketchPlane used to define which sketch plane truss can base on
n	baseCurve used to define the start point and end point of new truss.
n	dbView used to specify which level truss create on.

Instructions: 
1.	Select two columns or an existed truss in Revit.
2.	Run this command. (If there aren’t any templates for truss type or column in the project, you should load some first, or open Truss.rvt)
3.	If user select two columns, should select a Level on which you want to create truss in ComboBox, then click “Create” button to create a truss.
4.	After creating a new truss, you can open the “Truss Members” and “Profile Edit” tab pages.
5.	Open “Truss Members” page, you can select a truss member by clicking the each curve of truss geometry. After it turns red, you can change its beam type by “Change Type” button, and you can select the beam type you want change to in the ComboBox.
6.	Open “Profile Edit” page, user can draw TopChord line and BottomChord line in picture box and after you finished new profile for truss, click “Update” button, and you can restore the truss profile by “Restore” button.