private AcDb.ObjectId AddBorders() { AcDb.Polyline2d borderParcel = ServiceSimpleElements.CreatePolyline2d(this.Parcel.Points, true); borderParcel.LayerId = ServiceCAD.CreateLayer(settingsDrawing.Plan.FillParcel.Layer); AcDb.ObjectId idBorderParcel = ServiceCAD.InsertObject(borderParcel); AcDb.ResultBuffer xData = new AcDb.ResultBuffer(); int dxfCode; AcDb.TypedValue typedValue; dxfCode = (int)AcDb.DxfCode.ExtendedDataRegAppName; typedValue = new AcDb.TypedValue(dxfCode, "Земельна ділянка"); xData.Add(typedValue); foreach (LandInfo infoValue in this.Parcel.Info) { dxfCode = (int)AcDb.DxfCode.ExtendedDataAsciiString; typedValue = new AcDb.TypedValue(dxfCode, "<" + infoValue.Key + "> " + infoValue.Value); xData.Add(typedValue); } ServiceCAD.SetXData(idBorderParcel, xData); return(idBorderParcel); }
/// <summary> /// Створює елементи вектору з данними виносу. /// </summary> private void CreateDrawingStakeOut() { if (this.PointStation == null) { return; } AcGe.Point3d pntStart = new AcGe.Point3d(this.PointStation.E, this.PointStation.N, this.PointStation.H); AcGe.Point3d pntEnd = new AcGe.Point3d(this.Coordinates.X, this.Coordinates.Y, 0); AcDb.Line line = new AcDb.Line(pntStart, pntEnd); line.Visible = this.Visible; AcGe.Point3d pntMiddle = new AcGe.LineSegment3d(pntStart, pntEnd).MidPoint; double angleTXT = line.Angle; if (angleTXT > Math.PI / 2 && angleTXT < Math.PI * 3 / 2) { angleTXT += Math.PI; } AcDb.MText text = new AcDb.MText(); text.Contents = this.DistanceToString(AcRx.DistanceUnitFormat.Decimal) + "\r\n" + "л.к. " + ServiceTable.FormatAngleValue(this.LeftlAngleToString(AcRx.AngularUnitFormat.DegreesMinutesSeconds)); text.Rotation = angleTXT; text.Location = pntMiddle; text.Attachment = AcDb.AttachmentPoint.MiddleCenter; text.Width = 25; text.TextHeight = 1.8 * this.ScaleDrawing; this.lineID = ServiceCAD.InsertObject(line); this.txtID = ServiceCAD.InsertObject(text); }
private void AddLengthLine() { //AcDb.DBText oText; AcDb.MText oMText; AcDb.Line lineCur = null; AcDb.ObjectId idLineCur; AcGe.Point2d startPoint = this.Parcel.Points.ToArray()[this.Parcel.Points.Count - 1]; AcGe.Point3d midPoint; foreach (AcGe.Point2d endPoint in this.Parcel.Points) { midPoint = new AcGe.Point3d((endPoint.X + startPoint.X) / 2, (endPoint.Y + startPoint.Y) / 2, 0); lineCur = new AcDb.Line(new AcGe.Point3d(startPoint.X, startPoint.Y, 0), new AcGe.Point3d(endPoint.X, endPoint.Y, 0)); lineCur.ColorIndex = 222; lineCur.LineWeight = AcDb.LineWeight.LineWeight030; idLineCur = ServiceCAD.InsertObject(lineCur); ServiceCAD.ZoomCenter(midPoint, 1); /* * oText = new AcDb.DBText(); * oText.Height = 2 * this.SettingsForm.ScaleDrawing; * oText.TextString = startPoint.GetDistanceTo(endPoint).ToString("0.00").Replace(",","."); * //oText.Layer = settingsDrawing.Plan.LengthLine.Layer; * * ServiceCAD.ManualInsertText(oText); */ oMText = new AcDb.MText(); oMText.TextHeight = 2 * this.SettingsForm.ScaleDrawing; oMText.Attachment = AcDb.AttachmentPoint.MiddleCenter; //oMText.Layer = settingsDrawing.Plan.LengthLine.Layer; oMText.Contents = startPoint.GetDistanceTo(endPoint).ToString("0.00").Replace(",", "."); ServiceCAD.ZoomCenter(midPoint, 1); ServiceSimpleElements.ManualInsertMText(oMText); ServiceCAD.DeleteObject(idLineCur); startPoint = endPoint; } }
static List <AcDb.ObjectId> InsertAllParcel(BL blockLand, AcGe.Vector2d offset) { AcDb.Polyline2d curPolyline; AcGe.Point2dCollection points; List <AcDb.ObjectId> listObjectId = new List <AcDb.ObjectId>(); foreach (SR sr in blockLand.SR) { points = ServiceSimpleElements.Offset(ServiceIn4.GetPoints2dFromIn4Polygon(sr), offset); curPolyline = ServiceSimpleElements.CreatePolyline2d(points, true); listObjectId.Add(ServiceCAD.InsertObject(curPolyline)); } return(listObjectId); }
private void AddNumdersPoints() { int iCurNumberPoint = 0; //AcDb.DBText oText; AcDb.MText oMText; AcDb.Circle circleCurPoint = null; AcDb.ObjectId idCircleCurPoint; foreach (AcGe.Point2d point in this.Parcel.Points) { iCurNumberPoint += 1; circleCurPoint = new AcDb.Circle( new AcGe.Point3d(point.X, point.Y, 0), new AcGe.Vector3d(0, 0, 1), 1.75 * this.SettingsForm.ScaleDrawing); circleCurPoint.ColorIndex = 222; circleCurPoint.LineWeight = AcDb.LineWeight.LineWeight030; idCircleCurPoint = ServiceCAD.InsertObject(circleCurPoint); /* * oText = new AcDb.DBText(); * oText.TextString = Convert.ToString(iCurNumberPoint); * oText.Height = settingsDrawing.Plan.NumberPoint.TextHeight * this.SettingsForm.ScaleDrawing; * //oText.Layer = settingsDrawing.Plan.NumberPoint.Layer; */ oMText = new AcDb.MText(); oMText.TextHeight = 2 * this.SettingsForm.ScaleDrawing; oMText.Attachment = AcDb.AttachmentPoint.MiddleCenter; //oMText.Layer = settingsDrawing.Plan.LengthLine.Layer; oMText.Contents = Convert.ToString(iCurNumberPoint); ServiceCAD.ZoomCenter(new AcGe.Point3d(point.X, point.Y, 0), 1); ServiceSimpleElements.ManualInsertMText(oMText); ServiceCAD.DeleteObject(idCircleCurPoint); } }
private void AddFills() { Dictionary <string, HatchPolygon> listMissingHatch = new Dictionary <string, HatchPolygon>(); // // Parcel // if (SettingsForm.DisplayFillParcel) { AcDb.Polyline2d borderParcel = ServiceSimpleElements.CreatePolyline2d(this.Parcel.Points, true); AcDb.ObjectId idBorderParcel = ServiceCAD.InsertObject(borderParcel); AcDb.Hatch borderParcelHatch = ServiceSimpleElements.CreateHatch(idBorderParcel, true); HatchPolygon hatchParcel = HatchPolygon.GetHatchParcel(); if (hatchParcel != null) { borderParcelHatch.LayerId = ServiceCAD.CreateLayer(settingsDrawing.Plan.FillParcel.Layer); borderParcelHatch.ColorIndex = hatchParcel.ColorIndex; borderParcelHatch.SetHatchPattern(hatchParcel.Pattern.Type, hatchParcel.Pattern.Name); borderParcelHatch.PatternAngle = hatchParcel.Pattern.Angle; borderParcelHatch.PatternSpace = hatchParcel.Pattern.Space; AcDb.ObjectId idborderParcelHatch = ServiceCAD.InsertObject(borderParcelHatch); } else { try { listMissingHatch.Add("Parcel", new HatchPolygon("Parcel", "", 0, PatternHatch.DEFAULT)); CurrentCAD.Editor.WriteMessage("\n<!> Незнайдено штриховка Parcel;"); } catch { } } } // // Lands // AcDb.Polyline2d borderLand; AcDb.ObjectId idLand; AcDb.Hatch hatchLand; AcDb.ObjectId idHatchLand; if (SettingsForm.DisplayFillLand) { foreach (LandPolygon poligon in this.Parcel.Lands) { borderLand = ServiceSimpleElements.CreatePolyline2d(poligon.Points, true); borderLand.LayerId = ServiceCAD.CreateLayer(settingsDrawing.Plan.FillLand.Layer); idLand = ServiceCAD.InsertObject(borderLand); hatchLand = ServiceSimpleElements.CreateHatch(idLand, false); HatchPolygon hatch = HatchPolygon.GetHatchLand(poligon); if (hatch != null) { hatchLand.LayerId = ServiceCAD.CreateLayer(settingsDrawing.Plan.FillLand.Layer); hatchLand.ColorIndex = hatch.ColorIndex; hatchLand.SetHatchPattern(hatch.Pattern.Type, hatch.Pattern.Name); hatchLand.PatternAngle = hatch.Pattern.Angle; hatchLand.PatternSpace = hatch.Pattern.Space; idHatchLand = ServiceCAD.InsertObject(hatchLand); } else { string type = "000.00"; try { type = poligon.FindInfo("CC").Value; } catch { string ci = "*"; string cn = "*"; try { LandInfo infoCI = poligon.FindInfo("CI"); ci = infoCI.Value; } catch { } try { LandInfo infoCN = poligon.FindInfo("CN"); cn = infoCN.Value; } catch { } CurrentCAD.Editor.WriteMessage ("\n<!> Незнайдено поле CC угіддя CI = {0}, CN = {1};", ci, cn); } try { listMissingHatch.Add(type, new HatchPolygon(type, "", 0, PatternHatch.DEFAULT)); CurrentCAD.Editor.WriteMessage ("\n<!> Незнайдено CC = {0};", poligon.FindInfo("CC").Value ); } catch { } } } } // // Limiting // if (SettingsForm.DisplayFillLimiting) { foreach (LandPolygon poligon in this.Parcel.Limiting) { borderLand = ServiceSimpleElements.CreatePolyline2d(poligon.Points, true); borderLand.LayerId = ServiceCAD.CreateLayer(settingsDrawing.Plan.FillLimiting.Layer); idLand = ServiceCAD.InsertObject(borderLand); hatchLand = ServiceSimpleElements.CreateHatch(idLand, false); HatchPolygon hatchLimiting = HatchPolygon.GetHatchLimiting(poligon); if (hatchLimiting != null) { hatchLand.LayerId = ServiceCAD.CreateLayer(settingsDrawing.Plan.FillLimiting.Layer); hatchLand.ColorIndex = hatchLimiting.ColorIndex; hatchLand.SetHatchPattern(hatchLimiting.Pattern.Type, hatchLimiting.Pattern.Name); hatchLand.PatternAngle = hatchLimiting.Pattern.Angle; hatchLand.PatternSpace = hatchLimiting.Pattern.Space; idHatchLand = ServiceCAD.InsertObject(hatchLand); } else { string type = poligon.FindInfo("OK").Value; string name = poligon.FindInfo("OX").Value; try { listMissingHatch.Add((type + name), new HatchPolygon(type, name, 0, PatternHatch.DEFAULT)); CurrentCAD.Editor.WriteMessage ("\n<!> Незнайдено OK = {0}, OX = {1};", poligon.FindInfo("OK").Value, poligon.FindInfo("OX").Value ); } catch { } } } } if (listMissingHatch.Count > 0) { List <HatchPolygon> listForXml = new List <HatchPolygon>(); foreach (KeyValuePair <string, HatchPolygon> hp in listMissingHatch) { listForXml.Add(hp.Value); } listMissingHatch.Clear(); CurrentCAD.Editor.WriteMessage("\n\n<!> Побудова плана ділянки\n<!> Не визначено штриховку: \n"); CurrentCAD.Editor.WriteMessage(ServiceXml.GetStringXml <List <HatchPolygon> >(listForXml)); CurrentCAD.Editor.WriteMessage("\n<!>\n"); } }
private void ComboBoxNumberParcel_SelectedIndexChanged(object sender, EventArgs e) { this.Text = this.comboBoxNumberParcel.SelectedItem.ToString(); this.currentParcel = ServiceIn4.GetParcelForCadarstralNumber (this.currentBlockLand, this.comboBoxNumberParcel.SelectedItem.ToString()); if (!this.idCurrentHatchParcel.IsNull) { ServiceCAD.DeleteObject(this.idCurrentHatchParcel); ServiceCAD.DeleteObjects(this.idNeighborsCurrenParcel); } serviceParcel = new ServiceParcel(this.currentParcel, this.formSettings); AcGe.Point2dCollection pointsCurrentHatchParcel = ServiceSimpleElements.Offset(this.currentParcel.Points, this.offsetBlockLandView); AcDb.ObjectId idPolyline2d = ServiceCAD.InsertObject(ServiceSimpleElements.CreatePolyline2d(pointsCurrentHatchParcel, true)); AcDb.Hatch curHatch = ServiceSimpleElements.CreateHatch(new AcDb.ObjectIdCollection(new AcDb.ObjectId[] { idPolyline2d })); this.idCurrentHatchParcel = ServiceCAD.InsertObject(curHatch); ServiceCAD.DeleteObject(idPolyline2d); // ======================================================= if (this.currentParcel.StakeOutParcelPoints != null) { this.currentParcel.StakeOutParcelPoints.Clear(); } StakeOutParcelPoint stakeOutParcelPoint; this.dataGridView_StakeOut.ClearSelection(); this.dataGridView_StakeOut.Rows.Clear(); int indexPoint = 0; object[] row = new object[2]; foreach (AcGe.Point2d point in this.currentParcel.Points) { indexPoint++; stakeOutParcelPoint = new StakeOutParcelPoint { ScaleDrawing = this.drawingSettings.Scale.Value, Name = indexPoint.ToString(), Coordinates = point }; this.currentParcel.StakeOutParcelPoints.Add(stakeOutParcelPoint); row[0] = false; row[1] = indexPoint.ToString(); this.dataGridView_StakeOut.Rows.Add(row); } SetColPointStationAndOrientationItems(); AutoSearchingStationAndOrientationForAllPoints(); this.dataGridView_StakeOut.Update(); ReLoad_treeViewParcel(); }
/// <summary> /// Створює коллекцію текстових обектів значень данних таблиці обмежень земельної ділянки. /// </summary> /// <param name="parcel">Ділянка, що є вихідною для таблиці.</param> /// <param name="settingTable">Налаштування таблиці.</param> /// <returns> /// Повертає <see cref="T:AcDb.DBObjectCollection"/>, що містить текстові значення данний таблиці обмежень земельної ділянки. /// </returns> internal static AcDb.DBObjectCollection GetDataTableLimiting(LandParcel parcel, SettingTable settingTable) { AcDb.DBObjectCollection objects = new AcDb.DBObjectCollection(); AcDb.MText valueMText; AcGe.Point3d insertPoint; AcDb.Line lineRows; LandPolygon polygonLimiting; double steepRow = settingTable.TextHeight * 6; double heightTable = settingTable.GetHeightCapTable() * -1; List <HatchPolygon> listMissingHatch = new List <HatchPolygon>(); for (int index = 0; index < parcel.Limiting.Count; index++) { polygonLimiting = parcel.Limiting.ToArray()[index]; double colWidth = 0; if (index > 0) { lineRows = new AcDb.Line( new AcGe.Point3d(0, heightTable, 0), new AcGe.Point3d(settingTable.GetWidthTable(), heightTable, 0)); objects.Add(lineRows); } heightTable -= steepRow; foreach (ColumnTable col in settingTable.Columns) { colWidth += col.Width; insertPoint = new AcGe.Point3d(); insertPoint = new AcGe.Point3d(colWidth - col.Width / 2, (heightTable + steepRow / 2), 0); valueMText = new AcDb.MText(); valueMText.Width = col.Width * 0.9; valueMText.TextHeight = settingTable.TextHeight; valueMText.LineSpaceDistance = settingTable.TextHeight * 1.5; valueMText.Attachment = AcDb.AttachmentPoint.MiddleCenter; valueMText.Location = insertPoint; if (col.Format.IndexOf("LegendLimiting") > -1) { AcGe.Point2dCollection pointsHatch = new AcGe.Point2dCollection(new AcGe.Point2d[] { new AcGe.Point2d(insertPoint.X - col.Width / 2 + 2, heightTable + steepRow - 2), new AcGe.Point2d(insertPoint.X - col.Width / 2 + 2, heightTable + 2), new AcGe.Point2d(insertPoint.X - col.Width / 2 + col.Width - 2, heightTable + 2), new AcGe.Point2d(insertPoint.X - col.Width / 2 + col.Width - 2, heightTable + steepRow - 2) }); AcDb.Polyline2d polylineLimiting = ServiceSimpleElements.CreatePolyline2d(pointsHatch, true); AcDb.Hatch hatch = ServiceSimpleElements.CreateHatch(ServiceCAD.InsertObject(polylineLimiting), true); HatchPolygon hatchLimiting = HatchPolygon.GetHatchLimiting(polygonLimiting); if (hatchLimiting != null) { hatch.ColorIndex = hatchLimiting.ColorIndex; hatch.SetHatchPattern(AcDb.HatchPatternType.UserDefined, hatchLimiting.Pattern.Name); hatch.PatternAngle = hatchLimiting.Pattern.Angle; hatch.PatternSpace = hatchLimiting.Pattern.Space; } else { string type = polygonLimiting.FindInfo("OK").Value; string name = polygonLimiting.FindInfo("OX").Value; listMissingHatch.Add(new HatchPolygon(type, name, 0, PatternHatch.DEFAULT)); } objects.Add(hatch); polylineLimiting = ServiceSimpleElements.CreatePolyline2d(pointsHatch, true); objects.Add(polylineLimiting); } else if (col.Format.IndexOf("CodeLimiting") > -1) { valueMText.Contents = polygonLimiting.FindInfo("OK").Value; objects.Add(valueMText); } else if (col.Format.IndexOf("NameLimiting") > -1) { valueMText.Contents = polygonLimiting.FindInfo("OX").Value; objects.Add(valueMText); } else if (col.Format.IndexOf("LegalActsLimiting") > -1) { valueMText.Contents = polygonLimiting.FindInfo("OD").Value; objects.Add(valueMText); } else if (col.Format.IndexOf("AreaLimiting") > -1) { double area = Convert.ToDouble(polygonLimiting.FindInfo("AO").Value.Replace(".", ",")); valueMText.Contents = (area / 10000).ToString("0.0000").Replace(",", ".");; objects.Add(valueMText); } } } if (listMissingHatch.Count > 0) { CurrentCAD.Editor.WriteMessage("\n\nПобудова таблиці омеженнь\n Не визначено штриховку: \n"); CurrentCAD.Editor.WriteMessage(ServiceXml.GetStringXml <List <HatchPolygon> >(listMissingHatch)); } return(objects); }