3) Connecting to Inventor from a Windows MFC app. |
Top Previous Next |
Here is what your init of you MFC Windows application could look like:
BOOL CCollMakeApp::InitInstance() { INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // Effettuare questa impostazione in modo da includere tutte le classi di controlli comuni da utilizzare // nell'applicazione. InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls);
::CoInitialize (NULL) ;
if (!ExcelIsPresent()) { // Required if you use tabular iParts gLogger.Printf (ekErrMsg,L"Is Excel installed for Inventor?") ; }
const bool kbInventorOK = ConnectToInventor();
if (!kbInventorOK) { return FALSE ; }
CWinApp::InitInstance();
// Creare il gestore della shell se la finestra di dialogo contiene // controlli della visualizzazione elenco o struttura ad albero della shell. CShellManager* pShellManager = new CShellManager;
// Initialization finished, run the main dialog of the application... { CMainDlg dlg; m_pMainWnd = &dlg; (void)dlg.DoModal(); }
// Program finished, tidy up...
// Let the user see dialogs etc... GetInvAppPtr()->SilentOperation = VARIANT_FALSE ;
// Free up Inventor interface globals DestroyInventorGlobals () ;
::CoUninitialize();
// Eliminare il gestore della shell creato in precedenza. if (pShellManager != NULL) { delete pShellManager; }
return FALSE; }
CoInitialize and CoUninitialize are required to be able to use COM and its pointers. What I do is, in sequence:
Step 3 above is the heart of the program, a dialog box which talks to Inventor. You have to write that!
4) Inventor pointers and DestroyInventorGlobals
|
Text, images and diagrams © 2021 Owen F. Ransen. All rights reserved. (But copy the source code as much as you want!)