Replies: 3 comments 3 replies
-
Hi @farshadvl, Here is a quick guide of steps to read and manage information in a dwg file:
If there's anything you need, don't hesitate to ask. Note: notice that the entity ACAD_TABLE is not implemented yet, if the text that you want to extract is in this type of entity, please open an issue and I'll fix it as soon as I can. |
Beta Was this translation helpful? Give feedback.
-
TextEntity and MText are types, you can identify them using this: foreach (var item in doc.Entities)
{
string text = null;
if(item is TextEntity texte)
{
text = texte.Value;
}
if(item is MText mtext)
{
text = mtext.Value;
}
} But, before that, make sure that the objects that you are looking for are these types, with the images I cannot know if the text that you are trying to get is from a text object, an insert with attributes or a table. |
Beta Was this translation helpful? Give feedback.
-
Hi @farshadvl, I don't understand what you mean by "it just returned number 3 in result", but I ran a simple console app using your file and works fine for me: Here is the code: static void Main(string[] args)
{
CadDocument doc;
using (DwgReader reader = new DwgReader(_file))
{
doc = reader.Read();
}
foreach (var item in doc.Entities)
{
if(item is TextEntity text)
{
Console.WriteLine($"TextEntity:{text.Value}");
}
else if(item is MText mtext)
{
Console.WriteLine($"MText:{mtext.Value}");
}
}
} Inspecting the file I could see that some of the Text that I see in the image form AutoCAD are polylines: This text won't be possible to extract as a string in the code. |
Beta Was this translation helpful? Give feedback.
-
Hi guys. I want to make a tool to read a dwg and extract it's content text into an array of data.
my dwg in autcad is :
the right table is my goal.what should I do?
Beta Was this translation helpful? Give feedback.
All reactions