4) Pointers to Inventor and useful Inventor API objects.

Top  Previous  Next

In the library, file InventorSupp.cpp there are these pointers:


static CComPtr<Application> pInvApp = nullptr;

static CComPtr<TransientGeometry> pTransGeom  = nullptr;

static CComPtr<TransientObjects> pTransientObjects  = nullptr;

static CComPtr<Matrix> pIdMatrix = nullptr;


pInvApp is initialised by a call to ConnectToInventor.


The last three are initialised as required, for example:


CComPtr<TransientGeometry> GetTransGeomPtr ()


   if (pInvApp == nullptr) {

       gLogger.Printf (ekErrMsg,L"GetTransGeomPtr failed, no app") ;

       return nullptr ;



   if (pTransGeom == nullptr) {

       // Not yet initialised...




   if (pTransGeom == nullptr) {

       // Something went wrong

       gLogger.Printf (ekErrMsg,L"CCollMakeApp::GetTransGeomPtr failed, no transient geometry") ;

       return nullptr ;



   return pTransGeom ;



The Inventor application pointer is the main method for getting data from Inventor and sending commands to it.


The transient geometry pointer lets you create matrices, vectors etc. Explained more here.


The transient objects pointer is used to make temporary collections of objects you need to operate on, for example a list of holes in a solid object or some workplanes arranged somewhere in a part. TransientObjectCollections are explained more here.


And pIdMatrix is an often used object, so rather than creating it every time its need I create it once and use it often.


DestroyInventorGlobals should be called at the end of your program:


void DestroyInventorGlobals()


   // These are smart pointers and setting them to nullptr will release the memory too...

   pInvApp = nullptr ;

   pTransGeom = nullptr ;

   pTransientObjects = nullptr ;

   pIdMatrix = nullptr ;



5) Running Inventor programatically.




Text, images and diagrams © 2021 Owen F. Ransen. All rights reserved. (But copy the source code as much as you want!)