← Inbox

C3D-0333 · 17X11: 3x3 clerk box hard in the page corner (0,8)-(3,11), border cut back [C3D-NOTCH17B] done

Redo. The box now measures from the PAGE corner (0,11), not the border - sheet 0..3 / 8..11, block -16.670..-13.670 / 7.670..10.670. Cuts both border rings back to the box edges (left verticals stop at y 7.670, top horizontals start at x -13.670) and draws the 3x3 box on BLOCK_TB2 at the true page corner. Viewport and title panel untouched.

Script file
C3D-0333.cs
Target
260714 - 285 Huckaby Rd R2.dwg · paper space
Author
claude
Approved
yes · auto-auth
Timeout
120s

C# payload

// 3x3 clerk box in the TOP-LEFT of the 17X11 sheet, measured from the PAGE CORNER (0,11),
// not from the border. Cut out of SS_BLOCK_17X11 on BLOCK_TB2.
//
// Block insert (16.670, 0.330):  sheet = block + (16.670, 0.330)
// Page corner (0,11) sheet  ->  block (-16.670, 10.670)
// Box occupies sheet 0..3 / 8..11  ->  block -16.670..-13.670 / 7.670..10.670
// So both rings are cut at block x = -13.670 and block y = 7.670. The border sits INSIDE the
// box's footprint on the left and top, so those runs are removed from the corner entirely and
// the notch closes at the box edges.
const string BLK   = "SS_BLOCK_17X11";
const string LAYER = "BLOCK_TB2";
const double NW = 3.0, NH = 3.0;
const double TOL = 0.02;

// page corner in block coords
const double PCX = -16.670, PCY = 10.670;
double xN = PCX + NW;          // -13.670  right edge of the box
double yN = PCY - NH;          //   7.670  bottom edge of the box

Log("drawing: " + Db.Filename);
Log(string.Format("box: sheet (0,{0:F2})-({1:F2},{2:F2})   block x {3:F4}..{4:F4}  y {5:F4}..{6:F4}",
    11.0-NH, NW, 11.0, PCX, xN, yN, PCY));

var bt = (BlockTable)Tx.GetObject(Db.BlockTableId, OpenMode.ForRead);
if (!bt.Has(BLK)) { Log("block " + BLK + " missing"); return; }
var bd = (BlockTableRecord)Tx.GetObject(bt[BLK], OpenMode.ForWrite);

// bail if already notched at the new x
foreach (ObjectId eid in bd) {
    var l = Tx.GetObject(eid, OpenMode.ForRead) as Line;
    if (l == null || l.Length > NH + TOL) continue;
    if (Math.Abs(l.StartPoint.X - xN) < TOL && Math.Abs(l.EndPoint.X - xN) < TOL) {
        Log("ALREADY NOTCHED at x=" + xN.ToString("F4") + " - nothing changed"); return;
    }
}

double[,] ring = {
    { -16.3400, 0.0000, 0.0000, 10.3400 },      // outer  xL, yB, xR, yT
    { -16.2967, 0.0407, -0.0416, 10.2996 }      // inner
};

int cut = 0, added = 0;
var newLines = new List<Line>();

for (int r = 0; r < 2; r++) {
    double xL = ring[r,0], yT = ring[r,3];
    Log(string.Format("--- ring {0}: left x={1:F4}  top y={2:F4}", r==0?"OUTER":"INNER", xL, yT));

    foreach (ObjectId eid in bd) {
        var probe = Tx.GetObject(eid, OpenMode.ForRead) as Line;
        if (probe == null) continue;
        if (!probe.Layer.Equals(LAYER, StringComparison.OrdinalIgnoreCase)) continue;
        var s = probe.StartPoint; var e = probe.EndPoint;

        bool isLeft = Math.Abs(s.X - xL) < TOL && Math.Abs(e.X - xL) < TOL &&
                      (Math.Abs(s.Y - yT) < TOL || Math.Abs(e.Y - yT) < TOL);
        bool isTop  = Math.Abs(s.Y - yT) < TOL && Math.Abs(e.Y - yT) < TOL &&
                      (Math.Abs(s.X - xL) < TOL || Math.Abs(e.X - xL) < TOL);
        if (!isLeft && !isTop) continue;

        var w = (Line)Tx.GetObject(eid, OpenMode.ForWrite);
        if (isLeft) {
            // this vertical lies inside the box footprint (xL is right of PCX); cut it at yN
            if (Math.Abs(w.StartPoint.Y - yT) < TOL) w.StartPoint = new Point3d(w.StartPoint.X, yN, w.StartPoint.Z);
            else                                     w.EndPoint   = new Point3d(w.EndPoint.X,   yN, w.EndPoint.Z);
        } else {
            // top horizontal starts at the box's right edge
            if (Math.Abs(w.StartPoint.X - xL) < TOL) w.StartPoint = new Point3d(xN, w.StartPoint.Y, w.StartPoint.Z);
            else                                     w.EndPoint   = new Point3d(xN, w.EndPoint.Y,   w.EndPoint.Z);
        }
        cut++;
        var back = (Line)Tx.GetObject(eid, OpenMode.ForRead);
        Log(string.Format("   {0} [{1}] -> ({2:F4},{3:F4})-({4:F4},{5:F4})",
            isLeft?"LEFT ":"TOP  ", back.Handle,
            back.StartPoint.X, back.StartPoint.Y, back.EndPoint.X, back.EndPoint.Y));
    }
}

// the box itself, on the page corner: 3 sides drawn (the two page edges need no line)
// right side, full height of the box; bottom, full width of the box
var v = new Line(new Point3d(xN, PCY, 0), new Point3d(xN, yN, 0));
var h = new Line(new Point3d(xN, yN, 0), new Point3d(PCX, yN, 0));
// and the two page-edge sides so the box reads as a closed box
var vl = new Line(new Point3d(PCX, PCY, 0), new Point3d(PCX, yN, 0));
var ht = new Line(new Point3d(PCX, PCY, 0), new Point3d(xN, PCY, 0));
newLines.Add(v); newLines.Add(h); newLines.Add(vl); newLines.Add(ht);

foreach (var ln in newLines) {
    ln.Layer = LAYER;
    bd.AppendEntity(ln);
    Tx.AddNewlyCreatedDBObject(ln, true);
    added++;
    var back = (Line)Tx.GetObject(ln.ObjectId, OpenMode.ForRead);
    Log(string.Format("   BOX  [{0}] ({1:F4},{2:F4})-({3:F4},{4:F4}) len={5:F4}",
        back.Handle, back.StartPoint.X, back.StartPoint.Y,
        back.EndPoint.X, back.EndPoint.Y, back.Length));
}

Log("");
Log(string.Format("cut {0} border lines, drew {1} box lines", cut, added));
Log(string.Format("box: sheet (0.00,{0:F2}) to ({1:F2},11.00) - hard in the page corner", 11.0-NH, NW));
Ed.Regen();

Result

Status
success
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260714 - 285 Huckaby Rd, Brooks, GA 30205, USA\260714 - 285 Huckaby Rd R2.dwg
Message
Executed C3D-0333 (0 entities touched).
Entities
Duration
473 ms
Civil 3D
25.0.0.0

Log

drawing: C:\Users\sanja\OneDrive\_SurveyDisco\260714 - 285 Huckaby Rd, Brooks, GA 30205, USA\260714 - 285 Huckaby Rd R2.dwg
box: sheet (0,8.00)-(3.00,11.00)   block x -16.6700..-13.6700  y 7.6700..10.6700
--- ring OUTER: left x=-16.3400  top y=10.3400
   TOP   [21078] -> (-13.6700,10.3400)-(0.0000,10.3400)
   LEFT  [2108D] -> (-16.3400,7.6700)-(-16.3400,0.0000)
--- ring INNER: left x=-16.2967  top y=10.2996
   TOP   [21077] -> (-13.6700,10.2996)-(-0.0416,10.2996)
   LEFT  [21086] -> (-16.2987,7.6700)-(-16.2967,0.0407)
   BOX  [21F16] (-13.6700,10.6700)-(-13.6700,7.6700) len=3.0000
   BOX  [21F17] (-13.6700,7.6700)-(-16.6700,7.6700) len=3.0000
   BOX  [21F18] (-16.6700,10.6700)-(-16.6700,7.6700) len=3.0000
   BOX  [21F19] (-16.6700,10.6700)-(-13.6700,10.6700) len=3.0000

cut 4 border lines, drew 4 box lines
box: sheet (0.00,8.00) to (3.00,11.00) - hard in the page corner

Notes

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

No notes yet.