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
Solved! Go to Solution.
Solved by Joe.Ye. Go to Solution.
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,
Can't find what you're looking for? Ask the community or share your knowledge.