Represents a viewport table record in AutoCAD.

This class represents viewport arrangements in AutoCAD, which define how the drawing is displayed in different areas of the screen or paper space. Viewports can have their own zoom levels, pan positions, grid settings, and other display properties.

const viewportRecord = new AcDbViewportTableRecord();
viewportRecord.name = '*Active';
viewportRecord.circleSides = 100;
viewportRecord.lowerLeftCorner = new AcGePoint2d(0, 0);
viewportRecord.upperRightCorner = new AcGePoint2d(1, 1);

Hierarchy (View Summary)

Constructors

Accessors

  • get circleSides(): number
  • Gets or sets the circle zoom percent.

    This controls the number of sides to the tessellation used when displaying curves. The value can be between 1 and 20000, with higher settings using more sides in the curve tessellation.

    Returns number

    The number of sides used for circle tessellation

    const sides = viewportRecord.circleSides;
    viewportRecord.circleSides = 200; // Higher quality circles
  • set circleSides(value: number): void
  • Parameters

    • value: number

    Returns void

  • get database(): AcDbDatabase
  • Gets the database in which this object is resident.

    When an object isn't added to a database, this property returns the current working database. After it is added to a database, it will be set automatically. You should never set this value manually.

    Returns AcDbDatabase

    The database this object belongs to

    const db = obj.database;
    
  • set database(db: AcDbDatabase): void
  • Sets the database for this object.

    This is typically set automatically when the object is added to a database. Manual setting should be avoided unless you know what you're doing.

    Parameters

    Returns void

    obj.database = myDatabase;
    
  • get lowerLeftCorner(): AcGePoint2d
  • Gets or sets the lower left corner of the viewport window.

    The X and Y values of this point are expressed as a value between (0.0, 0.0) for the lower left corner of the AutoCAD graphics area and (1.0, 1.0) for the upper right corner of the AutoCAD graphics area. For example, a lower left corner value of (0.5, 0.0) indicates that the viewport's lower left corner is along the bottom of the AutoCAD graphics area, midway between the left and right edges of the graphics area.

    Returns AcGePoint2d

    The lower left corner point

    const corner = viewportRecord.lowerLeftCorner;
    viewportRecord.lowerLeftCorner = new AcGePoint2d(0.25, 0.25);
  • set lowerLeftCorner(value: AcGePoint2d): void
  • Parameters

    Returns void

  • get name(): string
  • Gets or sets the name of the symbol table record.

    This property corresponds to DXF group code 2 and is used for identifying and referencing the symbol table record.

    Returns string

    The name of the symbol table record

    const recordName = record.name;
    record.name = 'NewRecordName';
  • set name(value: string): void
  • Parameters

    • value: string

    Returns void

  • get objectId(): string
  • Gets the object ID.

    AutoCAD uses 64-bit integers to represent handles, which exceed the maximum integer value of JavaScript. Therefore, strings are used to represent object handles.

    Returns string

    The object ID as a string

    const id = obj.objectId;
    console.log(`Object ID: ${id}`);
  • set objectId(value: string): void
  • Sets the object ID.

    Parameters

    • value: string

      The new object ID

    Returns void

    obj.objectId = 'new-object-id';
    
  • get ownerId(): string
  • Gets the object ID of the owner of this object.

    Returns string

    The owner object ID

    const ownerId = obj.ownerId;
    
  • set ownerId(value: string): void
  • Sets the object ID of the owner of this object.

    Parameters

    • value: string

      The new owner object ID

    Returns void

    obj.ownerId = 'parent-object-id';
    

Methods

  • Closes the object.

    All changes made to the object since it was opened are committed to the database, and a "closed" notification is sent. This method can be overridden by subclasses to provide specific cleanup behavior.

    Returns void

    obj.close();
    
  • Gets the value of the specified attribute.

    This method will throw an exception if the specified attribute doesn't exist. Use getAttrWithoutException() if you want to handle missing attributes gracefully.

    Parameters

    • attrName: string

      The name of the attribute to retrieve

    Returns any

    The value of the specified attribute

    When the specified attribute doesn't exist

    try {
    const value = obj.getAttr('objectId');
    } catch (error) {
    console.error('Attribute not found');
    }
  • Gets the value of the specified attribute without throwing an exception.

    This method returns undefined if the specified attribute doesn't exist, making it safer for optional attributes.

    Parameters

    • attrName: string

      The name of the attribute to retrieve

    Returns any

    The value of the specified attribute, or undefined if it doesn't exist

    const value = obj.getAttrWithoutException('optionalAttribute');
    if (value !== undefined) {
    // Use the value
    }