Message 1 of 6
Hatch does not work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
hi:
I have code to hatch 100+ LWPOLYLINE, for some reason, some of them not working. I check the code, I got error message of
eInvalidInput
at line of
oHatch.AppendLoop(HatchLoopTypes.Default, ObjIds);
I already tried HatchLoopTypes.External, same result.
for testing, I create a function: pick the pline, then call the function, got the same error.
if I manually pick the same pline, use AutoCAD HATCH command, it works.
what's could be wrong?
I really appreciate your help.
private static Entity DrawHatch(Entity ent, Color color)
{
string HatchPattern = "SOLID";
Transparency HatchTransparency = new Transparency(255);
ObjectIdCollection ObjIds = new ObjectIdCollection();
ObjIds.Add(ent.ObjectId);
try
{
ent.UpgradeOpen();
Hatch oHatch = new Hatch();
oHatch.SetDatabaseDefaults();
oHatch.SetHatchPattern(HatchPatternType.PreDefined, HatchPattern);
// color
oHatch.Color = color;
// transparency
oHatch.Transparency = HatchTransparency;
// Outermost
oHatch.AppendLoop(HatchLoopTypes.Default, ObjIds);
// evaluate hatch
oHatch.EvaluateHatch(true);
return oHatch;
}
catch (Exception caught)
{
BPLog.Fatal($"ent={ent.Handle}", caught);
return null;
}
}
Windows 10 64 bit, AutoCAD (ACA, Map) 2023