//Создание свободной ординаты
[CommandMethod("DrawTableGidroOrdinate", CommandFlags.UsePickSet)]
public static void DrawTableGidroOrdinate()
{
//Получаем ссылки на документ
AcadMain.AccessToDocument AcadDoc = new AcadMain.AccessToDocument();
Database db = AcadDoc.DBase;
//экземпляр формы
DrawTableGidroOrdinateForm drawTableGidroOrdinateForm = new DrawTableGidroOrdinateForm();
drawTableGidroOrdinateForm.ShowDialog();
if (drawTableGidroOrdinateForm.ButtonWasClicked != false)
{
//Параметры с формы исходной
double dblpiketOrdinate = PKtoMT(drawTableGidroOrdinateForm.TextBoxText(1));
string strPiketOrdinate = drawTableGidroOrdinateForm.TextBoxText(2);
//Контрольные параметры для построение ординаты
InfoDataGidro(out double scaleX, out double scaleY, out double infoX, out double infoY, out double Mark, out string Piket,out string handle);
using (Transaction tr = db.TransactionManager.StartTransaction())
{
double dblPiket = PKtoMT(Piket);
TableGidroTest tableGidroTest = new TableGidroTest();
//Ссылка на слои
TableLayers TableLayer = new TableLayers();
TableLayer.PreparationLayer();
//Открываем таблицу блоков на запись
BlockTable bt = tr.GetObject(db.BlockTableId, OpenMode.ForWrite) as BlockTable;
//Создаем новое определение блока, задаем ему имя
BlockTableRecord btr = tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
//Запоминание текущего слоя для возврата к нему
string CurrentLayer = TableLayer.CurrentLayerData();
//Слой таблички
TableLayer.ActiveLayerSetup(TableLayers.layerGI);
//Пересчет координат
infoX = Math.Round(infoX + (dblpiketOrdinate - dblPiket) * scaleX / 1000, 2);
; //Рисование ординат
Line line = new Line(new Point3d( infoX,
infoY - tableGidroTest.HeightMoveAbs - tableGidroTest.HeightTable(0),
0),
new Point3d( infoX,
infoY - tableGidroTest.HeightMoveAbs + 10000,
0));
ObjectId newidPoly = db.GetObjectId(false, new Handle(Convert.ToInt64(handle)), 0);
MessageBox.Show(handle.ToString(), "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning);
MessageBox.Show(newidPoly.ToString(), "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning);
Polyline localPoly = tr.GetObject(newidPoly, OpenMode.ForRead) as Polyline;
//MessageBox.Show((typeof().ToString(), "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning);
//MessageBox.Show(points[0].X.ToString(), "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning);
Point3dCollection points = new Point3dCollection();
line.IntersectWith(localPoly, Intersect.OnBothOperands, points, IntPtr.Zero, IntPtr.Zero);
MessageBox.Show(points[0].X.ToString(), "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning);
MessageBox.Show(points[0].Y.ToString(), "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning);
btr.AppendEntity(line);
tr.AddNewlyCreatedDBObject(line, true);
//Создаем однострочный текстовый объект - пикет
DBText Text = new DBText
{
Height = heightTextOrdinate,
Position = new Point3d(infoX - heightTextOrdinate / 2 - deltaTextOrdinate, infoY - tableGidroTest.HeightMoveAbs + deltaTextOrdinate, 0),
TextString = MTtoPK(dblpiketOrdinate) + " " + strPiketOrdinate,
HorizontalMode = TextHorizontalMode.TextLeft,
VerticalMode = TextVerticalMode.TextVerticalMid,
AlignmentPoint = new Point3d(infoX - heightTextOrdinate / 2 - deltaTextOrdinate, infoY - tableGidroTest.HeightMoveAbs + deltaTextOrdinate, 0),
Rotation = Math.PI / 2
};
btr.AppendEntity(Text);
tr.AddNewlyCreatedDBObject(Text, true);
//Создаем однострочный текстовый объект - отметка
Text = new DBText
{
Height = heightTextOrdinate,
Position = new Point3d(infoX - heightTextOrdinate / 2 - deltaTextOrdinate, infoY - tableGidroTest.HeightMoveAbs + deltaTextOrdinate - tableGidroTest.HeightTable(0), 0),
TextString = MTtoPK(dblpiketOrdinate),
HorizontalMode = TextHorizontalMode.TextLeft,
VerticalMode = TextVerticalMode.TextVerticalMid,
AlignmentPoint = new Point3d(infoX - heightTextOrdinate / 2 - deltaTextOrdinate, infoY - tableGidroTest.HeightMoveAbs + deltaTextOrdinate - tableGidroTest.HeightTable(0), 0),
Rotation = Math.PI / 2
};
btr.AppendEntity(Text);
tr.AddNewlyCreatedDBObject(Text, true);
TableLayer.ActiveLayerSetup(CurrentLayer);
tr.Commit();
}
}
}