/// <summary> /// Create the cross section type and angle information for a specified Wall element. /// </summary> /// <param name="wallElement">The wall element.</param> /// <returns>The WallCrossSectionInfo information, or null if not consistent.</returns> /// <remarks> /// The angles returned will be consistent with the cross section type. /// 1. A vertical wall will have no angles set. /// 2. A slanted wall will have one angle set, or will return null if that angle can't be found. /// 3. A tapered wall will have both angles set, or will return null if either angle can't be found. /// </remarks> public static WallCrossSectionInfo Create(Wall wallElement) { if (wallElement == null) { return(null); } Parameter crossSectionParam = wallElement.get_Parameter(BuiltInParameter.WALL_CROSS_SECTION); if (crossSectionParam == null || !crossSectionParam.HasValue || crossSectionParam.StorageType != StorageType.Integer) { return(null); } WallCrossSection crossSectionType = (WallCrossSection)crossSectionParam.AsInteger(); double? angle1 = null; double? angle2 = null; switch (crossSectionType) { case WallCrossSection.Vertical: // Vertical. break; case WallCrossSection.SingleSlanted: // Slanted. Parameter angleParam = wallElement.get_Parameter(BuiltInParameter.WALL_SINGLE_SLANT_ANGLE_FROM_VERTICAL); if (angleParam != null && angleParam.HasValue && angleParam.StorageType == StorageType.Double) { angle1 = angleParam.AsDouble(); } else { return(null); } break; case WallCrossSection.Tapered: // Vertically tapered. Parameter exteriorAngleParam = wallElement.get_Parameter(BuiltInParameter.WALL_TAPERED_EXTERIOR_INWARD_ANGLE); Parameter rightAngleParam = wallElement.get_Parameter(BuiltInParameter.WALL_TAPERED_INTERIOR_INWARD_ANGLE); // The two angles measure the inward slant. That is, they are positive if the // corresponding side face of the wall slants "into the wall" (i.e., toward the // other side of the wall). if ((exteriorAngleParam != null && exteriorAngleParam.HasValue && exteriorAngleParam.StorageType == StorageType.Double) && (rightAngleParam != null && rightAngleParam.HasValue && rightAngleParam.StorageType == StorageType.Double)) { angle1 = exteriorAngleParam.AsDouble(); angle2 = rightAngleParam.AsDouble(); } else { return(null); } break; default: // Unknown case. return(null); } return(new WallCrossSectionInfo(crossSectionType, angle1, angle2)); }
private WallCrossSectionInfo(WallCrossSection wallCrossSection, double?angle1, double?angle2) { CrossSectionInfo = Tuple.Create(wallCrossSection, angle1, angle2); }