← Inbox

C3D-0334 · 17X11: redo the notch - C3D-0332's script with the notch measured from the page corner [C3D-NOTCH17C] done

C3D-0333 was wrong: it drew a free-standing 4-line box outside both border rings, leaving the border stubs disconnected. This is C3D-0332's script (which came out right) with ONE change - the notch edges are x=-13.670 / y=7.670 measured from the page corner instead of from each ring's own corner. Both rings step around the notch and stay closed. Viewport and title panel untouched.

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

C# payload

// 3x3 clerk box, TOP-LEFT of the 17X11 sheet, cut out of the SS_BLOCK_17X11 border.
//
// This is C3D-0332's script (which came out right) with ONE change: the notch edges are
// measured from the PAGE CORNER instead of from each ring's own corner, so the box reaches
// the page edge rather than starting at the border.
//
// Block insert (16.670, 0.330):  sheet = block + (16.670, 0.330)
// Page corner (0,11) sheet -> block (-16.670, 10.670)
// Notch edges, both rings:  x = -16.670 + 3 = -13.670    y = 10.670 - 3 = 7.670
//
// Each ring: shorten its left vertical to stop at yN, shorten its top horizontal to start at xN,
// then add the two lines that close THAT ring around the notch.
const string BLK   = "SS_BLOCK_17X11";
const string LAYER = "BLOCK_TB2";
const double NW = 3.0, NH = 3.0;
const double TOL = 0.02;

const double PCX = -16.670, PCY = 10.670;   // page corner in block coords
double xN = PCX + NW;                        // -13.670
double yN = PCY - NH;                        //   7.670

Log("drawing: " + Db.Filename);
Log(string.Format("notch edges: x={0:F4}  y={1:F4}   (page corner {2:F3},{3:F3})", xN, yN, PCX, 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);

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

// guard: bail if a previous run already notched at this x
foreach (ObjectId eid in bd) {
    var l = Tx.GetObject(eid, OpenMode.ForRead) as Line;
    if (l == null) continue;
    if (Math.Abs(l.StartPoint.X - xN) < TOL && Math.Abs(l.EndPoint.X - xN) < TOL) {
        Log("ALREADY NOTCHED - a vertical already sits at x=" + xN.ToString("F4"));
        Log("nothing changed"); return;
    }
}

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

for (int r = 0; r < 2; r++) {
    double xL = ring[r,0], yB = ring[r,1], xR = ring[r,2], yT = ring[r,3];
    Log(string.Format("--- ring {0}: x {1:F4}..{2:F4}  y {3:F4}..{4:F4}   notch to ({5:F4},{6:F4})",
        r == 0 ? "OUTER" : "INNER", xL, yB, xR, yT, xN, yN));

    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;

        // LEFT VERTICAL of this ring: both x at xL, spanning to the top
        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);
        // TOP HORIZONTAL of this ring: both y at yT, reaching the left edge
        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) {
            // keep the end that is NOT at the top; the top end drops to 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 {
            // keep the end that is NOT at the left edge; the left end moves right to xN
            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);
        }
        shortened++;
        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));
    }

    // close the notch for THIS ring: vertical down its right side to yN, horizontal across to xL
    var v = new Line(new Point3d(xN, yT, 0), new Point3d(xN, yN, 0));
    var h = new Line(new Point3d(xN, yN, 0), new Point3d(xL, yN, 0));
    v.Layer = LAYER; h.Layer = LAYER;
    newLines.Add(v); newLines.Add(h);
}

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

Log("");
Log(string.Format("shortened {0} border lines, added {1} closing lines", shortened, added));
Log(string.Format("clerk box is the empty {0:F2} x {1:F2} at sheet (0.000,{2:F3})-({3:F3},11.000)",
    NW, NH, 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-0334 (0 entities touched).
Entities
Duration
481 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
notch edges: x=-13.6700  y=7.6700   (page corner -16.670,10.670)
--- ring OUTER: x -16.3400..0.0000  y 0.0000..10.3400   notch to (-13.6700,7.6700)
   TOP   [21078] -> (-13.6700,10.3400)-(0.0000,10.3400)
   LEFT  [2108D] -> (-16.3400,7.6700)-(-16.3400,0.0000)
--- ring INNER: x -16.2967..0.0407  y -0.0416..10.2996   notch to (-13.6700,7.6700)
   TOP   [21077] -> (-13.6700,10.2996)-(-0.0416,10.2996)
   LEFT  [21086] -> (-16.2987,7.6700)-(-16.2967,0.0407)
   NEW  [21F21] (-13.6700,10.3400)-(-13.6700,7.6700) len=2.6700 layer=BLOCK_TB2
   NEW  [21F22] (-13.6700,7.6700)-(-16.3400,7.6700) len=2.6700 layer=BLOCK_TB2
   NEW  [21F23] (-13.6700,10.2996)-(-13.6700,7.6700) len=2.6296 layer=BLOCK_TB2
   NEW  [21F24] (-13.6700,7.6700)-(-16.2967,7.6700) len=2.6267 layer=BLOCK_TB2

shortened 4 border lines, added 4 closing lines
clerk box is the empty 3.00 x 3.00 at sheet (0.000,8.000)-(3.000,11.000)

Notes

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

No notes yet.