/// <summary> /// create the extrusions of the air handler system /// </summary> private void CreateExtrusions() { Autodesk.Revit.Creation.Application app = m_application.Create; CurveArray curves = null; CurveArrArray profile = null; Plane plane = null; SketchPlane sketchPlane = null; #region Create the cuboid extrusions for (int i = 0; i <= 2; ++i) { // create the profile curves = app.NewCurveArray(); curves.Append(Line.CreateBound(profileData[i, 0], profileData[i, 1])); curves.Append(Line.CreateBound(profileData[i, 1], profileData[i, 2])); curves.Append(Line.CreateBound(profileData[i, 2], profileData[i, 3])); curves.Append(Line.CreateBound(profileData[i, 3], profileData[i, 0])); profile = app.NewCurveArrArray(); profile.Append(curves); // create the sketch plane plane = app.NewPlane(sketchPlaneData[i, 0], sketchPlaneData[i, 1]); sketchPlane = SketchPlane.Create(m_document, plane); // create the extrusion extrusions[i] = f.NewExtrusion(isSolid[i], profile, sketchPlane, extrusionOffsets[i, 1]); extrusions[i].StartOffset = extrusionOffsets[i, 0]; m_combineElements.Append(extrusions[i]); } #endregion #region Create the round extrusions for (int i = 3; i <= 4; ++i) { // create the profile profile = app.NewCurveArrArray(); curves = app.NewCurveArray(); plane = new Plane(profileData[i, 0], profileData[i, 1]); curves.Append(Arc.Create(plane, arcRadius, 0, Math.PI * 2)); profile.Append(curves); // create the sketch plane plane = app.NewPlane(sketchPlaneData[i, 0], sketchPlaneData[i, 1]); sketchPlane = SketchPlane.Create(m_document, plane); // create the extrusion extrusions[i] = f.NewExtrusion(isSolid[i], profile, sketchPlane, extrusionOffsets[i, 1]); extrusions[i].StartOffset = extrusionOffsets[i, 0]; m_combineElements.Append(extrusions[i]); } #endregion }
/// <summary> /// Batch creation of Walls /// </summary> /// <returns>If batch creation succeeds, return true; otherwise, return false</returns> private bool CreateWalls() { try { if (null == m_level) { return(false); } //Create ProfiledWallCreationData for Walls' batch creation List <ProfiledWallCreationData> profiledWallCreationDatas = new List <ProfiledWallCreationData>(); Autodesk.Revit.Creation.Application appCreation = m_cmdData.Application.Application.Create; for (int i = 1; i < 11; i++) { // Create wall's profile which is a combination of rectangle and arc CurveArray curveArray = appCreation.NewCurveArray(); // Create three lines for rectangle part of profile. Autodesk.Revit.DB.XYZ pt1 = new Autodesk.Revit.DB.XYZ(i * 10, -80, 15); Autodesk.Revit.DB.XYZ pt2 = new Autodesk.Revit.DB.XYZ(i * 10, -80, 0); Autodesk.Revit.DB.XYZ pt3 = new Autodesk.Revit.DB.XYZ(i * 10, -90, 0); Autodesk.Revit.DB.XYZ pt4 = new Autodesk.Revit.DB.XYZ(i * 10, -90, 15); Line line1 = appCreation.NewLine(pt1, pt2, true); Line line2 = appCreation.NewLine(pt2, pt3, true); Line line3 = appCreation.NewLine(pt3, pt4, true); // Create arc part of profile. Autodesk.Revit.DB.XYZ pointInCurve = new Autodesk.Revit.DB.XYZ(i * 10, -85, 20); Arc arc = appCreation.NewArc(pt4, pt1, pointInCurve); if (null == line1 || null == line2 || null == line3 || null == arc) { continue; } curveArray.Append(line1); curveArray.Append(line2); curveArray.Append(line3); curveArray.Append(arc); ProfiledWallCreationData profiledWallCreationData = new ProfiledWallCreationData(curveArray, true); if (null != profiledWallCreationData) { profiledWallCreationDatas.Add(profiledWallCreationData); } } //Create RectangularWallCreationData for Walls' batch creation List <RectangularWallCreationData> rectangularWallCreationDatas = new List <RectangularWallCreationData>(); for (int i = 1; i < 11; i++) { Autodesk.Revit.DB.XYZ pt1 = new Autodesk.Revit.DB.XYZ(i * 10, -110, 0); Autodesk.Revit.DB.XYZ pt2 = new Autodesk.Revit.DB.XYZ(i * 10, -120, 0); Line line = appCreation.NewLine(pt1, pt2, true); RectangularWallCreationData rectangularWallCreationData = null; if (null != line) { rectangularWallCreationData = new RectangularWallCreationData(line, m_level, true); } if (null != rectangularWallCreationData) { rectangularWallCreationDatas.Add(rectangularWallCreationData); } } // Create Walls if (0 == profiledWallCreationDatas.Count || 0 == rectangularWallCreationDatas.Count) { return(false); } m_doc.Create.NewWalls(profiledWallCreationDatas); m_doc.Create.NewWalls(rectangularWallCreationDatas); } catch (Exception) { return(false); } return(true); }