C3D-0332 · 17X11: notch the SS_BLOCK_17X11 border for a 3x3 clerk box, top-left [C3D-NOTCH17] done
Edits the SS_BLOCK_17X11 block definition on layer BLOCK_TB2. For BOTH border rings (outer -16.34..0 / 0..10.34 and inner -16.2967..-0.0416 / 0.0407..10.2996): shortens the left vertical to stop 3in below the top, shortens the top horizontal to start 3in right of the left edge, and adds the two lines that close the notch. Leaves the viewport, the title panel and every other layout alone. Idempotent - bails if a notch vertical already exists. Verifies by reading each line back.
C# payload
// 3x3 clerk box in the TOP-LEFT of the 17X11 sheet, cut out of the SS_BLOCK_17X11 border.
//
// Block insert is at (16.670, 0.330) with the geometry in negative x, so
// sheet = block + (16.670, 0.330) -> block = sheet - (16.670, 0.330)
// The border is doubled:
// outer x -16.3400 .. 0.0000 y 0.0000 .. 10.3400
// inner x -16.2967 .. -0.0416 y 0.0407 .. 10.2996
// Top-left of the sheet is block (-16.34, +10.34) for the outer ring.
//
// Each ring: shorten its left vertical to stop 3in below the top, shorten its top horizontal to
// start 3in right of the left edge, then add the two lines that close 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;
Log("drawing: " + Db.Filename);
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);
// the two rings, from the geometry read in C3D-0331
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 this block
foreach (ObjectId eid in bd) {
var l = Tx.GetObject(eid, OpenMode.ForRead) as Line;
if (l == null) continue;
double xNotchOuter = -16.3400 + NW;
if (Math.Abs(l.StartPoint.X - xNotchOuter) < TOL && Math.Abs(l.EndPoint.X - xNotchOuter) < TOL) {
Log("ALREADY NOTCHED - a vertical already sits at the notch edge x=" + xNotchOuter.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];
double xN = xL + NW; // right edge of the notch
double yN = yT - NH; // bottom edge of the notch
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: vertical down its right side, horizontal across its bottom
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 ({2:F3},{3:F3})-({4:F3},{5:F3})",
NW, NH, 0.330, 10.670 - NH, 0.330 + NW, 10.670));
Ed.Regen();
Result
Log
drawing: C:\Users\sanja\OneDrive\_SurveyDisco\260714 - 285 Huckaby Rd, Brooks, GA 30205, USA\260714 - 285 Huckaby Rd R2.dwg --- ring OUTER: x -16.3400..0.0000 y 0.0000..10.3400 notch to (-13.3400,7.3400) TOP [21078] -> (-13.3400,10.3400)-(0.0000,10.3400) LEFT [2108D] -> (-16.3400,7.3400)-(-16.3400,0.0000) --- ring INNER: x -16.2967..0.0407 y -0.0416..10.2996 notch to (-13.2967,7.2996) TOP [21077] -> (-13.2967,10.2996)-(-0.0416,10.2996) LEFT [21086] -> (-16.2987,7.2996)-(-16.2967,0.0407) NEW [21F0B] (-13.3400,10.3400)-(-13.3400,7.3400) len=3.0000 layer=BLOCK_TB2 NEW [21F0C] (-13.3400,7.3400)-(-16.3400,7.3400) len=3.0000 layer=BLOCK_TB2 NEW [21F0D] (-13.2967,10.2996)-(-13.2967,7.2996) len=3.0000 layer=BLOCK_TB2 NEW [21F0E] (-13.2967,7.2996)-(-16.2967,7.2996) len=3.0000 layer=BLOCK_TB2 shortened 4 border lines, added 4 closing lines clerk box is the empty 3.00 x 3.00 at sheet (0.330,7.670)-(3.330,10.670)
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.