using Autodesk.Revit.DB; using OfficeOpenXml; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CDM.Interop.Revit.RevitCompoent { class RevitBeam : RevitComponent { public RevitBeam(string path) { using (ExcelPackage package = new ExcelPackage(new FileStream(path, FileMode.Open))) { ExcelWorksheet sheet = package.Workbook.Worksheets[1]; //ExcelWorksheet sheet = package.Workbook.Worksheets["基本构件"]; this.Name = sheet.Cells["G2"].Value.ToString(); this.Comment = sheet.Cells["G4"].Value.ToString(); base.Xl = Convert.ToDouble(sheet.Cells["H14"].Value); base.Yw = Convert.ToDouble(sheet.Cells["H15"].Value); base.Zh = Convert.ToDouble(sheet.Cells["H16"].Value); base.DegreesWithXAxis = Convert.ToDouble(sheet.Cells["H17"].Value); this.L = Convert.ToDouble(sheet.Cells["H18"].Value); this.SectionB = Convert.ToDouble(sheet.Cells["H19"].Value); this.SectionH = Convert.ToDouble(sheet.Cells["H20"].Value); } } /// /// Revit中的定位点 /// public XYZ rOrigin => new XYZ(base.Xl, base.Yw, base.Zh + SectionH / 2 / 1000) / 304.8 * 1000; /// /// 方向 /// public XYZ rDirection => new XYZ(Math.Cos(Radians), Math.Sin(Radians), 0); /// /// 终点 /// public XYZ rEndPoint => rOrigin + rDirection * L / 304.8; public double Radians => Math.PI / 180 * DegreesWithXAxis; /// /// 梁长 /// public double L { get; set; } /// /// 截面梁宽 /// public double SectionB { get; set; } /// /// 截面梁高 /// public double SectionH { get; set; } } }