C3D-0225 · 260714 Huckaby: final hatch variants (explicit style, closed loop, -HATCH command) done
Three last attempts: (A) HatchObjectType/HatchStyle set before EvaluateHatch(false) with an External loop, (B) an explicitly-closed Polyline loop with zero bulges, (C) the native -HATCH command through the editor instead of the managed Hatch class. Each cleans up after itself on failure.
C# payload
// Last API-level variants before declaring this blocked.
// A) set HatchObjectType/HatchStyle explicitly before evaluating
// B) build the loop from a Point2dCollection WITHOUT bulges (pure polyline loop)
// C) run the real HATCH command via the editor instead of the managed Hatch class
var ms = (BlockTableRecord)Tx.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(Db), OpenMode.ForWrite);
ObjectId bid;
Db.TryGetObjectId(new Handle(Convert.ToInt64("20CC8", 16)), out bid);
var src = (Polyline)Tx.GetObject(bid, OpenMode.ForRead);
// --- A
{
var h = new Hatch();
h.Layer = "X-DRIV-CONC";
h.HatchObjectType = HatchObjectType.HatchObject;
h.HatchStyle = HatchStyle.Normal;
ms.AppendEntity(h); Tx.AddNewlyCreatedDBObject(h, true);
try {
h.SetHatchPattern(HatchPatternType.PreDefined, "AR-CONC");
h.PatternScale = 0.61;
var ids = new ObjectIdCollection(); ids.Add(bid);
h.AppendLoop(HatchLoopTypes.External, ids);
h.EvaluateHatch(false);
Log(string.Format("A: OK area {0:F0} handle {1}", h.Area, h.Handle));
} catch (System.Exception e) { Log("A: FAIL " + e.Message); try { h.Erase(); } catch { } }
}
// --- B
{
var h = new Hatch();
h.Layer = "X-DRIV-CONC";
ms.AppendEntity(h); Tx.AddNewlyCreatedDBObject(h, true);
try {
h.SetHatchPattern(HatchPatternType.PreDefined, "AR-CONC");
h.PatternScale = 0.61;
var pts = new Point2dCollection();
var bul = new DoubleCollection();
for (int i = 0; i < src.NumberOfVertices; i++) { pts.Add(src.GetPoint2dAt(i)); bul.Add(0.0); }
pts.Add(src.GetPoint2dAt(0)); bul.Add(0.0); // explicitly close the loop
h.AppendLoop(HatchLoopTypes.Polyline, pts, bul);
h.EvaluateHatch(false);
Log(string.Format("B: OK area {0:F0} handle {1}", h.Area, h.Handle));
} catch (System.Exception e) { Log("B: FAIL " + e.Message); try { h.Erase(); } catch { } }
}
// --- C: let AutoCAD's own command do it
try {
Ed.Command("_.-HATCH", "_P", "AR-CONC", "0.61", "0", "_S", bid, "", "");
Log("C: -HATCH command returned without throwing");
} catch (System.Exception e) { Log("C: FAIL " + e.Message); }
Ed.Regen();
Result
Log
A: OK area 3491 handle 20D66 B: FAIL eNotApplicable C: FAIL eInvalidInput
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.