← Inbox

C3D-UPD619 · Tract B anchored to A + road text inline on CL done

Re-anchor B sides to Tract A corners; place road label on the centerline

Script file
C3D-UPD619.cs
Target
active document · model space
Author
claude
Approved
yes · claude (session)
Timeout
60s

C# payload

// Update 1: re-anchor Tract B's two sides to Tract A (SE corner for road frontage, SW for west line),
// extending SOUTH into B. Update 2: place road text inline ON the CL centerline.
var bt = (BlockTable)Tx.GetObject(Db.BlockTableId, OpenMode.ForRead);
var ms = (BlockTableRecord)Tx.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
double d2r = System.Math.PI / 180.0;

// find Tract A (closed polyline on C-PROP-LINE); SW=vertex0, SE=vertex3
Polyline tractA = null;
foreach (ObjectId id in ms) { var e = Tx.GetObject(id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity; if (e is Polyline p && p.Closed && p.Layer == "C-PROP-LINE") { tractA = p; break; } }
if (tractA == null) { Log("Tract A not found — aborting"); return; }
var A_SW = tractA.GetPoint2dAt(0);
var A_SE = tractA.GetPoint2dAt(3);
Log($"Tract A anchor: SW=({A_SW.X:F2},{A_SW.Y:F2}) SE=({A_SE.X:F2},{A_SE.Y:F2})");

// erase the old floating B lines (len ~700.98 / ~734.86 on C-PROP-LINE) + old road text
var kill = new List<ObjectId>();
foreach (ObjectId id in ms) {
    var e = Tx.GetObject(id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
    if (e is Line ln && ln.Layer == "C-PROP-LINE") { double L = ln.Length; if (System.Math.Abs(L - 700.98) < 1.0 || System.Math.Abs(L - 734.86) < 1.0) kill.Add(id); }
    if (e is MText mt && mt.Layer == "C-ANNO" && (mt.Contents ?? "").ToUpperInvariant().Contains("STONEWALL")) kill.Add(id);
}
foreach (var id in kill) ((Autodesk.AutoCAD.DatabaseServices.Entity)Tx.GetObject(id, OpenMode.ForWrite)).Erase();
Log($"erased {kill.Count} old entities (floating B lines + old road label)");

void PL(Point2d a, Point2d b, string layer) { var l = new Line(new Point3d(a.X, a.Y, 0), new Point3d(b.X, b.Y, 0)); l.Layer = layer; ms.AppendEntity(l); Tx.AddNewlyCreatedDBObject(l, true); }

// road frontage: from A_SE, S13-41-11W 734.86 (colinear continuation of A's east line, south)
var roadEnd = new Point2d(A_SE.X - 734.86 * System.Math.Sin(13.686389 * d2r), A_SE.Y - 734.86 * System.Math.Cos(13.686389 * d2r));
PL(A_SE, roadEnd, "C-PROP-LINE");
// west line: from A_SW, S02-06-04W 700.98
var westEnd = new Point2d(A_SW.X - 700.98 * System.Math.Sin(2.101111 * d2r), A_SW.Y - 700.98 * System.Math.Cos(2.101111 * d2r));
PL(A_SW, westEnd, "C-PROP-LINE");
Log("Tract B: road frontage + west line re-anchored to Tract A, extending south");

// road text inline on the CL centerline (rotate to local direction, sit on the line)
Polyline cl = null;
foreach (ObjectId id in ms) { var e = Tx.GetObject(id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity; if (e is Polyline p && p.Layer == "SS-V-ROAD-CNTR") { cl = p; break; } }
if (cl != null) {
    double mid = cl.Length / 2.0;
    var pm = cl.GetPointAtDist(mid);
    var pa = cl.GetPointAtDist(System.Math.Max(0, mid - 15));
    var pb = cl.GetPointAtDist(System.Math.Min(cl.Length, mid + 15));
    double rot = System.Math.Atan2(pb.Y - pa.Y, pb.X - pa.X);
    if (rot > System.Math.PI / 2 || rot < -System.Math.PI / 2) rot += System.Math.PI; // keep upright
    var mt = new MText { Location = new Point3d(pm.X, pm.Y, 0), Contents = "STONEWALL TELL ROAD", TextHeight = 8, Rotation = rot, Attachment = AttachmentPoint.MiddleCenter };
    mt.Layer = "C-ANNO"; ms.AppendEntity(mt); Tx.AddNewlyCreatedDBObject(mt, true);
    Log($"road text placed inline on CL at ({pm.X:F1},{pm.Y:F1}) rot={rot / d2r:F1}deg");
} else Log("no CL centerline found for text");
Log("Updates complete.");

Result

Status
success
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260619 - 3625 Stonewall Tell Rd, Atlanta, GA 30349, USA\260619 - 3625 Stonewall Tell Rd.dwg
Message
Executed C3D-UPD619 (0 entities touched).
Entities
Duration
541 ms
Civil 3D
25.0.0.0

Log

Tract A anchor: SW=(2166566.93,1330683.97) SE=(2166766.60,1330673.01)
erased 3 old entities (floating B lines + old road label)
Tract B: road frontage + west line re-anchored to Tract A, extending south
road text placed inline on CL at (2166837.2,1330495.6) rot=77.1deg
Updates complete.

Notes

What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.

No notes yet.