Reshi
Reshi

Reputation: 799

How to extract components from DXF created in AutoCAD?

I'm trying to find some way how I could obtain some concrete components from .dxf file created by AutoCAD. Concretely, there will be a building drawn in AutoCAD with windows, doors and other similar components specified.

I found some libraries like dxflib from ribbonsoft or kabeja that are able to extract lines, arcs and so on. But it would be very helpful if I could identify directly components like windows, doors etc. The reason why I need it is, that I have to transform an existing building into my own data model (abstracting some unnecessary attributes) in my application.

Is there such a solution? Doesn't matter if free or paid. Also doesn't matter if the solution would be in C/C++, Java, Lisp ... (the best would be java :))

Thank you very much for your answers and help :)

Upvotes: 0

Views: 902

Answers (1)

kaps
kaps

Reputation: 186

Use code below... It will help you. It is in C#

List<Entity> tListEntities = new List<Entity>();
Database database = HostApplicationServices.WorkingDatabase;
using (Transaction transaction = database.TransactionManager.StartTransaction())
{
BlockTableRecord btRecord = (BlockTableRecord)transaction.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(database), OpenMode.ForRead);
foreach (ObjectId id in btRecord)
{
    tListEntities.Add((Entity)transaction.GetObject(id, OpenMode.ForRead));
}
transaction.Commit();

}

Upvotes: 1

Related Questions