Message 1 of 2
How to extract attributes(text) from blocks with C# .NET
Not applicable
04-28-2010
10:42 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi dear friends
I'm trying to write a simple program which it can open the DWG file and read the text inside a block,
until now the software can open the AutoCAD software but I dont know how to access through the block attributes and text,
Autodesk.AutoCAD.Interop.AcadApplication app = null;
Autodesk.AutoCAD.Interop.AcadDocument doc;
Autodesk.AutoCAD.Interop.Common.AcadModelSpace modelspace;
try
{
string inFileName = "C:\\Users\\Paul\\Desktop\\drawing1.dwg";
app = new Autodesk.AutoCAD.Interop.AcadApplication();
doc = app.Documents.Open(inFileName, true, string.Empty);
modelspace = doc.ModelSpace;
foreach (Autodesk.AutoCAD.Interop.Common.AcadEntity myCadEntity in doc.ModelSpace) {
if (myCadEntity is AcadBlockReference)
{
if (myCadEntity.EntityType.ToString() == "7")
{//blocks
MessageBox.Show(myCadEntity.ToString());
MessageBox.Show("this is a block, now its time to read the atrributes inside");
}
}
}
..................
Any help is greatly appreciated,
Maz
I'm trying to write a simple program which it can open the DWG file and read the text inside a block,
until now the software can open the AutoCAD software but I dont know how to access through the block attributes and text,
Autodesk.AutoCAD.Interop.AcadApplication app = null;
Autodesk.AutoCAD.Interop.AcadDocument doc;
Autodesk.AutoCAD.Interop.Common.AcadModelSpace modelspace;
try
{
string inFileName = "C:\\Users\\Paul\\Desktop\\drawing1.dwg";
app = new Autodesk.AutoCAD.Interop.AcadApplication();
doc = app.Documents.Open(inFileName, true, string.Empty);
modelspace = doc.ModelSpace;
foreach (Autodesk.AutoCAD.Interop.Common.AcadEntity myCadEntity in doc.ModelSpace) {
if (myCadEntity is AcadBlockReference)
{
if (myCadEntity.EntityType.ToString() == "7")
{//blocks
MessageBox.Show(myCadEntity.ToString());
MessageBox.Show("this is a block, now its time to read the atrributes inside");
}
}
}
..................
Any help is greatly appreciated,
Maz