A layout object is usually associated with a block record object that stores geometry. When the associated block contains entities, the extents can be calculated base on the extents of stored entities. This is actual extents. When the associated block does not contain entities or the layout is not associated with a block, the extents cannot be calculated, but the program can assign two three-dimensional points as extents of the layout. This is formal extents. The formal extents coordinates are stored as typical data, and are not bound to actual extents or extents of entities.
In the following examples, the pLayout variable stores a pointer to the layout object, and the pDb variable stores a pointer to the database object.
To calculate the actual extents of entities stored in the associated block, declare a variable of the OdGeExtents3d type which is an extents instance, and use the getGeomExtents() method which requires a reference to an existing extents instance as an argument and returns an error code if the extents is invalid or eOk if the extents is calculated successfully. For example:
OdGePoint3d extmin, extmax;
OdGeExtents3d extents;
OdDbBlockTableRecordPtr pBlock = pLayout->getBlockTableRecordId().safeOpenObject(OdDb::kForWrite);
if(!pBlock.isNull())
{
OdResult result = pBlock->getGeomExtents(extents);
if(result != eOk)
{
odPrintConsoleString(L"\nError: %d - %s", result,
pLayout->database()->appServices()->getErrorDescription(result));
}
else
{
extmin = extents.minPoint();
extmax = extents.maxPoint();
odPrintConsoleString(L"\nExtents: min(%f,%f,%f)--max(%f,%f,%f)",
extmin.x, extmin.y, extmin.z, extmax.x, extmax.y, extmax.z);
}
}
else odPrintConsoleString(L"Layout is not associated with a block");
Note: If the layout is not associated with a block, calculating the extents is not applicable.
Note: If the layout does not contain geometry or contains only paper space viewports in its own associated block, the calculated extents is invalid and the getGeomExtents() method returns the result code eInvalidExtents. For example:
// When the block is empty
OdResult result = pBlock->getGeomExtents(extents);
odPrintConsoleString(L"\nError: %d - %s", result, pHost->getErrorDescription(result));
// Error: 35 - Invalid extents
When a layout object is not associated with a block record object, its extents are undefined. However, the layout object has a formal extents, which is stored as typical data in the layout object, independent from geometry. The formal extents are defined as two three-dimensional points. The first point defines the coordinates of the minimum extents, and the second point defines the coordinates of the maximum extents. The initial value for both points is (0,0,0).
To get the minimum formal extents, use the getEXTMIN() method. To get the maximum formal extents, use the getEXTMAX() method. Both methods return the three-dimensional point as an instance of the OdGePoint3d type. For example:
OdGePoint3d minimum = pLayout->getEXTMIN();
odPrintConsoleString(L"\nMinimum extents = (%f,%f,%f)", minimum.x, minimum.y, minimum.z);
OdGePoint3d maximum = pLayout->getEXTMAX();
odPrintConsoleString(L"\nMinimum extents = (%f,%f,%f)", maximum.x, maximum.y, maximum.z);
To set the minimum formal extents, use the setEXTMIN() method. To set the maximum formal extents, use the setEXTMAX() method. Both methods require one argument — the three-dimensional point as an instance of the OdGePoint3d type — and do not return a value. For example:
OdGePoint3d minimum(10, 10, 10);
pLayout->setEXTMIN(minimum);
OdGePoint3d maximum(90, 90, 90);
pLayout->setEXTMAX(maximum);
Note: To synchronize the formal extents with actual extents, call the getGeomExtents() method to calculate the actual extents which are based on the geometry, and then call the setEXTMIN() and setEXTMAX() methods to set the formal extents for calculated points. For example:
OdGeExtents3d extents;
pBlock = pLayout->getBlockTableRecordId().safeOpenObject();
pBlock->getGeomExtents(extents);
pLayout->setEXTMIN(extents.minPoint());
pLayout->setEXTMAX(extents.maxPoint());
The database object has similar methods for getting and setting the formal extents of model space and paper space:
For example, to get:
OdGePoint3d minExtModel = pDb->getEXTMIN();
OdGePoint3d maxExtModel = pDb->getEXTMAX();
odPrintConsoleString(L"\nCurrent model minimum extents (%f,%f,%f)", minExtModel.x, minExtModel.y, minExtModel.z);
odPrintConsoleString(L"\nCurrent model maximum extents (%f,%f,%f)", maxExtModel.x, maxExtModel.y, maxExtModel.z);
OdGePoint3d minExtPaper = pDb->getPEXTMIN();
OdGePoint3d maxExtPaper = pDb->getPEXTMAX();
odPrintConsoleString(L"\nCurrent paper minimum extents (%f,%f,%f)", minExtPaper.x, minExtPaper.y, minExtPaper.z);
odPrintConsoleString(L"\nCurrent paper maximum extents (%f,%f,%f)", maxExtPaper.x, maxExtPaper.y, maxExtPaper.z);
For example, to set:
pDb->setEXTMIN( OdGePoint3d(10,10,10) );
pDb->setEXTMAX( OdGePoint3d(90,90,90) );
pDb->setPEXTMIN( OdGePoint3d(30,30,30) );
pDb->setPEXTMAX( OdGePoint3d(60,60,60) );
Note: The EXTMIN, EXTMAX, PEXTMIN, and PEXTMAX system variables provide access to the formal extents of model space and paper space.
The layout limits are two two-dimensional points that represent the limits of geometry entered in the layout. The first point defines the coordinates of the lower-left corner, and the second point defines the coordinates of the upper-right corner. The initial value for both points is (0,0).
To get the lower-left limits, use the getLIMMIN() method. To get the upper-right limits, use the getLIMMAX() method. Both methods return the two-dimensional point as an instance of the OdGePoint2d type. For example:
OdGePoint2d limmin = pLayout->getLIMMIN();
odPrintConsoleString(L"\nLower-left limits = (%f,%f)", limmin.x, limmin.y);
OdGePoint2d limmax = pLayout->getLIMMAX();
odPrintConsoleString(L"\nUpper-right limits = (%f,%f)", limmax.x, limmax.y);
To set the lower-left limits, use the setLIMMIN() method. To set the upper-right limits, use the setLIMMAX() method. Both methods require one argument — the two-dimensional point as an instance of the OdGePoint2d type — and do not return a value. For example:
OdGePoint2d limmin(10, 10, 10);
pLayout->setLIMMIN(limmin);
OdGePoint2d limmax(90, 90, 90);
pLayout->setLIMMAX(limmax);
The database object has similar methods for getting and setting the limits of model space and paper space:
For example, to get:
OdGePoint2d minLimModel = pDb->getLIMMIN();
OdGePoint2d maxLimModel = pDb->getLIMMAX();
odPrintConsoleString(L"\nCurrent model minimum extents (%f,%f)", minLimModel.x, minLimModel.y);
odPrintConsoleString(L"\nCurrent model maximum extents (%f,%f)", maxLimModel.x, maxLimModel.y);
OdGePoint2d minLimPaper = pDb->getPLIMMIN();
OdGePoint2d maxLimPaper = pDb->getPLIMMAX();
odPrintConsoleString(L"\nCurrent paper minimum extents (%f,%f)", minLimPaper.x, minLimPaper.y);
odPrintConsoleString(L"\nCurrent paper maximum extents (%f,%f)", maxLimPaper.x, maxLimPaper.y);
For example, to set:
pDb->setLIMMIN( OdGePoint2d(1,1) );
pDb->setLIMMAX( OdGePoint2d(12,18) );
pDb->setPLIMMIN( OdGePoint2d(3,3) );
pDb->setPLIMMAX( OdGePoint2d(9,9) );
Note: The LIMMIN, LIMMAX, PLIMMIN, and PLIMMAX system variables provide access to the limits of model space and paper space.
This status determines whether entities placed in the layout should be limited by the grid of the layout. LIMMIN and LIMMAX specify the grid limits. The outside limits status is defined as a Boolean value and is True if objects outside the limits are disallowed, or it is False if objects outside the limits are allowed. The initial value is False.
To check the status, use the getLIMCHECK() method which returns the status as a Boolean value. For example:
odPrintConsoleString(L"\nObjects outside limits are %s ",
(pLayout->getLIMCHECK()) ? L"disallowed" : L"allowed");
To switch the status, use the setLIMCHECK() method which requires the status as a Boolean argument. For example:
// Disallow the objects outside limits
pLayout->setLIMCHECK(true);
// Allow the objects outside limits
pLayout->setLIMCHECK(false);
The database object has similar methods for getting and setting the outside limits status of model space and paper space:
For example, to get:
odPrintConsoleString(L"\nObjects outside limits are %s for the model space",
(pDb->getLIMCHECK()) ? L"disallowed" : L"allowed");
odPrintConsoleString(L"\nObjects outside limits are %s for the paper space",
(pDb->getPLIMCHECK()) ? L"disallowed" : L"allowed");
For example, to set:
pDb->setLIMCHECK(true);
pDb->setPLIMCHECK(false);
Note: The LIMCHECK and PLIMCHECK system variables provide access to the outside limits status of model space and paper space.
Associations of the Layout Object
Other Properties of the Layout Object
Example of Working with the Layout Object
Copyright © 2002 – 2021. Open Design Alliance. All rights reserved.
|