Ejemplo n.º 1
0
    public static ObjectId ToTable(this SymbolTableRecord record, ObjectId tblId, Database db = null)
    {
        db = (db ?? Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument.Database);
        ObjectId id = ObjectId.Null;

        using (Transaction trans = db.TransactionManager.StartTransaction())
        {
            SymbolTable tbl = trans.GetObject(tblId, OpenMode.ForWrite) as SymbolTable;
            if (tbl.Has(record.Name))
            {
                return(tbl[record.Name]);
            }
            tbl.Add(record);
            trans.AddNewlyCreatedDBObject(record, true);
            trans.Commit();
        }
        return(id);
    }