public JsonLineProperty SetupLineProperty(DBObject item, JsonBlockSetup jsonBlockSetup) { var jsonLineProperty = new JsonLineProperty(); jsonLineProperty.Type = Convert.ToString(item); if (item is Line) { var line = item as Line; jsonLineProperty.LinePoints.Add(ConvertAcadPoint3dToPoint2D(line.StartPoint, 1)); jsonLineProperty.LinePoints.Add(ConvertAcadPoint3dToPoint2D(line.EndPoint, 2)); jsonLineProperty.Layer = jsonBlockSetup.RealNameFinder(line.Layer); jsonLineProperty.Internal_Id = BlockTableRead.InternalCounter; } else if (item is Polyline) { var p = item as Polyline; for (var i = 0; i < p.NumberOfVertices; i++) { var point = p.GetPoint2dAt(i); jsonLineProperty.LinePoints.Add(ConvertAcadPoint2dToPoint2D(point, i + 1)); jsonLineProperty.Layer = jsonBlockSetup.RealNameFinder(p.Layer); //System.Diagnostics.Debug.WriteLine($"\t\tPOLYLINE POINTS: {point}"); } p.Closed = false; jsonLineProperty.Internal_Id = BlockTableRead.InternalCounter; } else if (item is Polyline2d) { var p2d = item as Polyline2d; int i = 1; foreach (Vertex2d polyline in p2d) { jsonLineProperty.LinePoints.Add(ConvertAcadVertex2DToPoint2D(polyline, i)); jsonLineProperty.Layer = jsonBlockSetup.RealNameFinder(p2d.Layer); i++; } p2d.Closed = false; jsonLineProperty.Internal_Id = BlockTableRead.InternalCounter; } else if (item is Polyline3d) { var p3d = item as Polyline3d; int i = 1; foreach (Vertex2d polyline in p3d) { jsonLineProperty.LinePoints.Add(ConvertAcadVertex2DToPoint2D(polyline, i)); jsonLineProperty.Layer = jsonBlockSetup.RealNameFinder(p3d.Layer); i++; } p3d.Closed = false; jsonLineProperty.Internal_Id = BlockTableRead.InternalCounter; } return(jsonLineProperty); }
public bool LineTypeComparer(JsonLineProperty line1, JsonLineProperty line2) { //System.Diagnostics.Debug.WriteLine($"AutoCAD TAG: {attRef.Tag}"); var properties1 = line1.Type; //.GetType().GetProperties(); var properties2 = line2.Type; //.GetType().GetProperties(); if (properties1.Length != properties2.Length || properties1.ToString() != properties2.ToString()) { if (!Comments.Contains($"InternalId: {line1.Internal_Id}")) { Comments.Add($"InternalId: {line1.Internal_Id}"); } Comments.Add(($"Type: {properties1}")); return(false); } return(true); }
public bool LineCompare(JsonLineProperty line1, JsonLineProperty line2) { if (!line1.Type.Equals(line2.Type)) { AddInternalIdToComments(line1.Internal_Id); Comments.Add($"\tType does not match: {line1.Type}"); return(false); } if (line1.LinePoints.Count != line2.LinePoints.Count) { AddInternalIdToComments(line1.Internal_Id); Comments.Add($"\tLinePoint number is not equal."); return(false); } var localErrors = new List <string>(); for (int j = 0; j < line1.LinePoints.Count; j++) { var p1 = line1.LinePoints[j]; var p2 = line2.LinePoints[j]; if (p1.X != p2.X || p1.Y != p2.Y) { localErrors.Add($"\tPoint[{p1.Point}] (X1:{p1.X}|Y1:{p1.Y}) != (X2:{p2.X}|Y2:{p2.Y})"); // id } } if (localErrors.Count > 0) { AddInternalIdToComments(line1.Internal_Id); Comments.AddRange(localErrors); return(false); } return(true); }