If you want to open in a specific design view, you need to use OpenWithOptions, while Open method can only open the assembly with LOD (Level of Detail) option.
Following is a code to open an assembly with last active LOD and last active design view
static HRESULT GetInventorInformation()
{
HRESULT Result = NOERROR;
// Assume Inventor application pInvApp is available
CComPtr<Documents> pAllDocs = NULL;
Result = pInvApp->get_Documents(&pAllDocs);
CComPtr<FileManager> pFileManager;
Result = pInvApp->get_FileManager(&pFileManager);
_bstr_t bsCurrentDocumentName(L"C:\\test.iam");
// get last LOD
BSTR strLastActiveLOD;
Result =
pFileManager->
GetLastActiveLevelOfDetailRepresentation(bsCurrentDocumentName,
&strLastActiveLOD);
// get last Design View Representation
BSTR strLastActiveView;
Result =
pFileManager->
GetLastActiveDesignViewRepresentation(bsCurrentDocumentName,
&strLastActiveView);
BSTR strFullDocumentName;
Result =
pFileManager->
GetFullDocumentName(bsCurrentDocumentName, strLastActiveLOD,
&strFullDocumentName);
CComPtr<NameValueMap> nameValueMap = NULL;
pInvApp->TransientObjects->CreateNameValueMap(&nameValueMap);
nameValueMap->
Add(_bstr_t("LevelOfDetailRepresentation"),
_variant_t( strLastActiveLOD) );
nameValueMap->
Add(_bstr_t("DesignViewRepresentation"),
_variant_t( strLastActiveView ));
CComPtr<Document> pDocument = NULL;
//pDocument = pAllDocs->MethodOpen(strFullDocumentName,VARIANT_TRUE);
pDocument =
pAllDocs->
MethodOpenWithOptions(bsCurrentDocumentName,nameValueMap,
_variant_t(VARIANT_TRUE));
return Result;
}