← Inbox

C3D-0178 · Land lot markers: L.L. 3 west, L.L. 4 east of the land lot line [LL-MARKERS] error

Places two double-circle land lot markers straddling the LAND_LOT_LINE line 2FA8F at its midpoint, offset 25 feet each side - L.L. 3 on the west, L.L. 4 on the east. Circle radii follow the drawing existing symbol proportions and the text matches the 4.0 height of the APPROXIMATE LAND LOT LINE annotation. Idempotent and verifies the result.

Script file
C3D-0178.cs
Target
active document · model space
Author
claude
Approved
yes · reviewer
Timeout
240s

C# payload

// Two land lot markers straddling the land lot line: L.L. 3 west, L.L. 4 east.
//
// The line is 2FA8F on layer LAND_LOT_LINE, running due north-south at a constant
// X = 2296402.372 from Y 1279678.207 to 1280597.609 (919.40 ft). Constant X means WEST is the
// smaller X and EAST the larger, so the markers sit at X -/+ an offset either side of it.
//
// Marker form copied from the drawing's existing double-circle symbols (PDF2_E IPF-SET and
// SS-0-FRAME both use a concentric pair r=0.938 / r=1.271): two circles plus "L.L." over the
// number, centred. Scaled up here so it reads at the land-lot line's scale.
//
// Placed at the line's MIDPOINT height, offset 25 ft to each side.
// Idempotent: bails if an L.L. marker already exists on the target layer.
const string LAYER = "LAND_LOT_LINE";
const double R_IN  = 9.38;    // 10x the existing symbol, to match the 4.0-height annotation scale
const double R_OUT = 12.71;
const double TXT_H = 4.0;     // same height as the APPROXIMATE LAND LOT LINE annotation
const double OFFSET = 25.0;   // how far either side of the line

var ms = (BlockTableRecord)Tx.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(Db), OpenMode.ForWrite);
Log("drawing: " + Db.Filename);
EnsureLayer(LAYER, 7);

// find the land lot line by handle, and fall back to the layer if it moved
Line ll = null;
foreach (ObjectId id in ms) {
    var o = Tx.GetObject(id, OpenMode.ForRead);
    if (o.Handle.ToString() == "2FA8F") { ll = o as Line; break; }
}
if (ll == null) {
    foreach (ObjectId id in ms) {
        var l = Tx.GetObject(id, OpenMode.ForRead) as Line;
        if (l != null && l.Layer == LAYER) { ll = l; break; }
    }
}
if (ll == null) { Log("ABORT: land lot line not found"); return; }
Log(String.Format("land lot line [{0}]  {1:F3},{2:F3} -> {3:F3},{4:F3}  len={5:F2}",
    ll.Handle, ll.StartPoint.X, ll.StartPoint.Y, ll.EndPoint.X, ll.EndPoint.Y, ll.Length));

// idempotency
foreach (ObjectId id in ms) {
    var t = Tx.GetObject(id, OpenMode.ForRead) as MText;
    if (t != null && !t.IsErased && t.Layer == LAYER && t.Contents.IndexOf("L.L.") >= 0) {
        Log("an L.L. marker already exists on " + LAYER + " - nothing to do");
        return;
    }
}

// midpoint of the line, and the perpendicular direction
double mx = (ll.StartPoint.X + ll.EndPoint.X) / 2.0;
double my = (ll.StartPoint.Y + ll.EndPoint.Y) / 2.0;
double dx = ll.EndPoint.X - ll.StartPoint.X, dy = ll.EndPoint.Y - ll.StartPoint.Y;
double len = Math.Sqrt(dx*dx + dy*dy);
double px = -dy/len, py = dx/len;          // unit perpendicular
if (px < 0) { px = -px; py = -py; }        // make +perp point EAST (increasing X)

Action<double,double,string> marker = (cx, cy, label) => {
    var c1 = new Circle(new Point3d(cx, cy, 0), Vector3d.ZAxis, R_IN);
    c1.Layer = LAYER; ms.AppendEntity(c1); Tx.AddNewlyCreatedDBObject(c1, true);
    var c2 = new Circle(new Point3d(cx, cy, 0), Vector3d.ZAxis, R_OUT);
    c2.Layer = LAYER; ms.AppendEntity(c2); Tx.AddNewlyCreatedDBObject(c2, true);

    var t = new MText {
        Location   = new Point3d(cx, cy, 0),
        Contents   = "L.L.\P" + label,
        TextHeight = TXT_H,
        Attachment = AttachmentPoint.MiddleCenter,
    };
    t.Layer = LAYER;
    ms.AppendEntity(t); Tx.AddNewlyCreatedDBObject(t, true);
    Log(String.Format("  L.L. {0} at {1:F3},{2:F3}  circles r={3:F2}/{4:F2}", label, cx, cy, R_IN, R_OUT));
};

marker(mx - px*OFFSET, my - py*OFFSET, "3");   // WEST side
marker(mx + px*OFFSET, my + py*OFFSET, "4");   // EAST side

// verify
int circles = 0, texts = 0;
foreach (ObjectId id in ms) {
    var o = Tx.GetObject(id, OpenMode.ForRead);
    var e = o as Autodesk.AutoCAD.DatabaseServices.Entity;
    if (e == null || e.IsErased || e.Layer != LAYER) continue;
    if (o is Circle) circles++;
    var t = o as MText;
    if (t != null && t.Contents.IndexOf("L.L.") >= 0) texts++;
}
Log("");
Log("on " + LAYER + ": " + circles + " circles, " + texts + " L.L. labels (verified)");
Ed.Regen();

Result

Status
error
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260613 - 5030 E Lake Pkwy, Stockbridge, GA 30281, USA\260612-C-Store Sewer As-Built.dwg
Message
Compile error: (64,27): error CS1009: Unrecognized escape sequence
Entities
Duration
21 ms
Civil 3D
25.0.0.0

Notes

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

No notes yet.