Close

Relief for ODA Team in Ukraine

Learn more
ODA Drawings SDK
Example of Working with the Layout Object

This example demonstrates working with the layout object for displaying and modifying its properties. This example uses a console menu that represents the following operations: getting and setting the tab order [N], insertion base point [I], minimum extents [M], maximum extents [H], lower-left limits [L], upper-right limits [U], tab selected status [T], outside limits status [O], linetype scale status [S], annotative display status [A], associating with a block [B], disassociating from a block [D], making a viewport active [V], calculating and printing the actual geometry extents [E], printing the whole layout [P] and specific properties [p]. For calculating the geometry extents and selecting a viewport, the optional [G] operation represents the entering of the point entity and viewport entity and adding them in the associated block.

The example uses the following header files and functions implemented in examples:


#include "..\Common\DemoMain.h"
#include "Ge\GePoint2d.h"
#include "Ge\GePoint3d.h"
#include "Ge\GeExtents3d.h"
#include "DbPoint.h"
#include "DbLayout.h"
#include "DbViewport.h"
#include "DbBlockTableRecord.h"
#include <iostream>
using namespace std;

// Example of Entering and Displaying 3D Point Objects
bool EntryPoint3d(OdGePoint3d& point);
OdString AboutPoint3d(const OdGePoint3d& point);

// Example of Entering and Displaying 2D Point Objects
bool EntryPoint2d(OdGePoint2d& point);
OdString AboutPoint2d(const OdGePoint2d& point);

// Example of Using the Record–Table and Dictionary Interfaces for Getting Information about Objects
OdString AboutObjectKey(OdDbObject* pObject);
OdString AboutDbObject(OdDbObjectId idObject);

// Example of Using the Record–Table Interface for Selecting Objects
OdDbObjectId EntryTableRecordObject(OdDbObjectId idTable, OdDbObjectId idRecord = OdDbObjectId::kNull);

// Example of Using the Handle for Selecting Objects
OdDbObjectPtr EntryObjectByHandle(OdDbDatabase* pDb, OdRxClass *pClass);

// Example of Entering Characters for String Objects
OdString EntryTextAs(enum enumCheckText = kArbitrary);

void PrintObjectProperties(OdDbObject* pObject);

The PrintLayoutProperties() function requires a pointer to an existing layout object and prints the listed properties of that layout. This function uses the methods of the layout object to get and display the value of properties.

The PrintLayoutProperties() function has the following implementation:


void PrintLayoutProperties(OdDbLayout* pLayout)
{
  wcout << L"\n  Key = <" << AboutObjectKey(pLayout) << ">"
        << L"\n  Name = \"" << pLayout->getLayoutName() << L"\""
        << L"\n  Type = " << ((pLayout->modelType()) ? L"Model" : L"Paper")
        << L"\n  Block = " << AboutDbObject(pLayout->getBlockTableRecordId())
        << L"\n  Active Viewport = " << AboutDbObject(pLayout->activeViewportId())
        << L"\n  Overall Viewport = " << AboutDbObject(pLayout->overallVportId())
        << L"\n  Tab Order = " << pLayout->getTabOrder()
        << L"\n  Insertion base = " << AboutPoint3d(pLayout->getINSBASE())
        << L"\n  Minimum extents = " << AboutPoint3d(pLayout->getEXTMIN())
        << L"\n  Maximum extents = " << AboutPoint3d(pLayout->getEXTMAX())
        << L"\n  Lower-left limits = " << AboutPoint2d(pLayout->getLIMMIN())
        << L"\n  Upper-right limits = " << AboutPoint2d(pLayout->getLIMMAX())
        << L"\n  Tab selected status = " << ((pLayout->getTabSelected()) ? L"On" : L"Off")
        << L"\n  Outside limits status = " << ((pLayout->getLIMCHECK()) ? L"On" : L"Off")
        << L"\n  Linetype scale status = " << ((pLayout->getPSLTSCALE()) ? L"On" : L"Off")
        << L"\n  Annotative display status = " << ((pLayout->annoAllVisible()) ? L"On" : L"Off");
}

The PrintBlockEntities() function requires a pointer to an existing block record object and prints the list of entities placed in it. The function creates the object iterator for the block using the newIterator() method of the block, and traverses through the container of entities using the step() and done() methods of the iterator. The function gets the pointer to each entity and prints its handle and class name. If an entity is the paper space viewport, the function prints its width and height. If an entity is the point, the function prints its coordinates.

The PrintBlockEntities() function has the following implementation:


void PrintBlockEntities(OdDbBlockTableRecord* pBlock)
{
  OdDbObjectIteratorPtr itEntity;
  OdDbEntityPtr pEntity;

  wcout << "\nBlock geometry:";
  for(itEntity = pBlock->newIterator() ; !itEntity->done() ; itEntity->step())
  {
    pEntity = itEntity->entity();
    wcout << L"\nH=" << pEntity->handle().ascii()
          << L", " << pEntity->isA()->name();
    if(pEntity->isA() == OdDbViewport::desc())
      wcout << L", [" << ((OdDbViewport*)pEntity.get())->width() 
            << L"x" << ((OdDbViewport*)pEntity.get())->height() << "]";
    else if(pEntity->isA() == OdDbPoint::desc())
      wcout << L", " << AboutPoint3d( ((OdDbPoint*)pEntity.get())->position() );
  }
  wcout << "\n";
}

The ModifyLayoutProperties() function requires a pointer to an existing layout object and implements the console menu for the listed operations. The function creates a loop that inquires about the operation code and uses the switch statement to select whether the case must be performed. The function uses the PrintLayoutProperties() function for displaying the specific properties and the AboutObjectKey() function for displaying the external layout name. The ModifyLayoutProperties() function processes user actions in the loop until the user selects the [Q] operation.

When the user selects [P], the function displays the common object properties using the PrintObjectProperties() function and specific layout properties using the PrintLayoutProperties() function. When the user selects the [p] operation, the function displays only specific layout properties.

When the user selects [N], the function gets the current tab order using the getTabOrder() method and prompts for a new current tab number as a positive non-zero integer value. If an entered value is incorrect, the function displays an error message and breaks to the console menu. If an entered value is correct, the function sets the new tab order using the the setTabOrder() method.

When the user selects [I], the function gets the insertion base point using the getINSBASE() method, calls the EntryPoint3d() function for entry of its coordinates, and sets the returned three-dimensional point as a new insertion base using the setINSBASE() method if entry is successful.

When the user selects [M], the function gets the minimal extent point using the getEXTMIN() method, calls the EntryPoint3d() function for entry of its coordinates, and sets the returned three-dimensional point as a new minimum extents using the setEXTMIN() method if entry is successful.

When the user selects [H], the function gets the maximum extent point using the getEXTMAX() method, calls the EntryPoint3d() function for entry of its coordinates, and sets the returned three-dimensional point as a new maximum extents using the setEXTMAX() method if entry is successful.

When the user selects [L], the function gets the lower-left limits corner using the getLIMMIN() method, calls the EntryPoint2d() function for entry of its coordinates, and sets the returned two-dimensional point as a new lower-left limits using the setLIMMIN() method if entry is successful.

When the user selects [U], the function gets the upper-right limits corner using the getLIMMAX() method, calls the EntryPoint2d() function for entry of its coordinates, and sets the returned three-dimensional point as a new upper-right limits using the setLIMMAX() method if entry is successful.

When the user selects [T], the function prompts for the status of the selected tab: N-on or F-off. The function calls the setTabSelected() method and passes to it a True value if the user enters 'N' or a False value if the user enters 'F'. After setting, the function checks and displays the status of the selected tab using the getTabSelected() method.

When the user selects [O], the function prompts for the status of the outside limits: N-on or F-off. The function calls the setLIMCHECK() method and passes to it a True value if the user enters 'N' or a False value if the user enters 'F'. After setting, the function checks and displays the outside limits status using the getLIMCHECK() method.

When the user selects [S], the function prompts for the status of the linetype scale: N-on or F-off. The function calls the setPSLTSCALE() method and passes to it a True value if the user enters 'N' or a False value if the user enters 'F'. After setting, the function checks and displays the linetype scale status using the getPSLTSCALE() method.

When the user selects [A], the function prompts for the status of the annotative display: N-on or F-off. The function calls the setAnnoAllVisible() method and passes to it a True value if the user enters 'N' or a False value if the user enters 'F'. After setting, the function checks and displays the annotative display status using the annoAllVisible() method.

When the user selects [E], the function calculates the actual geometry extents using the getGeomExtents() method and passes to it the instance of the OdGeExtents3d type as an argument in which this method must save the extents calculated on the geometry that is stored in the associated block. If the method returns eOk, the function prints the minimum, maximum, and center of the obtained extents, otherwise the function prints an error message.

When the user selects [B], the function gets the object ID of the associated block record object using the getBlockTableRecordId() method and calls the EntryTableRecordObject() function for selecting another block. The EntryTableRecordObject() function requires the object ID of the symbol table object that stores the block record objects and the default block record object as arguments, organizes its own console menu for selecting an object, and returns the object ID of the block record object specified by the user or the same object ID if the user cancels entry. To get the block table object, the function uses the getBlockTableId() method of the database object and the database() method of the layout object. After selecting, the function checks whether the ID is not kNull, and then, it calls the setBlockTableRecordId() method of the layout object, passing to it the returned object ID to associate the layout with the selected block, and calls the setLayoutId() method of the selected block record object, passing to it the object ID of the layout object to associate the block with the layout. After, the function displays information about the associated block using the AboutDbObject() function, passing to it the object ID returned by the getBlockTableRecordId() method of the layout object.

When the user selects [D], the function gets the smart pointer to the associated block record object using the getBlockTableRecordId() method and safeOpenObject() method. If the smart pointer is not NULL, the function calls the setLayoutId() method of the block record object, passing to it kNull, and calls the setBlockTableRecordId() method of the layout object, passing to it kNull to disassociate the layout and block.

When the user selects [V], the function checks whether the layout has the paper space type because only paper space viewports can be set for paper layouts. The model layout has a hard association with the current active model space viewport implemented by the viewport record object that is singly stored in the viewport table object. Then the function gets the associated block record object, that same as in the [D] operation, and prints the entities stored in it using the PrintBlockEntities() function. The function inquires about the handle of the paper space viewport to be set active using the EntryObjectByHandle() function, which requires the pointer to the database from which an object is selected as the first argument, object type as the second argument, and returns the pointer to the selected object or NULL if the user cancels the entry. After entry, the function calls the setActiveViewportId() method, passing to it the object ID of the selected viewport object. Then, the function displays information about the active viewport using the AboutDbObject() function, passing to it the object ID returned by the activeViewportId() method of the layout object.

When the user selects [Q], the function ends the loop and returns to the calling function.

The ModifyLayoutProperties() function has the following implementation:


void ModifyLayoutProperties(OdDbLayout* pLayout)
{
  OdInt16  number;
  OdResult result;
  OdGePoint2d  location;
  OdGePoint3d  position;
  OdGeExtents3d extents;
  OdDbPointPtr  pPoint;
  OdDbViewportPtr pViewport;
  OdDbBlockTableRecordPtr pBlock;
  wchar_t ch = L'\0';

  wcout << L"\nStart modifying of the layout properties";    
  do {
    switch(ch)
    {
      case L'P':          // Print the whole properties
        wcout << L"\nH=" << pLayout->handle().ascii();
        wcout << L"\n  ------ Common Object Properties";
        PrintObjectProperties(pLayout);

      case L'p':          // Print the specific properties
        wcout << L"\n  ------ Specific Layout Properties";
        PrintLayoutProperties(pLayout);
        wcout << L"\n";
        break;

 
      case L'N':          // Set the tab order
      case L'n':
        wcout << L"\nEntry tab order [=" << pLayout->getTabOrder() << L"]:>";
        wcin >> number;

        if(!wcin.fail() && wcin.peek() == 10)
        {
          pLayout->setTabOrder(number);
          wcout << L"Tab order = " << pLayout->getTabOrder() << L"\n";
        }
        else { wcin.clear();  wcin.sync();  wcout << L"Error: Invalid entered value\n"; }
        break;


      case L'I':          // Set the insertion base
      case L'i':
        wcout << L"Entry the insertion base:";
        position = pLayout->getINSBASE();

        if(EntryPoint3d(position))
        {        
          pLayout->setINSBASE(position);
          wcout << L"Insertion base is set to " << AboutPoint3d(pLayout->getINSBASE()) << L"\n";
        }
        break;


      case L'M':          // Set the minimum extents
      case L'm':
        wcout << L"Entry the minimum extents:";
        position = pLayout->getEXTMIN();

        if(EntryPoint3d(position))
        {        
          pLayout->setEXTMIN(position);
          wcout << L"Minimum extents is set to " << AboutPoint3d(pLayout->getEXTMIN()) << L"\n";
        }
        break;


      case L'H':          // Set the maximum extents
      case L'h':
        wcout << L"Entry the maximum extents:";
        position = pLayout->getEXTMAX();

        if(EntryPoint3d(position))
        {        
          pLayout->setEXTMAX(position);
          wcout << L"Maximum extents is set to " << AboutPoint3d(pLayout->getEXTMAX()) << L"\n";
        }
        break;


      case L'L':          // Set the lower-left limits
      case L'l':
        wcout << L"Entry the lower-left limits:";
        location = pLayout->getLIMMIN();

        if(EntryPoint2d(location))
        {        
          pLayout->setLIMMIN(location);
          wcout << L"Lower-left limits is set to " << AboutPoint2d(pLayout->getLIMMIN()) << L"\n";
        }
        break;


      case L'U':          // Set the upper-right limits
      case L'u':
        wcout << L"Entry the upper-right limits:";
        location = pLayout->getLIMMAX();

        if(EntryPoint2d(location))
        {        
          pLayout->setLIMMAX(location);
          wcout << L"Upper-right limits is set to " << AboutPoint2d(pLayout->getLIMMAX()) << L"\n";
        }
        break;


      case L'T':          // Switch the tab selected status 
      case L't':
        wcout << L"\nSwitch the tab selected status [N-On|F-Off]:>";
        wcin >> ch;

        if(ch == L'N' || ch == L'n') pLayout->setTabSelected(true);
        else if(ch == L'F' || ch == L'f') pLayout->setTabSelected(false);
        wcout << L"Layout tab is " 
              << ((pLayout->getTabSelected()) ? L"selected" : L"nonselected") << L"\n";
        break; 


      case L'O':          // Switch the outside limits status 
      case L'o':
        wcout << L"\nSwitch the outside limits status [N-On|F-Off]:>";
        wcin >> ch;

        if(ch == L'N' || ch == L'n') pLayout->setLIMCHECK(true);
        else if(ch == L'F' || ch == L'f') pLayout->setLIMCHECK(false);
        wcout << L"Objects outside limits are " 
              << ((pLayout->getLIMCHECK()) ? L"disallowed" : L"allowed") << L"\n";
        break; 


      case L'S':          // Switch the linetype scale status
      case L's':
        wcout << L"\nSwitch the linetype scale status [N-On|F-Off]:>";
        wcin >> ch;

        if(ch == L'N' || ch == L'n') pLayout->setPSLTSCALE(true);
        else if(ch == L'F' || ch == L'f') pLayout->setPSLTSCALE(false);
        wcout << L"Linetype dash lengths are based on " 
              << ((pLayout->getPSLTSCALE()) ? L"modelspace" : L"paperspace") << L" units\n";
        break; 


      case L'A':          // Switch the annotative display status 
      case L'a':
        wcout << L"\nSwitch the annotative display status [N-On|F-Off]:>";
        wcin >> ch;

        if(ch == L'N' || ch == L'n') pLayout->setAnnoAllVisible(true);
        else if(ch == L'F' || ch == L'f') pLayout->setAnnoAllVisible(false);
        wcout << ((pLayout->annoAllVisible()) ? L"All annotative objects" : 
                 L"Only annotative objects supported the current annotation scale") 
              << L" are displayed\n";
        break; 


      case L'B':          // Associate with the block record object
      case L'b':
        pBlock = EntryTableRecordObject( pLayout->database()->getBlockTableId(), 
                 pLayout->getBlockTableRecordId() ).safeOpenObject(OdDb::kForWrite);
        if(pBlock.isNull()) break;

        try {
          pLayout->setBlockTableRecordId( pBlock->objectId() );

          pBlock->setLayoutId( pLayout->objectId() );
          
          wcout << L"Block is set to: " << AboutDbObject( pLayout->getBlockTableRecordId() ) << L"\n";
        }
        catch(OdError& e) { wcout << L"\nError: " << e.code() << L" - " << e.description() << L"\n"; }
        break;


      case L'D':          // Disassociate with the block record object
      case L'd':
        try {
          pBlock = pLayout->getBlockTableRecordId().safeOpenObject(OdDb::kForWrite);

          if(!pBlock.isNull()) pBlock->setLayoutId( OdDbObjectId::kNull );

          pLayout->setBlockTableRecordId( OdDbObjectId::kNull );
        }
        catch(OdError& e) { wcout << L"\nError: " << e.code() << L" - " << e.description() << L"\n"; }
        break;


      case L'V':          // Specify the active paper space viewport
      case L'v':
        if(pLayout->modelType()) break;

        pBlock = pLayout->getBlockTableRecordId().safeOpenObject(OdDb::kForWrite);
        if(!pBlock.isNull())
        {
          PrintBlockEntities(pBlock.get());

          wcout << L"\nEntry the handle of the paper viewport to be set active:>";
          pViewport = EntryObjectByHandle(pLayout->database(), OdDbViewport::desc());

          if(!pViewport.isNull())
          {
            wcout << L"\nH=" << pViewport->handle().ascii() << L"\n";
            try {
              pLayout->setActiveViewportId( pViewport->objectId() );

              wcout << L"Active viewport is set to: " 
                    << AboutDbObject( pLayout->activeViewportId() ) << L"\n";
            }
            catch(OdError& e) { wcout << L"\nError: " << e.code() << L" - " << e.description() << L"\n"; }
          }
        }
        else wcout << L"Layout is not associated with block";
        break;


      case L'E':          // Print the geometry extents
      case L'e':
        pBlock = pLayout->getBlockTableRecordId().safeOpenObject(OdDb::kForWrite);
        if(!pBlock.isNull())
        {
          result = pBlock->getGeomExtents(extents); 

          if(result != eOk) 
            wcout << L"\nError: " << result << L" - " 
                  << pLayout->database()->appServices()->getErrorDescription(result) << L"\n"; 
          else 
            wcout << L"\nExtents " << (extents.isValidExtents() ? L"(valid):" : L"(invalid):")
                  << L"\n minimum = " << AboutPoint3d(extents.minPoint())
                  << L"\n maximum = " << AboutPoint3d(extents.maxPoint())
                  << L"\n center  = " << AboutPoint3d(extents.center()) << L"\n";
        }
        else wcout << L"Layout is not associated with block";
        break;


      case L'G':          // Append the geometry
      case L'g':
        pBlock = pLayout->getBlockTableRecordId().safeOpenObject(OdDb::kForWrite);
        if(!pBlock.isNull())
        {
          wcout << L"Select the object type [1-point|2-viewport] to be added:>";
          wcin >> ch;
          if(ch == L'1')
          {
            wcout << L"Entry the point position";
            position.set(0, 0, 0);
            if(EntryPoint3d(position))
            {
              pPoint = OdDbPoint::createObject();
              pPoint->setPosition(position);
              pBlock->appendOdDbEntity(pPoint);
              pPoint = NULL;
            }
          }
          else if(ch == L'2')
          {
            wcout << L"Entry the center point";
            position.set(0, 0, 0);
            if(EntryPoint3d(position))
            {
              wcout << L"Entry the width(x) and height(y)";
              location.set(0, 0);
              if(EntryPoint2d(location))
              {
                pViewport = OdDbViewport::createObject();
                pViewport->setCenterPoint(position);
                pViewport->setWidth(location.x);
                pViewport->setHeight(location.y);
                pBlock->appendOdDbEntity(pViewport);
                pViewport = NULL;
              }
            }
          }
        }
        else wcout << L"Layout is not associated with block";
        break;


      case L'\0':         // Skip an action
        break;

      default:
        wcout << L"Incorrect operation\n";
    }
    wcout << L"\nSelected layout: \"" << pLayout->getLayoutName() << L"\"";
    if(!pLayout->modelType()) wcout << L"\nV. Active viewport";
    wcout << L"\nG. Append geometry"
          << L"\nN. Set the tab order"
          << L"\nI. Set the insertion base"
          << L"\nM. Set the minimum extents"
          << L"\nH. Set the maximum extents"
          << L"\nL. Set the lower-left limits"
          << L"\nU. Set the upper-right limits"
          << L"\nE. Print the geometry extents"
          << L"\nP. Print the whole properties"
          << L"\np. Print the specific properties"
          << L"\nT. Switch the tab selected status"
          << L"\nO. Switch the outside limits status"
          << L"\nS. Switch the linetype scale status"
          << L"\nA. Switch the annotative display status"
          << L"\nB. Associate with the block record object"
          << L"\nD. Disassociate with the block record object"
          << L"\nQ. Quit";
    wcout << L"\nSelect operation:>";
    wcin >> ch;
  }
  while(ch != L'Q' && ch != L'q');

  wcout << L"Stop modifying of the layout properties\n";
}

Testing gives the following results:


Start modifying of the layout properties

Selected layout: "MyLayout"
V. Active viewport
G. Append geometry
N. Set the tab order
I. Set the insertion base
M. Set the minimum extents
H. Set the maximum extents
L. Set the lower-left limits
U. Set the upper-right limits
E. Print the geometry extents
P. Print the whole properties
p. Print the specific properties
T. Switch the tab selected status
O. Switch the outside limits status
S. Switch the linetype scale status
A. Switch the annotative display status
B. Associate with the block record object
D. Disassociate with the block record object
Q. Quit
Select operation:>

When the operation is p-"Print the specific properties":


  ------ Specific Layout Properties
  Key = <MyLayout>
  Name = "MyLayout"
  Type = Paper
  Block = [6F-"MyLayout"-Block]
  Active Viewport = [Db:kNull]
  Overall Viewport = [Db:kNull]
  Tab Order = 4
  Insertion base = (0,0,0)
  Minimum extents = (0,0,0)
  Maximum extents = (0,0,0)
  Lower-left limits = (0,0)
  Upper-right limits = (0,0)
  Tab selected status = Off
  Outside limits status = Off
  Linetype scale status = On
  Annotative display status = Off

When the operation is N-"Set the tab order":


Entry tab order [=4]:>3
Tab order = 3

When the operation is I-"Set the insertion base":


Entry the insertion base:
Current coordinates: (0,0,0)
Entry X-coordinate:>1
Entry Y-coordinate:>1
Entry Z-coordinate:>1
Insertion base is set to (1,1,1)

When the operation is M-"Set the minimum extents":


Entry the minimum extents:
Current coordinates: (0,0,0)
Entry X-coordinate:>0.5
Entry Y-coordinate:>0.5
Entry Z-coordinate:>0.5
Minimum extents is set to (0.5,0.5,0.5)

When the operation is H-"Set the maximum extents":


Entry the maximum extents:
Current coordinates: (0,0,0)
Entry X-coordinate:>90
Entry Y-coordinate:>90
Entry Z-coordinate:>10
Maximum extents is set to (90,90,10)

When the operation is L-"Set the lower-left limits":


Entry the lower-left limits:
Current coordinates: (0,0)
Entry X-coordinate:>1.5
Entry Y-coordinate:>1.5
Lower-left limits is set to (1.5,1.5)

When the operation is U-"Set the upper-right limits":


Entry the upper-right limits:
Current coordinates: (0,0)
Entry X-coordinate:>12.6
Entry Y-coordinate:>11.8
Upper-right limits is set to (12.6,11.8)

When the operation is T-"Switch the tab selected status":


Switch the tab selected status [N-On|F-Off]:>n
Layout tab is selected

When the operation is O-"Switch the outside limits status":


Switch the outside limit status [N-On|F-Off]:>n
Objects outside limits are disallowed

When the operation is S-"Switch the linetype scale status":


Switch the linetype scale status [N-On|F-Off]:>f
Linetype dash lengths are based on paperspace units

When the operation is A-"Switch the annotative display status":


Switch the annotative display status [N-On|F-Off]:>n
All annotative objects are displayed

When the operation is G-"Append geometry":


Select the object type [1-point|2-viewport] to be added:>1
Entry the point position
Current coordinates: (0,0,0)
Entry X-coordinate:>3
Entry Y-coordinate:>4
Entry Z-coordinate:>1

Select the object type [1-point|2-viewport] to be added:>1
Entry the point position
Current coordinates: (0,0,0)
Entry X-coordinate:>6
Entry Y-coordinate:>2
Entry Z-coordinate:>3

Select the object type [1-point|2-viewport] to be added:>1
Entry the point position
Current coordinates: (0,0,0)
Entry X-coordinate:>5
Entry Y-coordinate:>7
Entry Z-coordinate:>2

Select the object type [1-point|2-viewport] to be added:>2
Entry the center point
Current coordinates: (0,0,0)
Entry X-coordinate:>4
Entry Y-coordinate:>4
Entry Z-coordinate:>4
Entry the width(x) and height(y)
Current coordinates: (0,0)
Entry X-coordinate:>10
Entry Y-coordinate:>10

Select the object type [1-point|2-viewport] to be added:>2
Entry the center point
Current coordinates: (0,0,0)
Entry X-coordinate:>5
Entry Y-coordinate:>5
Entry Z-coordinate:>5
Entry the width(x) and height(y)
Current coordinates: (0,0)
Entry X-coordinate:>20
Entry Y-coordinate:>20

When the operation is V-"Active viewport":


Block geometry:
H=71, AcDbPoint, (3,4,1)
H=72, AcDbPoint, (6,2,3)
H=73, AcDbPoint, (5,7,2)
H=74, AcDbViewport, [10x10]
H=75, AcDbViewport, [20x20]

Entry the handle of the paper viewport to be set active:>74

Active viewport is set to: [74-Viewport]

When the operation is E-"Print the geometry extents":


Extents (valid):
 minimum = (3,2,1)
 maximum = (6,7,3)
 center  = (4.5,4.5,2)

After entry, the operation P-"Print all properties" displays:


H=6E
  ------ Common Object Properties
  Type: AcDbLayout
  Status: unerased,resident,modified,forRead,forWrite
  Database: c:\test.dwg
  ------ Specific Layout Properties
  Key = <MyLayout>
  Name = "MyLayout"
  Type = Paper
  Block = [6F-"MyLayout"-Block]
  Active Viewport = [74-Viewport]
  Overall Viewport = [74-Viewport]
  Tab Order = 3
  Insertion base = (1,1,1)
  Minimum extents = (0.5,0.5,0.5)
  Maximum extents = (90,90,10)
  Lower-left limits = (1.5,1.5)
  Upper-right limits = (12.6,11.8)
  Tab selected status = On
  Outside limits status = On
  Linetype scale status = Off
  Annotative display status = On

When the operation is D-"Disassociate with the block record object" and p-"Print the specific properties":


  ------ Specific Layout Properties
  Key = <MyLayout>
  Name = "MyLayout"
  Type = Paper
  Block = [Db:kNull]
  Active Viewport = [Db:kNull]
  Overall Viewport = [Db:kNull]
  Tab Order = 3
  Insertion base = (1,1,1)
  Minimum extents = (0.5,0.5,0.5)
  Maximum extents = (90,90,10)
  Lower-left limits = (1.5,1.5)
  Upper-right limits = (12.6,11.8)
  Tab selected status = On
  Outside limits status = On
  Linetype scale status = Off
  Annotative display status = On

When the operation is B-"Associate with the block record object":


Select the Block object:
1F-"*Model_Space"
1B-"*Paper_Space"
23-"*Paper_Space0"
6F-"MyLayout"
Current: [Db:kNull]
Entry the name to be selected (or [?]-null/[:]-quit):>MyLayout
Block is set to: [6F-"MyLayout"-Block]

Use the Q-"Quit" operation to exit:


Stop modifying of the layout properties

See Also

Working with Layouts

Example of Working with the Layout Dictionary

Copyright © 2002 – 2022. Open Design Alliance. All rights reserved.