Click here to Skip to main content
16,017,502 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
[CommandMethod("FindAllHatches")]
public static void FindAllHatches()
{
    Document acDoc = Application.DocumentManager.MdiActiveDocument;
 var str=new StringBuilder();
    str.Append("\nSearching for Hatches");
 
    var db = acDoc.Database;
    using (Transaction transaction = db.TransactionManager.StartTransaction())
    {
        ObjectId idModelSpace = SymbolUtilityServices.GetBlockModelSpaceId(db);
 
        BlockTableRecord modelSpace = transaction.GetObject(idModelSpace, OpenMode.ForRead) as
            BlockTableRecord;
 
        foreach (var objId in modelSpace)
        {
            var entity = transaction.GetObject(objId, OpenMode.ForRead);
            Hatch hatch = entity as Hatch;
            if (hatch == null)
                continue; //not hatch

           str.Append("\nFound Hatch Area={0}", hatch.Area);
        } 
 acDoc.Editor.WriteMessage(str.ToString());           
    }
}


What I have tried:

The above code is calculate the area of hatches in my autocad drawing, i want to display the area of each hatch seprately in my drawing but when loop is iterate the output is overwrite on each other. Suggest me the code to calculate the area and display seprately from each other.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900