.NET

Reply
New Member
mike_mair
Posts: 1
Registered: ‎07-20-2011
Message 1 of 2 (227 Views)

Convert a Wall (AEC_WALL) to an Solid3D Object

227 Views, 1 Replies
11-24-2013 10:29 AM

Hello,

 

Can someone explain me how I can change an AEC Wall (AEC_WALL) to an Solid3D Object. I found out that I can extract all Bodies from a Wall with "GetComponentBodies" function, but I do not know how to get this to an Solid3D Object.

 

Dim wall AsWall = TryCast(trans.GetObject(obj, OpenMode.ForRead), Wall)

Dim bodyColl As New BodyCollection

wall.GetComponentBodies(bodyColl,True, False, True, True, True, True, True)

 

 

I know that there is an Autodesk Architectur Command "AECCONVERTTO3DSOLIDS" --> dies is the Command what i need --> but i need the command for .NET.

 

I hope, anyone can Help me.

 

mike

ADN Support Specialist
Joe.Ye
Posts: 328
Registered: ‎03-05-2010
Message 2 of 2 (143 Views)

Re: Convert a Wall (AEC_WALL) to an Solid3D Object

12-13-2013 12:16 AM in reply to: mike_mair

 

Hi Mike,

 

You can write out the body components of AEC wall to *.sat file to the disk. Then read in this file using the Autodesk.AutoCAD.DatabaseServices.Body.AcisIn(fileName). The Body class in AutoCAD .NET is a 3D solid entity.

 

 

Here is the full code to convert the wall to 3D solid.

 

<code>

 

[Autodesk.AutoCAD.Runtime.CommandMethod("w2b", "w2b", Autodesk.AutoCAD.Runtime.CommandFlags.Modal)]
public void ConvertWallToAcDbBody()
{
Editor editor = Application.DocumentManager.MdiActiveDocument.Editor;
editor.WriteMessage("\n====================================================\n");


PromptEntityOptions opts = new PromptEntityOptions("\nPick a wall: ");
PromptEntityResult results = null;

results = editor.GetEntity(opts);
ObjectId id = results.ObjectId;

Database db = Application.DocumentManager.MdiActiveDocument.Database;

TransactionManager tm = db.TransactionManager;
Transaction trans = tm.StartTransaction();

Wall w = trans.GetObject(id, OpenMode.ForRead) as Wall;
BodyCollection bc = new BodyCollection();
w.GetComponentBodies(out bc, true, true, true, true, true, true, true);

BlockTable bt = (BlockTable)tm.GetObject(db.BlockTableId, OpenMode.ForRead, false);
BlockTableRecord btr = (BlockTableRecord)tm.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite, false);

String fileName = @"c:\test\mysat.sat";
foreach (Autodesk.Aec.Modeler.Body b in bc)
{

b.SaveToSAT(fileName);


DBObjectCollection collection = Autodesk.AutoCAD.DatabaseServices.Body.AcisIn(fileName);

foreach(DBObject obj in collection)
{
btr.AppendEntity((Autodesk.AutoCAD.DatabaseServices.Entity)obj);
trans.AddNewlyCreatedDBObject(obj, true);
}

}
trans.Commit();

editor.WriteMessage("\n====================================================\n");
}

 

<code>

 

Hope this helps,

 



Joe Ye
Contractor
Developer Technical Services
Autodesk Developer Network
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.