Getting the project file location and other options programatically |
Top Previous Next |
You can use this fragment:
CComPtr<FileLocations> pFileLocations; Result = pInvApp->get_FileLocations(&pFileLocations); if (SUCCEEDED(Result)) { CComBSTR bstrFileLocationsFile; Result = pFileLocations->get_FileLocationsFile(&bstrFileLocationsFile); if (SUCCEEDED(Result)) TRACE(L"Active Project File: %ls \n", bstrFileLocationsFile); }
and something like this:
static HRESULT GetInventorInformation(CComPtr<Application>& pInvApp) {
// Display some information about Inventor TRACE("\nInventor Information: \n");
CComBSTR bstrCaption; HRESULT Result = pInvApp->get_Caption(&bstrCaption); if (SUCCEEDED(Result)) TRACE(L"Caption: %ls \n", bstrCaption);
CComBSTR bstrLanguage; Result = pInvApp->get_LanguageName(&bstrLanguage); if (SUCCEEDED(Result)) TRACE(L"Language: %ls \n", bstrLanguage);
CComBSTR bstrUserName; Result = pInvApp->get_UserName(&bstrUserName); if (SUCCEEDED(Result)) TRACE(L"User Name: %ls \n", bstrUserName);
CComPtr<SoftwareVersion> pSoftwareVersion; Result = pInvApp->get_SoftwareVersion(&pSoftwareVersion); if (SUCCEEDED(Result)) { CComBSTR bstrSoftVerDispName; Result = pSoftwareVersion->get_DisplayName(&bstrSoftVerDispName); if (SUCCEEDED(Result)) TRACE(L"Software Version: %ls \n", bstrSoftVerDispName); }
CComPtr<FileLocations> pFileLocations; Result = pInvApp->get_FileLocations(&pFileLocations); if (SUCCEEDED(Result)) { CComBSTR bstrFileLocationsFile; Result = pFileLocations->get_FileLocationsFile(&bstrFileLocationsFile); if (SUCCEEDED(Result)) TRACE(L"Active Project File: %ls \n", bstrFileLocationsFile); }
CComPtr<GeneralOptions> pGeneralOptions; Result = pInvApp->get_GeneralOptions(&pGeneralOptions); if (SUCCEEDED(Result)) { CComBSTR bstrStartupProjectFile; Result = pGeneralOptions->get_StartupProjectFileName(&bstrStartupProjectFile); if (SUCCEEDED(Result)) TRACE(L"Startup Project File: %ls \n\n", bstrStartupProjectFile); }
// Obtain the 'Visible' property of the active application VARIANT_BOOL bVisible = VARIANT_FALSE; Result = pInvApp->get_Visible(&bVisible); if (FAILED(Result)) return Result;
if (bVisible != VARIANT_TRUE){ pInvApp->Visible = VARIANT_TRUE ; }
CComPtr<Document> pDoc; Result = pInvApp->get_ActiveDocument(&pDoc); if (FAILED(Result)) { ShowCOMError (Result,L"get_ActiveDocument failed\n") ; return Result ; }
...etc. |
Text, images and diagrams © 2021 Owen F. Ransen. All rights reserved. (But copy the source code as much as you want!)