/// <summary> /// Iterates through all the BarDescriptions in the project. /// store these data in a data table m_barDescriptions and /// store the AreaReinforcements id value in a array list m_areaReinforcementIdList /// </summary> private bool PrepareAllNeededData() { // reset the Columns of data table m_barDescriptions SetDataTableCloumn(); AreaReinforcement tempAreaReinforcement = null; FilteredElementIterator i = (new FilteredElementCollector(m_revit.Application.ActiveUIDocument.Document)).OfClass(typeof(AreaReinforcement)).GetElementIterator(); while (i.MoveNext()) { tempAreaReinforcement = i.Current as AreaReinforcement; if (tempAreaReinforcement != null) { // store all the AreaReinforcements id value in a array list m_areaReinforcementIdList m_areaReinforcementIdList.Add(tempAreaReinforcement.Id.IntegerValue); // store BarDescriptions in a data table m_barDescriptions for (int j = 0; j < tempAreaReinforcement.NumBarDescriptions; j++) { BarDescription barDescription = tempAreaReinforcement.get_BarDescription(j); SetCurrentBarDescriptionToTable(tempAreaReinforcement, barDescription); } } } if (null == tempAreaReinforcement) { return(false); } return(true); }
/// <summary> /// insert current BarDescription, which is iterated through, into data table /// </summary> /// <param name="areaReinforcement"></param> /// <param name="barDescription"></param> private void SetCurrentBarDescriptionToTable(AreaReinforcement areaReinforcement, BarDescription barDescription) { int areaReinforcementId = areaReinforcement.Id.IntegerValue; int layer = barDescription.Layer; string barType = barDescription.BarType.Name; double barLength = barDescription.Length; string[] hookType = new string[2] { "", "" }; bool hookSameDirection = barDescription.HooksInSameDirection; int barCount = barDescription.Count; for (int i = 0; i < 2; i++) { if (null == barDescription.get_HookType(i)) { hookType[i] = "None"; } else { hookType[i] = barDescription.get_HookType(i).Name; } } DataRow newRow = m_barDescriptions.NewRow(); newRow["areaReinforcementId"] = areaReinforcementId; newRow["layer"] = layer; newRow["barType"] = barType; newRow["barLength"] = barLength; newRow["oneEndHookType"] = hookType[0]; newRow["otherEndHookType"] = hookType[1]; newRow["hookSameDirection"] = hookSameDirection; newRow["barCount"] = barCount; m_barDescriptions.Rows.Add(newRow); }
/// <summary> /// insert current BarDescription, which is iterated through, into data table /// </summary> /// <param name="areaReinforcement"></param> /// <param name="barDescription"></param> private void SetCurrentBarDescriptionToTable(AreaReinforcement areaReinforcement, BarDescription barDescription) { int areaReinforcementId = areaReinforcement.Id.IntegerValue; int layer = barDescription.Layer; string barType = barDescription.BarType.Name; double barLength = barDescription.Length; string[] hookType = new string[2]{"",""}; bool hookSameDirection = barDescription.HooksInSameDirection; int barCount = barDescription.Count; for (int i = 0; i < 2; i++) { if (null == barDescription.get_HookType(i)) { hookType[i] = "None"; } else { hookType[i] = barDescription.get_HookType(i).Name; } } DataRow newRow = m_barDescriptions.NewRow(); newRow["areaReinforcementId"] = areaReinforcementId; newRow["layer"] = layer; newRow["barType"] = barType; newRow["barLength"] = barLength; newRow["oneEndHookType"] = hookType[0]; newRow["otherEndHookType"] = hookType[1]; newRow["hookSameDirection"] = hookSameDirection; newRow["barCount"] = barCount; m_barDescriptions.Rows.Add(newRow); }