[CommandMethod("createTable_")]
public void createTable()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
if (doc == null) return;
Editor ed = doc.Editor;
Database db = doc.Database;
PromptPointResult prPts =
ed.GetPoint("\nEnter table insertion point:");
if (prPts.Status == PromptStatus.OK)
{
using (Transaction tr = doc.TransactionManager.StartTransaction())
{
DBDictionary tsd = tr.GetObject(db.TableStyleDictionaryId, OpenMode.ForRead) as DBDictionary;
if (tsd != null && tsd.Contains("Cablelog"))
{
Table tab = null;
TableStyle ts =
tr.GetObject(tsd.GetAt("Cablelog"), OpenMode.ForRead) as TableStyle;
if (!ts.Template.IsNull)
{
TableTemplate tt =
tr.GetObject(ts.Template, OpenMode.ForRead) as TableTemplate;
// Тут можно поиграться с опциями TableCopyOptions
tab = tt.CreateTable(TableCopyOptions.FillTarget | TableCopyOptions.ExpandOrContractTable);
}
else
{
tab = new Table();
tab.TableStyle = ts.ObjectId;
}
BlockTableRecord btr =
tr.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForWrite) as BlockTableRecord;
btr.AppendEntity(tab);
tr.AddNewlyCreatedDBObject(tab, true);
tab.Position = prPts.Value;
tab.GenerateLayout();
}
tr.Commit();
}
}
}