I need to hatch selected objects in a
. The code given below works, but it ignores the smaller circle inside the bigger one and hatch the bigger circle completely (see circle 1). It should detect the island and leave inside circle unhatched (see circle 1)
I need to set HPISLANDDETECTION value to normal/outer. How can I do it.
[CommandMethod("addhatch")]
public static void Addhatch()
{
var doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
var db = doc.Database;
var ed = doc.Editor;
var filter = new SelectionFilter(new[] { new TypedValue(0, "Circle") });
var selection = ed.GetSelection(filter);
if (selection.Status != PromptStatus.OK)
return;
using (var tr = db.TransactionManager.StartTransaction())
{
var curSpace = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
foreach (var id in selection.Value.GetObjectIds())
{
var ids = new ObjectIdCollection(new[] { id });
using (var hatch = new Hatch())
{
curSpace.AppendEntity(hatch);
tr.AddNewlyCreatedDBObject(hatch, true);
hatch.SetHatchPattern(HatchPatternType.PreDefined, "ANSI31");
hatch.Associative = true;
hatch.AppendLoop(HatchLoopTypes.External, ids);
hatch.HatchStyle = HatchStyle.Outer;
}
}
tr.Commit();
}
}