public static void GetColumnPointsEx() { try { CADAreaList areaList = new CADAreaList(); var zero = Interaction.GetPoint("ZeroPoint"); string[] keys = { "0:左下", "1:右下", "2:右上", "3:左上" }; string p1 = zero.ToString(); string p2 = zero.ToUCS().ToString(); string p3 = zero.ToWCS().ToString(); Interaction.WriteLine(string.Format("\n zero [{0},{1},{2}]", p1, p2, p3)); var key = Interaction.GetKeywords("\nChoose1 Zero Type ", keys); if (string.IsNullOrEmpty(key)) { return; } //var key = Interaction.GetKeywords("\nChoose1 Zero Type ", keys); var columns = Interaction.GetEntitysByLayers("COLUMN"); var area = columns.ToCADArea(zero.ToCADPoint(true), key, true, true); area.Name = "主厂房0m层"; areaList.Add(area); var txt = areaList.ToXml(); MyTool.TextReport("Points", txt, 700, 500); } catch (System.Exception ex) { MyTool.TextReport("Exception", ex.ToString(), 700, 500); } }
public static void GetColumnPointsEx() { CADAreaList areaList = new CADAreaList(); var zero = Interaction.GetPoint("ZeroPoint"); string[] keys = { "0:左下", "1:右下", "2:右上", "3:左上" }; var key = Interaction.GetKeywords("\nChoose Zero Type", keys); var columns = Interaction.GetEntitysByLayers("COLUMN"); var area = columns.ToCADArea(zero, key); area.Name = "主厂房0m层"; areaList.Add(area); var txt = areaList.ToXml(); Gui.TextReport("Points", txt, 700, 500); }
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); }