C3D-WHATLBL · What are the tract bearings? dump labels (read-only) done
Every annotation object within 80ft of A/B boundary, no text filter, with class+layer+text. To see what carries the bearings.
C# payload
// READ-ONLY: what ARE the tract bearings? Dump EVERY annotation-type object whose insertion point is
// within 80' of tract A or B boundary samples — no text filtering. Report class, layer, handle, tract,
// and any readable text. So we see exactly what carries the bearings.
using System;
using System.Linq;
using System.Collections.Generic;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.Civil.ApplicationServices;
using Autodesk.Civil.DatabaseServices;
var db = Db;
var ptsA=new List<Point2d>(); var ptsB=new List<Point2d>();
void SL(List<Point2d> into,Point3d a,Point3d b,int n=20){for(int i=0;i<=n;i++){double t=i/(double)n;into.Add(new Point2d(a.X+(b.X-a.X)*t,a.Y+(b.Y-a.Y)*t));}}
void SA(List<Point2d> into,Arc ar,int n=24){for(int i=0;i<=n;i++){double ang=ar.StartAngle+ar.TotalAngle*(i/(double)n);into.Add(new Point2d(ar.Center.X+ar.Radius*Math.Cos(ang),ar.Center.Y+ar.Radius*Math.Sin(ang)));}}
using (var tr = db.TransactionManager.StartTransaction())
{
var ms=(BlockTableRecord)tr.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(db),OpenMode.ForRead);
foreach(ObjectId id in ms){ var e=tr.GetObject(id,OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
if(e is Polyline pl && string.Equals(e.Layer,"SS-BOUNDARY TRACT B",StringComparison.OrdinalIgnoreCase)){int n=pl.NumberOfVertices;for(int i=0;i<n;i++)SL(ptsB,pl.GetPoint3dAt(i),pl.GetPoint3dAt((i+1)%n));}}
var cdoc=CivilDocument.GetCivilDocument(db);
foreach(ObjectId sid in cdoc.GetSiteIds()){var site=(Site)tr.GetObject(sid,OpenMode.ForRead);
foreach(ObjectId pid in site.GetParcelIds()){var p=(Parcel)tr.GetObject(pid,OpenMode.ForRead);
if(!string.Equals(p.Layer,"SS-BOUNDARY TRACT A",StringComparison.OrdinalIgnoreCase))continue;
var col=new DBObjectCollection();try{p.Explode(col);}catch{}
foreach(Autodesk.AutoCAD.DatabaseServices.DBObject o in col){if(o is Line l)SL(ptsA,l.StartPoint,l.EndPoint);else if(o is Arc ar)SA(ptsA,ar);}}}
Log($"sampleA={ptsA.Count} sampleB={ptsB.Count}");
double dA(Point2d p)=>ptsA.Count>0?ptsA.Min(q=>p.GetDistanceTo(q)):9e9;
double dB(Point2d p)=>ptsB.Count>0?ptsB.Min(q=>p.GetDistanceTo(q)):9e9;
int shown=0;
foreach(ObjectId id in ms)
{
var e=tr.GetObject(id,OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
if(e==null) continue;
string tn=e.GetType().Name;
// annotation-ish only
bool ann = tn=="MText"||tn=="DBText"||tn.EndsWith("Label")||tn.Contains("Label");
if(!ann) continue;
Point2d loc;
try{
if(e is MText m) loc=new Point2d(m.Location.X,m.Location.Y);
else if(e is DBText t) loc=new Point2d(t.Position.X,t.Position.Y);
else { var lbl=(Label)e; loc=new Point2d(lbl.LabelLocation.X,lbl.LabelLocation.Y); }
}catch{ continue; }
double a=dA(loc), b=dB(loc);
if(Math.Min(a,b)>80) continue;
string who = a<=b?"A":"B"; double d=Math.Min(a,b);
string txt=""; if(e is MText mm) txt="'"+mm.Text.Replace("\n"," ")+"'"; else if(e is DBText tt) txt="'"+tt.TextString+"'";
Log($" {who} d={d:0} {tn} @{e.Layer} h={e.Handle} {txt}");
shown++;
}
Log($"annotation objects near tracts: {shown}");
tr.Commit();
}
Result
Log
sampleA=0 sampleB=168 B d=63 MText @SS-BOUNDARY h=20B9B 'STONEWALL TELL ROAD (R/W VARIES)' B d=46 GeneralSegmentLabel @C-ANNO h=20BA6 B d=22 MText @SS-BOUNDARY h=20C36 'NEWBORN DRIVE SW (50' R/W PB 82 PG 117)' B d=63 MText @SS-BOUNDARY LAND LOT h=20CB5 'L.L. 143' B d=29 MText @C-ANNO h=20CCC 'ONE STORY BRICK' B d=33 MText @C-ANNO h=20CCE 'ASPHALT DRIVE' B d=33 MText @C-ANNO h=20CCF 'ASPHALT' B d=39 MText @SS-0-FRAME h=20CD3 'FENCE 2.5' WEST OF PL' B d=38 MText @SS-0-FRAME h=20CD4 'FENCE 12.7' EAST OF PL' B d=29 MText @SS-0-FRAME h=20CD5 'FENCE 7.2' EAST OF PL' B d=37 ParcelSegmentLabel @C-PROP-LINE-TEXT h=20CFD B d=53 GeneralSegmentLabel @SS-0-FRAME h=20E03 B d=0 GeneralSegmentLabel @SS-0-FRAME h=20FB8 B d=49 GeneralSegmentLabel @SS-0-FRAME h=20FB9 B d=39 GeneralSegmentLabel @SS-0-FRAME h=20FBA B d=0 ParcelSegmentLabel @C-PROP-LINE-TEXT h=2103E B d=0 ParcelSegmentLabel @C-PROP-LINE-TEXT h=21078 B d=48 ParcelSegmentLabel @C-PROP-LINE-TEXT h=21079 B d=0 ParcelSegmentLabel @C-PROP-LINE-TEXT h=2107A B d=0 ParcelSegmentLabel @C-PROP-LINE-TEXT h=2107B B d=14 ParcelSegmentLabel @C-PROP-LINE-TEXT h=2107C B d=0 ParcelSegmentLabel @C-PROP-LINE-TEXT h=2107D B d=0 ParcelSegmentLabel @C-PROP-LINE-TEXT h=2107E B d=0 ParcelSegmentLabel @C-PROP-LINE-TEXT h=2107F B d=52 MText @C-ANNO h=210A5 'APPROXIMATE LAND LINE' annotation objects near tracts: 25
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.