C3DO-260623 · Draw 261103 plat calls from point 166 done
Draws the four plat calls exactly as written (N17-26-32W 58.84, N72-33-28E 158.85, S17-26-32E 109.03, N89-54-31W 166.59) from the SW corner on point 166, closed when the record closes, on C-PROP-LINE, with bearing and distance labels on C-PROP-LINE-TEXT.
C# payload
// 261103: draw the plat calls exactly as written (user: "always use the deed or plat"), from the SW corner on point 166.
// Open line string: the record calls do not close, so no closing segment is added. Labels: bearing outside, distance inside.
const string LAYER = "C-PROP-LINE";
const string TLAYER = "C-PROP-LINE-TEXT";
var CALLS = new (char ns, int d, int m, int s, char ew, double dist, string label)[] {
('N', 17, 26, 32, 'W', 58.84, "N17%%d26'32\"W"),
('N', 72, 33, 28, 'E', 158.85, "N72%%d33'28\"E"),
('S', 17, 26, 32, 'E', 109.03, "S17%%d26'32\"E"),
('N', 89, 54, 31, 'W', 166.59, "N89%%d54'31\"W"),
};
var ms = (BlockTableRecord)Tx.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(Db), OpenMode.ForRead);
CogoPoint p166 = null;
foreach (ObjectId id in ms) { var cp = Tx.GetObject(id, OpenMode.ForRead) as CogoPoint; if (cp != null && cp.PointNumber == 166) p166 = cp; }
if (p166 == null) throw new System.Exception("point 166 not found");
var start = new Point2d(p166.Easting, p166.Northing);
Log("anchor: point 166 \"" + p166.RawDescription + "\" E=" + start.X.ToString("F3") + " N=" + start.Y.ToString("F3"));
// idempotent: skip if a polyline on the layer already starts at point 166
foreach (ObjectId id in ms) {
var ex = Tx.GetObject(id, OpenMode.ForRead) as Polyline;
if (ex != null && ex.Layer == LAYER && ex.NumberOfVertices >= 4 && ex.GetPoint2dAt(0).GetDistanceTo(start) < 0.001) { Log("already drawn: " + ex.Handle + " - nothing changed"); return; }
}
EnsureLayer(LAYER); EnsureLayer(TLAYER);
double r = Math.PI / 180.0;
var pts = new List<Point2d> { start };
foreach (var c in CALLS) {
double a = (c.d + c.m / 60.0 + c.s / 3600.0) * r;
double dn = c.dist * Math.Cos(a) * (c.ns == 'N' ? 1 : -1);
double de = c.dist * Math.Sin(a) * (c.ew == 'E' ? 1 : -1);
var last = pts[pts.Count - 1];
pts.Add(new Point2d(last.X + de, last.Y + dn));
}
var miss = pts[pts.Count - 1] - start;
bool closes = miss.Length < 0.01;
var pl = new Polyline();
int nv = closes ? pts.Count - 1 : pts.Count;
for (int i = 0; i < nv; i++) pl.AddVertexAt(i, pts[i], 0, 0, 0);
pl.Closed = closes;
Append(pl, LAYER);
Log("polyline " + pl.Handle + " on " + LAYER + ", closed=" + closes + ", length " + pl.Length.ToString("F2") + "'" + (closes ? ", area " + pl.Area.ToString("F1") + " sq ft (" + (pl.Area / 43560.0).ToString("F3") + " ac)" : "") + ", misclosure " + miss.Length.ToString("F3") + "' (dE " + miss.X.ToString("F3") + ", dN " + miss.Y.ToString("F3") + ")");
string[] names = { "SW (pt 166)", "NW", "NE", "SE", "end of 4th call" };
for (int i = 0; i < pts.Count; i++) Log(" " + names[i] + ": E=" + pts[i].X.ToString("F3") + " N=" + pts[i].Y.ToString("F3"));
// labels: traverse runs clockwise, so outside is the left side of travel
for (int i = 0; i < CALLS.Length; i++) {
var a = pts[i]; var b = pts[i + 1];
var dir = (b - a).GetNormal();
var left = new Vector2d(-dir.Y, dir.X);
var mid = new Point2d((a.X + b.X) / 2, (a.Y + b.Y) / 2);
double ang = Math.Atan2(dir.Y, dir.X);
if (ang > Math.PI / 2 || ang <= -Math.PI / 2) ang += Math.PI;
for (int k = 0; k < 2; k++) {
var at = mid + left * (k == 0 ? 3.0 : -3.0);
var t = new MText();
t.TextHeight = 3.0;
t.Attachment = AttachmentPoint.MiddleCenter;
t.Location = new Point3d(at.X, at.Y, 0);
t.Rotation = ang;
t.Contents = k == 0 ? CALLS[i].label : CALLS[i].dist.ToString("F2") + "'";
Append(t, TLAYER);
}
}
Log("labels: " + (CALLS.Length * 2) + " on " + TLAYER);
Ed.Regen();Result
Log
anchor: point 166 "IPF 1\2 RB CAP SELLER RLS 2308" E=2271928.908 N=1283512.645 polyline 22307 on C-PROP-LINE, closed=True, length 493.31', area 13333.1 sq ft (0.306 ac), misclosure 0.002' (dE 0.000, dN -0.002) SW (pt 166): E=2271928.908 N=1283512.645 NW: E=2271911.271 N=1283568.779 NE: E=2272062.817 N=1283616.393 SE: E=2272095.498 N=1283512.377 end of 4th call: E=2271928.908 N=1283512.642 labels: 8 on C-PROP-LINE-TEXT
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.