public static void DrawSectionLines(string sectionName, int scale = 200)
{
Point3d firstPoint = SelectionUtilities.GetPointFromUser("Pick first section line point");
Point3d secondPoint = SelectionUtilities.GetPointFromUser("Pick second section line point");
Point3d desiredSidePointer = SelectionUtilities.GetPointFromUser("Specify desired side");
double stripeThickness = 0.5 * scale;
int stripeLength = 5 * scale;
//--------------------------------------------------------------------Mandatory variables
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
Transaction tr = db.TransactionManager.StartTransaction();
//--------------------------------------------------------------------Mandatory variables
using (tr)
{
BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
Polyline polyline = new Polyline();
polyline.SetDatabaseDefaults();
polyline.AddVertexAt(0, new Point2d(firstPoint.X, firstPoint.Y), 0, stripeThickness, stripeThickness);
polyline.AddVertexAt(1, new Point2d(firstPoint.X - 5 * scale, firstPoint.Y), 0, stripeThickness, stripeThickness);
polyline.LineWeight = LineWeight.LineWeight060;
polyline.Layer = "0";
btr.AppendEntity(polyline);
tr.AddNewlyCreatedDBObject(polyline, true);
Polyline arrow = new Polyline();
arrow.SetDatabaseDefaults();
arrow.AddVertexAt(0, new Point2d(firstPoint.X - 0.66 * stripeLength, firstPoint.Y - 0.33), 0, 0, stripeThickness * 3);
arrow.AddVertexAt(1, new Point2d(firstPoint.X - 0.66 * stripeLength, firstPoint.Y - 0.33 * stripeLength), 0, 0, 0);
arrow.AddVertexAt(2, new Point2d(firstPoint.X - 0.66 * stripeLength, firstPoint.Y - stripeLength * 1.2), 0, 0, 0);
arrow.LineWeight = LineWeight.LineWeight060;
arrow.Layer = "0";
btr.AppendEntity(arrow);
tr.AddNewlyCreatedDBObject(arrow, true);
MText mtext = new MText();
using (mtext)
{
mtext.Location = arrow.EndPoint;
mtext.TextHeight = ESKDValues.SectionTextHeight * scale;
mtext.Attachment = AttachmentPoint.BottomRight;
mtext.Contents = sectionName;
mtext.Layer = "0";
btr.AppendEntity(mtext);
tr.AddNewlyCreatedDBObject(mtext, true);
}
Polyline mirroredPolyline = (Polyline)polyline.Clone();
Polyline mirroredArrow = (Polyline)arrow.Clone();
MText mirroredMText = (MText)mtext.Clone();
Line auxLine = new Line(firstPoint, secondPoint);
Point3d mlFirstPoint3D = new Point3d((firstPoint.X + secondPoint.X) / 2, 10, 0);
Point3d mlSecondPoint3D = new Point3d((firstPoint.X + secondPoint.X) / 2, -10, 0);
Line3d mirrorLine = new Line3d(mlFirstPoint3D, mlSecondPoint3D);
mirroredPolyline.TransformBy(Matrix3d.Mirroring(mirrorLine));
btr.AppendEntity(mirroredPolyline);
tr.AddNewlyCreatedDBObject(mirroredPolyline, true);
mirroredArrow.TransformBy(Matrix3d.Mirroring(mirrorLine));
btr.AppendEntity(mirroredArrow);
tr.AddNewlyCreatedDBObject(mirroredArrow, true);
mirroredMText.TransformBy(Matrix3d.Mirroring(mirrorLine));
btr.AppendEntity(mirroredMText);
tr.AddNewlyCreatedDBObject(mirroredMText, true);
tr.Commit();
}
}