Skip to content

Latest commit

 

History

History
51 lines (38 loc) · 1.31 KB

File metadata and controls

51 lines (38 loc) · 1.31 KB

ViewTable Class

Overview

The ViewTable class is a symbol table that contains all named view definitions in an AutoCAD drawing.

Namespace

Autodesk.AutoCAD.DatabaseServices

Inheritance Hierarchy

System.Object
  └─ RXObject
      └─ DBObject
          └─ SymbolTable
              └─ ViewTable

Key Methods

Method Return Type Description
Has(string) bool Checks if a view exists by name
this[string] ObjectId Gets view ObjectId by name (indexer)

Code Examples

Example 1: Listing All Named Views

using (Transaction tr = db.TransactionManager.StartTransaction())
{
    ViewTable vt = tr.GetObject(db.ViewTableId, OpenMode.ForRead) as ViewTable;
    
    ed.WriteMessage("\nNamed views in drawing:");
    
    foreach (ObjectId viewId in vt)
    {
        ViewTableRecord vtr = tr.GetObject(viewId, OpenMode.ForRead) as ViewTableRecord;
        
        ed.WriteMessage($"\n  {vtr.Name}");
    }
    
    tr.Commit();
}

Related Objects

  • Database - Contains ViewTableId
  • ViewTableRecord - Named view definition

References