C3D-0217 · 260714 Huckaby: AR-CONC hatch inside the joined driveway error
Concrete hatch (AR-CONC) inside the joined driveway polyline 20CC8, on a new X-DRIV-CONC-PATT layer so it can be frozen separately. Isolated per cookbook 10: the boundary was committed by C3D-0216, so this is not a same-transaction loop. Checks the boundary is closed before hatching and bails if not. Associative. Verifies pattern/scale/loops/area on read-back, regen last.
C# payload
// 260714 - concrete hatch inside the joined driveway polyline 20CC8.
// Cookbook 10: the user explicitly said "hatch", and this is ISOLATED - the boundary was
// committed by a PRIOR ticket (C3D-0216), so it is not a same-transaction loop, which is
// what threw "Operation is not valid due to the current state of the object" on 260613.
var lt = (LayerTable)Tx.GetObject(Db.LayerTableId, OpenMode.ForWrite);
var ms = (BlockTableRecord)Tx.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(Db), OpenMode.ForWrite);
ObjectId bid;
if (!Db.TryGetObjectId(new Handle(Convert.ToInt64("20CC8", 16)), out bid)) {
Log("boundary 20CC8 not found"); return;
}
var bpl = (Polyline)Tx.GetObject(bid, OpenMode.ForRead);
Log(string.Format("boundary [20CC8]: {0} verts, len {1:F2}, closed={2}, layer {3}",
bpl.NumberOfVertices, bpl.Length, bpl.Closed, bpl.Layer));
if (!bpl.Closed) { Log("boundary is NOT closed - hatch would be unreliable, stopping."); return; }
const string HL = "X-DRIV-CONC-PATT";
if (!lt.Has(HL)) {
var ltr = new LayerTableRecord(); ltr.Name = HL;
ltr.Color = Autodesk.AutoCAD.Colors.Color.FromColorIndex(Autodesk.AutoCAD.Colors.ColorMethod.ByAci, 8);
lt.Add(ltr); Tx.AddNewlyCreatedDBObject(ltr, true);
Log("layer created: " + HL);
}
var h = new Hatch();
h.Layer = HL;
ms.AppendEntity(h);
Tx.AddNewlyCreatedDBObject(h, true);
// AR-CONC is the ANSI/AutoCAD concrete pattern. Scale is drawing-unit dependent; the driveway
// is ~490 ft around, so a small scale keeps the aggregate from reading as mush.
h.SetHatchPattern(HatchPatternType.PreDefined, "AR-CONC");
h.PatternScale = 1.0;
h.SetHatchPattern(HatchPatternType.PreDefined, "AR-CONC");
h.Associative = true;
var ids = new ObjectIdCollection();
ids.Add(bid);
h.AppendLoop(HatchLoopTypes.Outermost, ids);
h.EvaluateHatch(true);
var back = (Hatch)Tx.GetObject(h.ObjectId, OpenMode.ForRead);
Log(string.Format("HATCH [{0}]: pattern {1}, scale {2:F2}, loops {3}, area {4:F0} sf, layer {5} (verified)",
back.Handle, back.PatternName, back.PatternScale, back.NumberOfLoops, back.Area, back.Layer));
Ed.Regen();
Result
Log
boundary [20CC8]: 23 verts, len 490.00, closed=True, layer X-DRIV-CONC layer created: X-DRIV-CONC-PATT
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.