Allows access to a Sheet.
This code snippet shows how to get the ID and working space of a Block instance. This code snippet also shows how to determine if the working space is a model or sheet.
COM native C++
//Get Block instance ID
bstr_t blkInstanceID = blkIns->GetID();
//Get working space
dsObjectType_e oType;
IDispatch pWorkingSpace;
blkIns->GetWorkingSpace( &oType, &pWorkingSpace );
//If working space is a model
if( dsModelType == oType )
{
IModel modelSpace ( pWorkingSpace );
. . .
}
else
{
//If working space is a sheet
if( dsSheetType == oType )
{
ISheetPtr sheet( pWorkingSpace );
. . .
}
}
COM native C++
This code snippet shows how to get the Sheets, their names, and the bounding box coordinates.
void CAddinDumpManager::DumpSheets( CStdioFile& fileOutput, LPCWSTR tabStr, IDocumentPtr dsDoc )
{
CString strPrint;
_variant_t pVariantArray = dsDoc->GetSheets();
if( V_VT( &pVariantArray ) != VT_EMPTY )
{
ISheetPtr *sheets = NULL;
int count = 0;
TypeConverter::convertVariantArrayToPtrArray<ISheetPtr, ISheet>( pVariantArray, sheets, count );
strPrint.Format( L"Sheets: (%d):\r\n", count );
fileOutput.WriteString( strPrint );
if( sheets && count > 0 )
{
// Iterate through Block instances
for( int i = 0; i < count; ++i )
{
//Get Sheet name
bstr_t SheetName= sheets[i]->GetName();
strPrint.Format( L"Name: %s\r\n", SheetName.operator const wchar_t*() );
fileOutput.WriteString( strPrint );
//Get ISketchManager object
ISketchManagerPtr dsSketchManagerSheet( sheets[i]->GetSketchManager() );
if( dsSketchManagerSheet != NULL )
{
//Get Sheet bounding box
double x1, y1, z1, x2, y2, z2;
dsSketchManagerSheet->GetBoundingBox( &x1, &y1, &z1, &x2, &y2, &z2 );
strPrint.Format( L"Bounding box: %.4f %.4f %.4f %.4f\r\n", x1, y1, x2, y2 );
fileOutput.WriteString( strPrint );
}
else
fileOutput.WriteString( L"ERROR GetSketchManager\r\n" );
}
delete[] sheets;
}
}
else
fileOutput.WriteString( L"ERROR GetSheets\r\n" );
}