public static CADArea ToCADArea(this ObjectId[] objIds, Point3d zero, string zeroType) { CADArea sps = new CADArea(); foreach (var item in objIds) { var sp = item.ToCADShape(); if (sp != null) { sps.Shapes.Add(sp); sp.Num = sps.Shapes.Count; } } sps.SetZero(zero.ToCADPoint(), zeroType); return(sps); }
public static CADArea ToCADArea(this ObjectId[] objIds, CADPoint zero, string zeroType, bool isToUCS, bool isSetZero) { CADArea sps = new CADArea(); foreach (var item in objIds) { var sp = item.ToCADShape(isToUCS); if (sp != null) { sps.Shapes.Add(sp); sp.Num = sps.Shapes.Count; } } if (isSetZero) { sps.SetZero(zero, zeroType); } return(sps); }
private void Worker2_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker1 = sender as BackgroundWorker; string basePath = AppDomain.CurrentDomain.BaseDirectory; string filePath = basePath + "Data\\CADAreaInfo.xml"; CADAreaList list = XmlSerializeHelper.LoadFromFile <CADAreaList>(filePath); list.LineToBlock(); Bll bll = new Bll(); var areas = bll.Areas.ToList(false); List <Point> newPoints = new List <Point>(); List <Area> newBounds = new List <Area>(); List <Area> newAreas = new List <Area>(); int count = 0; for (int i1 = 0; i1 < list.Count; i1++) { CADArea item = list[i1]; var area = areas.Find(i => i.Name == item.Name); if (area != null) { count += item.Shapes.Count; } } int index = 0; for (int i1 = 0; i1 < list.Count; i1++) { CADArea item = list[i1]; var area = areas.Find(i => i.Name == item.Name); if (area != null) { for (int i = 0; i < item.Shapes.Count; i++) { index++; CADShape sp = item.Shapes[i]; Bound bound = new Bound(); bool r1 = bll.Bounds.Add(bound); if (r1) { Area newArea = new Area(); newArea.Name = sp.Name; newArea.Type = AreaTypes.CAD; newArea.ParentId = area.Id; newArea.InitBound = bound; var r2 = bll.Areas.Add(newArea); if (r2) { var pointList = new List <Point>(); foreach (var pt in sp.Points) { var point = new Point(); point.X = (float)pt.X / 1000 - 0.1f; point.Y = (float)pt.Y / 1000 - 0.1f; point.BoundId = bound.Id; var r3 = bll.Points.Add(point); pointList.Add(point); } bound.Shape = 0; bound.IsRelative = true; bound.SetInitBound(pointList.ToArray(), area.InitBound.MinZ, (float)area.InitBound.GetHeight()); bool r4 = bll.Bounds.Edit(bound); newArea.SetBound(bound); bll.Areas.Edit(newArea); } } int percent = (int)((index + 0.0) / count * 100); worker1.ReportProgress(percent); } } } //bll.Areas.AddRange(newAreas); }