public Boolean ExecuteStructSample()
{
Document rvtDoc = m_app.ActiveUIDocument.Document;
FamilySymbol colType = null;
List<Wall> walls = new List<Wall>();
// iterate through a selection set, and collect walls which are constrained at the top and the bottom.
//
foreach( ElementId id in m_ids )
{
Element elem = rvtDoc.GetElement( id );
if( elem.GetType() == typeof( Autodesk.Revit.DB.Wall ) )
{
if( elem.get_Parameter( BuiltInParameter.WALL_HEIGHT_TYPE ) != null && elem.get_Parameter( BuiltInParameter.WALL_BASE_CONSTRAINT ) != null )
{
walls.Add( elem as Wall );
}
}
}
// how many did we get?
MessageBox.Show( "Number of constrained walls in the selection set is " + walls.Count );
if( walls.Count == 0 )
{
DialogResult dlgRes = MessageBox.Show( "You must select some walls that are constrained top or bottom", "Structural Sample", MessageBoxButtons.OK, MessageBoxIcon.Information );
if( dlgRes == System.Windows.Forms.DialogResult.OK )
{
return false;
}
}
// we have some # of walls now.
// Load the required family
FilteredElementCollector collect = new FilteredElementCollector( rvtDoc );
ElementClassFilter familyAreWanted = new ElementClassFilter( typeof( Family ) );
collect.WherePasses( familyAreWanted );
List<Element> elements = collect.ToElements() as List<Element>;
foreach( Element e in elements )
{
Family fam = e as Family;
if( fam != null )
{
if( fam.Name == "M_Wood Timber Column" )
{
colType = Utils.FamilyUtil.GetFamilySymbol( fam, "191 x 292mm" );
}
}
}
String fileName = "../Data/Platform/Metric/Library/Architectural/Columns/M_Wood Timber Column.rfa";
Family columnFamily;
if( colType == null )
{
m_app.ActiveUIDocument.Document.LoadFamily( fileName, out columnFamily );
colType = Utils.FamilyUtil.GetFamilySymbol( columnFamily, "191 x 292mm" );
}
if( colType == null )
{
MessageBox.Show( "Please load the M_Wood Timber Column : 191 x 292mm family" );
Utils.UserInput.LoadFamily( null, m_app.ActiveUIDocument.Document );
}
//
// place columns.
//
double spacing = 5; // Spacing in feet hard coded. Note: Revit's internal length unit is feet.
foreach( Autodesk.Revit.DB.Wall wall in walls )
{
FrameWall( m_app.Application, wall, spacing, colType );
}
return true;
}