Hi, everyone.
I got a drawing, with a hatch presents a site, and a DBText present the site's name, seen as the image. There are only two kinds of hatchs: a single triangle, the other is a circle with a triangle inside. Other entities have already been removed by me by hand.
After selecting the hatch, some points are showing, so I believe I can get the center point's coordinate as the site's coordinate.
Now, I need to read all the hatches and DBTexts. Then comes the question: how can I get the center point of the hatch?
Here is all I got at the present:
//Select hatch and DBText together
public bool Select(List<Point3d> hatchPointLst,List<DBText> nameLst)
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
using (Transaction trans = db.TransactionManager.StartTransaction())
{
try
{
SelectionFilter flt = new SelectionFilter(new TypedValue[] { new TypedValue(0, "TEXT,HATCH") }); // hatch and DBText
PromptSelectionOptions optSel = new PromptSelectionOptions();
optSel.MessageForAdding = "\nDraw the cursor to select:";
PromptSelectionResult resSel = ed.GetSelection(optSel, flt);
if (resSel.Status != PromptStatus.OK)
return false;
SelectionSet selSet = resSel.Value;
ObjectId[] ids = selSet.GetObjectIds();
foreach (ObjectId sSetEntId in ids)
{
Entity ent = (Entity)trans.GetObject(sSetEntId, OpenMode.ForRead);
if (ent.GetType().Name == "Hatch")
{
Hatch myHatch = (Hatch) trans.GetObject(sSetEntId, OpenMode.ForRead);
[color=red]//Now, how to get the center point of the hatch.[/color]
//Then the center point can be put into the PointList
} //End of the if (ent.GetType().Name == "Hatch")
else if (ent.GetType().Name == "DBText")
{
DBText myText = (DBText)trans.GetObject(sSetEntId, OpenMode.ForRead);
//Collect the DBText
nameLst.Add(myText);
}
}
}
catch (System.Exception ex)
{
ed.WriteMessage(ex.Message + "\n" + ex.StackTrace);
return false;
}
trans.Commit();
//
return true;
}
}