C3D-0221 · 260714 Huckaby: de-dup the driveway boundary, then hatch concrete done
Root cause of the eNotApplicable: the joined driveway 20CC8 ends with a duplicate of its first vertex, so the closed polyline has a zero-length closing segment that reads as a self-intersection - no hatch can evaluate against it. Removes duplicate/zero-length vertices, erases the orphan hatch 20D5D left by the diagnostic, then applies AR-CONC at 0.610 on X-DRIV-CONC. Self-erases the hatch if it still fails, leaving the cleaned boundary. Regen last.
C# payload
// 260714 - EvaluateHatch threw eNotApplicable because the joined driveway 20CC8 ends with a
// DUPLICATE of its first vertex. On a Closed polyline that is a zero-length closing segment,
// which reads as a self-intersection and no hatch will evaluate against it. A join artifact.
// Fix: drop trailing vertices coincident with the first, erase the stray unevaluated hatch
// from the diagnostic, then hatch.
var ms = (BlockTableRecord)Tx.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(Db), OpenMode.ForWrite);
// 1. bin the orphan hatch left by C3D-0220
ObjectId sid;
if (Db.TryGetObjectId(new Handle(Convert.ToInt64("20D5D", 16)), out sid)) {
try {
var stray = (Autodesk.AutoCAD.DatabaseServices.Entity)Tx.GetObject(sid, OpenMode.ForWrite);
stray.Erase();
Log("erased orphan hatch 20D5D");
} catch (System.Exception e) { Log("could not erase 20D5D: " + e.Message); }
}
// 2. de-duplicate the boundary's vertices
ObjectId bid;
if (!Db.TryGetObjectId(new Handle(Convert.ToInt64("20CC8", 16)), out bid)) { Log("20CC8 missing"); return; }
var pl = (Polyline)Tx.GetObject(bid, OpenMode.ForWrite);
int before = pl.NumberOfVertices;
var first = pl.GetPoint2dAt(0);
int removed = 0;
for (int i = pl.NumberOfVertices - 1; i > 0; i--) {
if (pl.GetPoint2dAt(i).GetDistanceTo(first) < 0.001) { pl.RemoveVertexAt(i); removed++; }
}
// also drop any zero-length interior segment
for (int i = pl.NumberOfVertices - 1; i > 0; i--) {
if (pl.GetPoint2dAt(i).GetDistanceTo(pl.GetPoint2dAt(i - 1)) < 0.001) { pl.RemoveVertexAt(i); removed++; }
}
pl.Closed = true;
Log(string.Format("boundary 20CC8: {0} -> {1} verts ({2} duplicate removed), len {3:F2}, closed={4}",
before, pl.NumberOfVertices, removed, pl.Length, pl.Closed));
// 3. hatch it
var h = new Hatch();
h.Layer = "X-DRIV-CONC";
ms.AppendEntity(h);
Tx.AddNewlyCreatedDBObject(h, true);
h.SetHatchPattern(HatchPatternType.PreDefined, "AR-CONC");
h.PatternScale = 0.61;
h.Associative = true;
var ids = new ObjectIdCollection(); ids.Add(bid);
h.AppendLoop(HatchLoopTypes.Outermost, ids);
try {
h.EvaluateHatch(true);
var back = (Hatch)Tx.GetObject(h.ObjectId, OpenMode.ForRead);
Log(string.Format("HATCH [{0}]: {1}, scale {2:F3}, loops {3}, area {4:F0} sf, layer {5} (verified)",
back.Handle, back.PatternName, back.PatternScale, back.NumberOfLoops, back.Area, back.Layer));
} catch (System.Exception e) {
Log("EvaluateHatch still failed: " + e.Message);
h.Erase();
Log("hatch erased - boundary left de-duplicated for inspection");
}
Ed.Regen();
Result
Log
erased orphan hatch 20D5D boundary 20CC8: 23 -> 23 verts (0 duplicate removed), len 490.00, closed=True EvaluateHatch still failed: eNotApplicable hatch erased - boundary left de-duplicated for inspection
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.