public SectionsResult(SectionsInfo sections) { Sections = sections.Sections; StartIndex = sections.StartIndex; Size = sections.Size; Amount = sections.Amount; }
static void Test14() { Database db = Database.FromResources("MyDatabase", "D://"); SectionsInfo si = new SectionsInfo(db); db.LoadSection("Тексты", si.GetIdsByLabel("Тексты")[0]); Console.WriteLine(((DataString)db.Select(0, 0)).ContentString); }
static void Test10() { Database db = Database.FromResources("MyDatabase", "D://"); SectionsInfo si = new SectionsInfo(db); db.LoadSection("-= <= RESOURCES => =-", si.GetIdsByLabel("-= <= RESOURCES => =-")[0]); Resource resource = (Resource)db.CurrentSection.Get(new Position(0, 0)); File.WriteAllBytes("D://MyDatabase/resultImage.png", resource.ContentData); }
static void Test4() { Database db = Database.FromResources("MyDatabase", "D://"); SectionsInfo si = new SectionsInfo(db); db.LoadSection("Дампы времени", si.GetIdsByLabel("Дампы времени")[0]); foreach (Integer i in db.CurrentSection.AsList()) { Console.WriteLine(i.Label + " > " + i.ContentInt32); } }
static void Test2() { Database db = Database.FromResources("MyDatabase", "D://"); SectionsInfo si = new SectionsInfo(db); db.LoadSection("ABC", si.GetIdsByLabel("ABC")[0]); foreach (DataString str in db.CurrentSection.AsList()) { Console.WriteLine(str.Label + " > " + str.ContentString); } }
private double ScaleBetweenSections(SectionsInfo secAtTheBeg, SectionsInfo secAtTheEnd) { XYZ xyz_min_Beg = secAtTheBeg.GetMinimumBoundary(); XYZ xyz_max_Beg = secAtTheBeg.GetMaximumBoundary(); XYZ xyz_min_End = secAtTheEnd.GetMinimumBoundary(); XYZ xyz_max_End = secAtTheEnd.GetMaximumBoundary(); double widthBeg = Math.Abs(xyz_max_Beg.X - xyz_min_Beg.X); double widthEnd = Math.Abs(xyz_max_End.X - xyz_min_End.X); double heightBeg = Math.Abs(xyz_max_Beg.Y - xyz_min_Beg.Y); double heightEnd = Math.Abs(xyz_max_End.Y - xyz_min_End.Y); double widthScale = widthEnd / widthBeg; double heightScale = heightEnd / heightBeg; if (widthScale > 1.0) { if (heightScale > 1.0) { return(Math.Max(widthScale, heightScale)); } else { if (Math.Max(widthScale, 1.0 / heightScale) > widthScale) { return(heightScale); } else { return(widthScale); } } } else { if (heightScale < 1.0) { return(Math.Min(widthScale, heightScale)); } else { if (Math.Min(widthScale, 1.0 / heightScale) < widthScale) { return(heightScale); } else { return(widthScale); } } } }
static void Test12() { Database db = Database.FromResources("MyDatabase", "D://"); SectionsInfo si = new SectionsInfo(db); db.LoadSection("Компоненты", si.GetIdsByLabel("Компоненты")[0]); Component com1 = (Component)db.CurrentSection.Get(new Position(0, 0)); Component com2 = (Component)db.CurrentSection.Get(new Position(0, 1)); Component com3 = (Component)db.CurrentSection.Get(new Position(0, 2)); Component com4 = (Component)db.CurrentSection.Get(new Position(0, 3)); Component com5 = (Component)db.CurrentSection.Get(new Position(0, 4)); Console.WriteLine("{0}, {1}, {2}, {3}, {4}", com1.Run(), com2.Run(), com3.Run(), com4.Run(), com5.Run()); }
static void Test8() { //need Test7() before run Database db = Database.FromResources("MyDatabase", "D://"); SectionsInfo si = new SectionsInfo(db); db.LoadSection("Тест группировки", si.GetIdsByLabel("Тест группировки")[0]); Group group = (Group)db.CurrentSection.Get(grp); Console.WriteLine(group.Label); foreach (DataString str in db.CurrentSection.AsList(group.ContentLinks)) { Console.WriteLine(str.Label + " > " + str.ContentString); } }
static void Test6() { Database db = Database.FromResources("MyDatabase", "D://"); SectionsInfo si = new SectionsInfo(db); db.LoadSection("Хранение объектов", si.GetIdsByLabel("Хранение объектов")[0]); TestSctruct ts; foreach (Structure i in db.CurrentSection.AsList()) { ts = (TestSctruct)i.ContentData; Console.WriteLine(i.Label + " > " + ts.PlayerName + " " + ts.CreationTime.ToString() + " " + ts.X + " " + ts.Y + " " + ts.Z); } }
/// <summary> /// Runs calculation\operations for cref="BeamSection" and cref="ColumnSection". /// </summary> /// <param name="obj">cref="BeamSection" object or cref="ColumnSection" object.</param> /// <returns>Result of calculation.</returns> public bool Run(ObjectDataBase obj) { SectionDataBase sectionData = obj as SectionDataBase; if (obj != null) { CommonParameters commParams = Parameters as CommonParameters; ForceResultsCache cache = null; if (commParams != null) { cache = commParams.ResultCache; } Section sec = null; switch (sectionData.Category) { default: break; case Autodesk.Revit.DB.BuiltInCategory.OST_ColumnAnalytical: if (sectionData is ColumnSection) { ColumnSection section = sectionData as ColumnSection; if (section.Info != null) { SectionsInfo secInfo = section.Info.Sections.AtTheBeg; if (secInfo.Sections.Count > 0) { sec = secInfo.Sections[0]; } } } break; case Autodesk.Revit.DB.BuiltInCategory.OST_BeamAnalytical: if (sectionData is BeamSection && sectionData.Label is LabelBeam) { BeamSection section = sectionData as BeamSection; LabelBeam label = sectionData.Label as LabelBeam; if (section.Info != null) { SectionsInfo secInfo = section.Info.Sections.AtTheBeg; if (secInfo.Sections.Count > 0) { sec = secInfo.Sections[0]; if (label.SlabBeamInteraction == ConcreteTypes.BeamSectionType.WithSlabBeamInteraction && section.Info.Slabs != null && section.Info.Slabs.TSection != null) { int nbrPoints = (sec.Contour != null && sec.Contour.Points != null) ? sec.Contour.Points.Count : 0; double relativeX = (section.CalcPoint as CalcPointLinear).CoordRelative; double maxFlangeWidth = 0.5 * section.Info.SectionsParams.AtThePoint(relativeX).Dimensions.h; sec = section.Info.Slabs.TSection.GetContour(relativeX, maxFlangeWidth, maxFlangeWidth); if (sec.Contour.Points.Count != nbrPoints) { section.IsTSection = true; section.DesignInfo.Add(Resources.ResourceManager.GetString("SlabBeamInteraction")); } } } } } break; } switch (sectionData.Category) { default: break; case Autodesk.Revit.DB.BuiltInCategory.OST_ColumnAnalytical: case Autodesk.Revit.DB.BuiltInCategory.OST_BeamAnalytical: if (sectionData is LinearSection) { LinearSection section = sectionData as LinearSection; if (sec != null && sec.Contour != null) { foreach (Autodesk.Revit.DB.XYZ p in sec.Contour.Points) { section.Geometry.Add(p.X, p.Y); } Autodesk.Revit.DB.XYZ pmin = sec.GetMinimumBoundary(); Autodesk.Revit.DB.XYZ pmax = sec.GetMaximumBoundary(); section.Width = Math.Abs(pmin.X - pmax.X); section.Height = Math.Abs(pmin.Y - pmax.Y); } if (cache != null) { IList <ForceLoadCaseDescriptor> loadCaseDescriptors = cache.GetLoadCaseDescriptors(); List <double> vFx = cache.GetForceForPoint(sectionData.ElementId, loadCaseDescriptors, sectionData.CalcPoint, ForceType.Fx); List <double> vFy = cache.GetForceForPoint(sectionData.ElementId, loadCaseDescriptors, sectionData.CalcPoint, ForceType.Fy); List <double> vFz = cache.GetForceForPoint(sectionData.ElementId, loadCaseDescriptors, sectionData.CalcPoint, ForceType.Fz); List <double> vMx = cache.GetForceForPoint(sectionData.ElementId, loadCaseDescriptors, sectionData.CalcPoint, ForceType.Mx); List <double> vMy = cache.GetForceForPoint(sectionData.ElementId, loadCaseDescriptors, sectionData.CalcPoint, ForceType.My); List <double> vMz = cache.GetForceForPoint(sectionData.ElementId, loadCaseDescriptors, sectionData.CalcPoint, ForceType.Mz); List <double> vUx = cache.GetForceForPoint(sectionData.ElementId, loadCaseDescriptors, sectionData.CalcPoint, ForceType.Ux); List <double> vUy = cache.GetForceForPoint(sectionData.ElementId, loadCaseDescriptors, sectionData.CalcPoint, ForceType.Uy); List <double> vUz = cache.GetForceForPoint(sectionData.ElementId, loadCaseDescriptors, sectionData.CalcPoint, ForceType.Uz); int i = -1; foreach (ForceLoadCaseDescriptor cas in loadCaseDescriptors) { i++; InternalForcesLinear linForces = new InternalForcesLinear(); InternalForcesContainer forces = new InternalForcesContainer(); forces.CaseName = cas.Name; forces.LimitState = cas.State; forces.ForceFx = vFx.Count == 0 ? 0.0 : vFx[i]; forces.ForceFy = vFy.Count == 0 ? 0.0 : vFy[i]; forces.ForceFz = vFz.Count == 0 ? 0.0 : vFz[i]; forces.MomentMx = vMx.Count == 0 ? 0.0 : vMx[i]; forces.MomentMy = vMy.Count == 0 ? 0.0 : vMy[i]; forces.MomentMz = vMz.Count == 0 ? 0.0 : vMz[i]; forces.DeflectionUx = vUx.Count == 0 ? 0.0 : vUx[i]; forces.DeflectionUy = vUy.Count == 0 ? 0.0 : vUy[i]; forces.DeflectionUz = vUz.Count == 0 ? 0.0 : vUz[i]; linForces.Forces = forces; section.ListInternalForces.Add(linForces); } } } break; } } return(true); }
private void AddShapesToRender(SectionsInfo sectionsInfo, Canvas sectionViewer, double scale) { sectionViewer.Children.Clear(); double actualWidth = sectionViewer.Width; double actualHeight = sectionViewer.MinHeight; if (sectionViewer.ActualWidth > 0) { actualWidth = sectionViewer.ActualWidth; } if (sectionViewer.ActualHeight > 0) { actualHeight = sectionViewer.ActualHeight; } double horizontalMargin = actualWidth / 6; double verticalMargin = actualHeight / 6; double width = actualWidth - 2 * horizontalMargin; double height = actualHeight - 2 * verticalMargin; horizontalMargin += (width - width * scale) / 2.0; verticalMargin += (height - height * scale) / 2.0; double horizontalShift = horizontalMargin; double verticalShift = verticalMargin; XYZ xyz_min = sectionsInfo.GetMinimumBoundary(); XYZ xyz_max = sectionsInfo.GetMaximumBoundary(); width = Math.Abs(xyz_max.X - xyz_min.X); height = Math.Abs(xyz_max.Y - xyz_min.Y); double stretchCoeff = 0; if (height > width) { stretchCoeff = (actualHeight - 2 * verticalMargin) / height; horizontalShift += (height - width) * stretchCoeff / 2; } else { stretchCoeff = (actualWidth - 2 * horizontalMargin) / width; verticalShift += (width - height) * stretchCoeff / 2; } if (xyz_min.X < 0) { horizontalShift -= stretchCoeff * xyz_min.X; } if (xyz_min.Y < 0) { verticalShift -= stretchCoeff * xyz_min.Y; } List <System.Windows.Shapes.Shape> contours = new List <System.Windows.Shapes.Shape>(); List <System.Windows.Shapes.Shape> holes = new List <System.Windows.Shapes.Shape>(); XYZ maxB = sectionsInfo.GetMaximumBoundary(); XYZ minB = sectionsInfo.GetMinimumBoundary(); foreach (Autodesk.Revit.DB.CodeChecking.Engineering.Section section in sectionsInfo.Sections) { Polygon polygon = new Polygon(); PointCollection points = new PointCollection(); foreach (XYZ xyz in section.Contour.Points) { points.Add(new Point(xyz.X * stretchCoeff, (minB.Y + (maxB.Y - xyz.Y)) * stretchCoeff)); } polygon.Points = points; polygon.Fill = Brushes.LightSteelBlue; polygon.Stretch = Stretch.None; polygon.Stroke = Brushes.Black; polygon.StrokeThickness = 1; contours.Add(polygon); foreach (Autodesk.Revit.DB.CodeChecking.Engineering.Shape shape in section.Holes) { polygon = new Polygon(); points = new PointCollection(); foreach (XYZ xyz in shape.Points) { points.Add(new Point(xyz.X * stretchCoeff, (minB.Y + (maxB.Y - xyz.Y)) * stretchCoeff)); } polygon.Points = points; polygon.Fill = Brushes.White; polygon.Stretch = Stretch.None; polygon.Stroke = Brushes.Black; polygon.StrokeThickness = 1; holes.Add(polygon); } } if (contours.Count() < 1) { horizontalShift = (actualWidth - defaultShapeToRender.Width) / 2; verticalShift = (actualHeight - defaultShapeToRender.Height) / 2; Canvas.SetLeft(defaultShapeToRender, horizontalShift); Canvas.SetTop(defaultShapeToRender, verticalShift); sectionViewer.Children.Add(defaultShapeToRender); return; } foreach (System.Windows.Shapes.Shape contour in contours) { Canvas.SetLeft(contour, horizontalShift); Canvas.SetTop(contour, verticalShift); sectionViewer.Children.Add(contour); } foreach (System.Windows.Shapes.Shape hole in holes) { Canvas.SetLeft(hole, horizontalShift); Canvas.SetTop(hole, verticalShift); sectionViewer.Children.Add(hole); } }