Selecting an enclosed area, a la hatch

Not applicable
09-10-2018
07:55 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Is it possible to prompt selection for an empty area, a la vanilla hatch command? I've written a piece of code where I aimed to select an object, then fill it with hatch. This would've worked had I a single object, but my enclosed space is surrounded by more than a single object or even types of objects.
Hence, I'm in need of a Prompt to select the empty enclosed space instead. Is this possible, or has anyone experience with this kind of thing? My code blow, which was to prompt for an object selection.
public static void HatchArea() { Document acDoc = Application.DocumentManager.MdiActiveDocument; Database acCurDb = acDoc.Database; Editor docEd = acDoc.Editor; PromptKeywordOptions promptKeyOpts = new PromptKeywordOptions(""); promptKeyOpts.AllowArbitraryInput = false; promptKeyOpts.Keywords.Add("Area"); promptKeyOpts.Keywords.Add("Boundary"); PromptResult hatchSelRes = docEd.GetKeywords(promptKeyOpts); using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction()) { BlockTable acBt; acBt = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead) as BlockTable; BlockTableRecord acBtr; acBtr = acTrans.GetObject(acBt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord; using (Hatch acHatch = new Hatch()) { if (hatchSelRes.StringResult == "Area") { Point3dCollection p3Coll = new Point3dCollection(); PromptEntityOptions promptEntity = new PromptEntityOptions(""); PromptEntityResult entityRes = docEd.GetEntity(promptEntity); if (entityRes.ObjectId != null) { ObjectId oid = new ObjectId(); oid = entityRes.ObjectId; ObjectIdCollection oidCol = new ObjectIdCollection(); oidCol.Add(oid); try { acBtr.AppendEntity(acHatch); acTrans.AddNewlyCreatedDBObject(acHatch, true); acHatch.AppendLoop(HatchLoopTypes.External, oidCol); } catch (SystemException ex) { docEd.WriteMessage("Select an enclosed object."); } } }