using CAD_DBS = Autodesk.AutoCAD.DatabaseServices;
using CAD_GEO = Autodesk.AutoCAD.Geometry;
using CAD_APS = Autodesk.AutoCAD.ApplicationServices;
using CIV_APS = Autodesk.Civil.ApplicationServices;
...
CAD_APS.Document doc = CAD_APS.Application.DocumentManager.MdiActiveDocument;
CAD_DBS.Database db = doc.Database;
CIV_APS.CivilDocument civ_doc = CIV_APS.CivilDocument.GetCivilDocument(db);
CAD_DBS.ObjectIdCollection alignColl = civ_doc.GetAlignmentIds();
...
List<CAD_DBS.Entity> ents = new List<CAD_DBS.Entity>();
// Точка в плане, которая лежит на трассе
CAD_GEO.Point3d pntPlan
...
using (CAD_DBS.Transaction tr = db.TransactionManager.StartTransaction())
{
foreach (CAD_DBS.ObjectId alignId in alignColl)
{
CIV_DBS.Alignment trs = (CIV_DBS.Alignment)tr.GetObject(alignId, CAD_DBS.OpenMode.ForRead);
try
{
// Расстояние в профиле по точке в плане
double dist = trs.GetDistAtPoint(pntPlan);
// Цикл по видам профиля для трассы
ObjectIdCollection ids = trs.GetProfileViewIds();
foreach (ObjectId id in ids)
{
CIV_DBS.ProfileView pv = tr.GetObject(id, CAD_DBS.OpenMode.ForRead) as CIV_DBS.ProfileView;
if (pv != null)
{
try {
MY_SKV skv = kkk[Convert.ToInt16(NUM) - 1];
double x = 0.0, y = 0.0;
pv.FindXYAtStationAndElevation(dist, skv.Ustie, ref x, ref y);
CAD_DBS.Entity e = (CAD_DBS.Entity)skv.blkref.Clone();
(e as CAD_DBS.BlockReference).Position = new CAD_GEO.Point3d(x, y - 100, 0);
ents.Add(e);
}
catch { }
}
}
}
catch (System.Exception ex )
{
MessageBox.Show(ex.Message); // ВЫВОД ТЕСТОВОГО СООБЩЕНИЯ ТЕКСТА ИСКЛЮЧЕНИЯ
}
}
}