To insert a general table annotation programmatically into a solid model (part or assembly), one must use the InsertGeneralTableAnnotation method of the IModelDocExtension class. The table is inserted, but selecting the table, the scale is null, and the scale factor cannot be changed.
By inserting the table manually, all works fine.
Is there any other solution than using the InsertGeneralTableAnnotation method?
Below is the code snippet
table = NULL;
if (ownerDoc->isDrawing ( ))
{
// Get the center point of the current sheet
double h, w;
long size;
BSTR name;
CComPtr
CComPtr
hr = drawingDoc->IGetCurrentSheet ( &sheet );
hr = sheet->GetSize ( &w, &h, &size );
hr = sheet->GetName ( &name );
printfs ( L"Sheet Name : %s, h : %.3f w : %.3f\n", name, w, h );
double htable = (type == TypeTable::DETAIL) ? (h / 2) : (2 * h / 3);
hr = drawingDoc->InsertTableAnnotation2 ( VARIANT_FALSE, w/2, htable, 1,
(wchar_t*)templateFile.c_str ( ), 10, 20, &table );
}
else
{
CComPtr
hr = modelDoc->get_Extension ( &ext );
// get the 2D annotation view and select it
CComPtr
if (noteArea == NULL) return false; // The 2D annotation view was not found
noteArea->Select2 ( VARIANT_FALSE, 0, &ret );
modelDoc->WindowRedraw ( );
// Create the table
table = NULL;
hr = ext->InsertGeneralTableAnnotation ( VARIANT_FALSE, 0, 0, 1,
(wchar_t*) templateFile.c_str ( ), 10, 20, &table );
if (table != NULL)
{
hr = table->put_BorderLineWeight ( 0 );
hr = table->put_GridLineWeight ( 0 );
}
modelDoc->WindowRedraw ( );
modelDoc->ClearSelection2 ( VARIANT_TRUE );
modelDoc->WindowRedraw ( );
}
Then when editing the table, the scale of the table is zero and it cannot be changed