screenshot.png (16.2 KB)
Here is the sample graph. I need to read all the Mtext and the graph above of them. One graph belongs to one Mtext(the one which below the graph). But here is the thing, there is no any relationship between the graph and Mtext(they are not in the same block or other container) .How can I read them under the circumstances. Maybe I can use coordinate to judge if one graph belongs to one Mtext, but it not easy. Is there any good way to help me to solve this problem? Thank you.
@autopay,
I guess the analysis of location is the only way here. Speaking commonly, the analysis of content in the drawings in details is not the easy task. The best solution may be the creation of drawings in some specific way that makes the further analysis easier, e.g., combining related objects into blocks or something else. Probably, cadImage.GetBounds() could be useful to fill Bounds around all entities and analyze rectangles, but I’m not sure it will work for text objects and requires some time to process.
Thanks for reply , is there any method to read entities based on the location ? from start X,Y to End X,Y? and read all entities from this area?
By the way, Can I read the entity by layer? I use the way below to read the entity in the layer 0, but I cannot read some specific entity, (like MLine), did I use the wrong way to read it?
foreach (CadBaseEntity baseEntity in entities)
{
if (baseEntity.LayerName=="0")
{
if (baseEntity.TypeName== CadEntityTypeName.MTEXT)
{
CadMText mtext = (CadMText)baseEntity;
res.Add(mtext.FullClearText);
}
if (baseEntity.TypeName == CadEntityTypeName.LINE)
{
CadLine cline = (CadLine)baseEntity;
filteredEntities.Add(cline);
}
if (baseEntity.TypeName == CadEntityTypeName.ELLIPSE)
{
CadEllipse cellipse = (CadEllipse)baseEntity;
filteredEntities.Add(cellipse);
}
if (baseEntity.TypeName == CadEntityTypeName.INSERT)
{
CadInsertObject insert = (CadInsertObject)baseEntity;
filteredEntities.Add(insert);
}
}
}