Anuncios

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

Writing a Table into a Side Database

jschierenbeck
Enthusiast

Writing a Table into a Side Database

jschierenbeck
Enthusiast
Enthusiast

I am trying to create a BOM table and save it into a Side Database as a .dwg. 
When I run this code on the active drawings database it works, but when I try and use a side database it creates the new drawing, but does not insert the new table. 
Am I doing something wrong here?

Here is the section of my code that creates the table based off of an array and saves it.

 

 

var tb = new Table();
var bt = acTrans.GetObject(newDb.BlockTableId, OpenMode.ForRead) as BlockTable;
tb.TableStyle = newDb.Tablestyle;
// insert rows and columns
totalRows -= 1;
tb.InsertRows(1, .2533, totalRows);
tb.InsertColumns(0, 2, 1);
tb.InsertColumns(0, 7, 1);
tb.InsertColumns(0, 2, 1);

tb.Position = new Point3d(1.5, 22, 0);
totalRows += 1;
for (int a = 1; a < totalRows; a++)
{
for (int b = 0; b < 4; b++)
{
string itemToInsert = bomArray[a, b];
tb.Cells[a, b].TextHeight = .1033;
tb.Cells[a, b].TextString = itemToInsert;
tb.Cells[a, b].Alignment = CellAlignment.MiddleCenter;
}

tb.GenerateLayout();
var btr = acTrans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
btr.AppendEntity(tb);
acTrans.AddNewlyCreatedDBObject(tb, true);
}
acTrans.Commit();
}
newDb.SaveAs(bomDwg, DwgVersion.AC1027);

 

0 Me gusta
Responder
Soluciones aceptadas (1)
440 Vistas
1 Respuesta
Respuesta (1)

JeffatPrimex
Collaborator
Collaborator
Solución aceptada

Your post does not make sense. You will have better results posting in the .net forum. Looking at your code you look to be creating a new table definition which is fine but as far as I know you would need to create a new drawing file first then a new table definition in the new drawing.

 

Best regards,

Jeff

0 Me gusta