← Inbox

C3D-260619-NOTCH · Redline 3 rev - clerk box at page corner, border notched done

Freezes BLOCK_TB2 in the 22X17 C viewport only, redraws the double border as paper-space lines stepping around a 3x3 notch at the top-left page corner, and moves the clerk recording box out to (0,14)-(3,17). Other layouts keep the original block frame.

Script file
C3D-260619-NOTCH.cs
Target
260619 · paper space
Author
claude
Approved
yes · reviewer
Timeout
60s

C# payload

// REDLINE #3 (revised) - move the 3" x 3" clerk recording box to the TRUE PAGE CORNER and
// notch the border out of its way.
//
// The 3x3 now occupies (0,14)-(3,17): hard against the top-left edge of the 22x17 sheet, with no
// frame line running through it. O.C.G.A. 15-6-67(c)(1)(B) wants that space clear.
//
// The existing border is a DOUBLE frame living inside the SS_BLOCK_22X17 block definition
// (outer 0.246..21.754 x 0.261..16.739, inner 0.293..21.711 x 0.305..16.695). Editing the
// definition would change every sheet that uses the block, so instead this affects ONLY 22X17 C:
//   1. BLOCK_TB2 (the frame layer) is frozen in this layout's viewport, hiding the block frame here
//   2. the same double border is redrawn as paper-space lines that step around the notch
//   3. the clerk box is moved out to the page corner
// Every other layout keeps the original block frame untouched.
//
// Idempotent: bails if the redrawn border already exists. Host owns Tx; host regens after commit.
const string LAYOUT = "22X17 C", FRAME = "C-ANNO-FRAME", CLERK = "C-ANNO-CLERK", TBLAYER = "BLOCK_TB2";

var layDict = (DBDictionary)Tx.GetObject(Db.LayoutDictionaryId, OpenMode.ForRead);
var layout  = (Layout)Tx.GetObject(layDict.GetAt(LAYOUT), OpenMode.ForRead);
var ps      = (BlockTableRecord)Tx.GetObject(layout.BlockTableRecordId, OpenMode.ForWrite);
EnsureLayer(FRAME, 7);
EnsureLayer(CLERK, 7);

foreach (ObjectId id in ps)
{
    var e0 = Tx.GetObject(id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
    if (e0 != null && e0.Layer == FRAME) { Log("notched border already present (h=" + e0.Handle + ") - nothing to do"); return; }
}

// 1) freeze the block's frame layer in THIS viewport only
var lt = (LayerTable)Tx.GetObject(Db.LayerTableId, OpenMode.ForRead);
if (lt.Has(TBLAYER))
{
    int done = 0;
    foreach (ObjectId id in ps)
    {
        var vp = Tx.GetObject(id, OpenMode.ForRead) as Viewport;
        if (vp == null) continue;
        var w = (Viewport)Tx.GetObject(id, OpenMode.ForWrite);
        w.FreezeLayersInViewport(new ObjectId[] { lt[TBLAYER] }.GetEnumerator());
        done++;
    }
    Log("froze '" + TBLAYER + "' in " + done + " viewport(s) on this layout only");
}

// 2) redraw the double border, notched
var segs = new (double x1, double y1, double x2, double y2)[] {
    (21.754, 0.261, 21.754, 16.739),
    (0.246, 0.261, 21.754, 0.261),
    (3.0, 16.739, 21.754, 16.739),
    (0.246, 0.261, 0.246, 14.0),
    (21.711, 0.305, 21.711, 16.695),
    (0.293, 0.305, 21.711, 0.305),
    (3.0, 16.695, 21.711, 16.695),
    (0.293, 0.305, 0.293, 14.0),
    (3.0, 14.0, 3.0, 16.739),
    (0.246, 14.0, 3.0, 14.0)
};
foreach (var g in segs)
{
    var l2 = new Line(new Point3d(g.x1, g.y1, 0.0), new Point3d(g.x2, g.y2, 0.0));
    l2.Layer = FRAME;
    ps.AppendEntity(l2);
    Tx.AddNewlyCreatedDBObject(l2, true);
}
Log("redrew border as " + segs.Length + " paper-space lines, notched " +
    3.0 + "x" + 3.0 + " at the top-left");

// 3) move the clerk box out to the page corner
int moved = 0;
foreach (ObjectId id in ps)
{
    var e = Tx.GetObject(id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
    if (e == null || e.Layer != CLERK) continue;
    var w = (Autodesk.AutoCAD.DatabaseServices.Entity)Tx.GetObject(id, OpenMode.ForWrite);
    Extents3d ex; try { ex = w.GeometricExtents; } catch { continue; }
    var pl0 = w as Polyline;
    if (pl0 != null)
    {
        // snap the box exactly to (0,14)-(3,17)
        double dx = 0.0 - ex.MinPoint.X, dy = 14.0 - ex.MinPoint.Y;
        w.TransformBy(Matrix3d.Displacement(new Vector3d(dx, dy, 0)));
    }
    else
    {
        // caption follows the same shift
        double dx = 0.0 - 0.45, dy = 14.0 - 13.55;
        w.TransformBy(Matrix3d.Displacement(new Vector3d(dx, dy, 0)));
    }
    moved++;
}
Log("moved " + moved + " clerk-box entit(ies) to the page corner");

foreach (ObjectId id in ps)
{
    var e = Tx.GetObject(id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
    if (e == null || e.Layer != CLERK) continue;
    var pl1 = e as Polyline;
    if (pl1 == null) continue;
    var ex = pl1.GeometricExtents;
    Log("clerk box now (" + ex.MinPoint.X.ToString("F2") + "," + ex.MinPoint.Y.ToString("F2") + ")-(" +
        ex.MaxPoint.X.ToString("F2") + "," + ex.MaxPoint.Y.ToString("F2") + ")  " +
        (ex.MaxPoint.X-ex.MinPoint.X).ToString("F2") + " x " + (ex.MaxPoint.Y-ex.MinPoint.Y).ToString("F2") + " (verified)");
}

Result

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

Log

froze 'BLOCK_TB2' in 2 viewport(s) on this layout only
redrew border as 10 paper-space lines, notched 3x3 at the top-left
moved 2 clerk-box entit(ies) to the page corner
clerk box now (0.00,14.00)-(3.00,17.00)  3.00 x 3.00 (verified)

Notes

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

No notes yet.