Retrievable Dimensions

Top  Previous  Next

Retrievable dimensions are dimensions in the part (and maybe the assembly) which can be placed in the view. In the GUI you open an IDW, go into the Annotate ribbon and click on the Retrieve icon:

 

Retrievable-Dimensions

 

If you have two visible versions of the same dimension in different views (on the same sheet) only one view will get the dimension.

 

Programatically you use the functions GetRetrievableDimensions and RetrieveDimensions.

 

Retrievable-Dimensions-Before-After

 

Here's a function you can use when a part drawing (not an assembly drawing) has been opened... though note that at the time of writing (July 2015) there seems to be a bug in the API when you try to get more than one dimension singly.

 

 

void GetRetDimsOfPart ()

{

   CComPtr<Application> pInvApp = theApp.GetInvAppPtr () ;

 

   // Get all the documents which are open in Inventor...

   CComPtr<Documents> pDocuments;

   HRESULT hRes = pInvApp->get_Documents (&pDocuments) ;

 

   if (FAILED(hRes) || (pDocuments == nullptr)) {

       TRACE (L"GetRetDimsOfPart, could not get docs") ;

       return ;

   }

 

   // Find the first IDW document...

   const UINT ikNumDocs = pDocuments->Count ;

   if (ikNumDocs == 0) {

       TRACE (L"There should be at least one IDW document open\n"

                                L"There are no documents open.") ;

       return ;

   }

 

   // This will be non null after the for loop if an IDW drawing document is found

   CComQIPtr<DrawingDocument> pIDWDoc ; // Is null at the moment

 

   for (UINT iDoc = 1 ; iDoc <= ikNumDocs ; iDoc) {

       CComPtr<Document> pDoc  ;

       hRes = pDocuments->get_Item (1,&pDoc) ;

       if (FAILED(hRes) || (pDoc == nullptr)) {

           TRACE (L"GetRetDimsOfPart, could not get doc %d",iDoc) ;

           return ;

       }

 

       // Try to convert from general doc to IDW drawing doc

       pIDWDoc = pDoc ;

       if (pIDWDoc != nullptr) {

           // The conversion worked so this is an IDW document, our first...

           TRACE (L"Doc %d is an IDW",iDoc) ;

           break ;

       }

   }

 

   if (pIDWDoc == nullptr) {

       TRACE (L"Could not find an IDW") ;

       return ;

   }

 

   // Find the sheets of the drawing document...

   CComPtr<Sheets> pSheets  ;

   hRes = pIDWDoc->get_Sheets(&pSheets) ;

   if (FAILED(hRes) || (pSheets == nullptr)) {

       ShowCOMError (hRes,L"GetRetDimsOfPart, could not get sheets of drawing document.");

       return ;

   }

 

   // Get the (assumed) single sheet inside the IDW. Remember the first object

   // in a COM list had index 1...

   CComPtr<Sheet> pSheet  ;

   hRes = pSheets->get_Item (CComVariant(1),&pSheet) ;

   if (FAILED(hRes) || (pSheet == nullptr)) {

       ShowCOMError (hRes,L"GetRetDimsOfPart, could not get 1st sheet of drawing.");

       return ;

   }

 

   // Get all the views of the sheet...

   CComPtr<DrawingViews> pViews  ;

   hRes = pSheet->get_DrawingViews (&pViews) ;

   if (FAILED(hRes) || (pViews == nullptr)) {

       ShowCOMError (hRes,L"GetRetDimsOfPart, get_DrawingViews failed.");

       return  ;

   }

 

   // Get the first view, you're assuming that there is one...

   CComPtr<DrawingView> pThisView  ;

   hRes = pViews->get_Item(1,&pThisView) ;

   if (FAILED(hRes) || (pThisView == nullptr)) {

       ShowCOMError (hRes,L"GetRetDimsOfPart, get_Item(1) for view failed.");

       return ;

   }

 

   CComPtr<DrawingDimensions> pDwgDimensions  ;

   pSheet->get_DrawingDimensions (&pDwgDimensions) ;

 

   CComPtr<GeneralDimensions> pGenDims  ;

   pDwgDimensions->get_GeneralDimensions (&pGenDims) ;

 

   CComPtr<ObjectCollection> pAllRetCollection  ;

   hRes = pGenDims->GetRetrievableDimensions (pThisView,gkvarEmpty,&pAllRetCollection) ;

   if (FAILED (hRes)) {

       TRACE"Could not get ret dims") ;

       return ;

 

   } else {

       WalertBoxA ("Got RetrievableDims ok, there are %d.",pAllRetCollection->Count) ;

   }

 

   const long ikNumRetDims = pAllRetCollection->Count ;

 

// Change this to 0 or 1

#define ALL_DIMENSIONS 0

 

#if ALL_DIMENSIONS

   /*

    * Make the dimensions actually appear in the IDW drawing document

    */

   CComPtr<GeneralDimensionsEnumerator> pGenDimsEnum1;

   hRes = pGenDims->Retrieve(pThisView,

                             CComVariant(pAllRetCollection),// This tells it to get all dimensions gkvarEmpty,

                             &pGenDimsEnum1);

#else

 

   // Do this so you can create object collections...

   CComPtr<TransientObjects> pTransObjs = GetTransientObjectsPtr() ;

 

   // Create an initially empty object collection...

   CComPtr<ObjectCollection> pJustOneDim  ;

   hRes = pTransObjs->CreateObjectCollection (gkvarEmpty,&pJustOneDim) ;

 

   // Get only the first dimension from the retrievable dimensions...

   IDispatchPtr pFirstDim;

   hRes = pAllRetCollection->get_Item(_variant_t(1), &pFirstDim);

 

   // Add it into the collection of "just one dimension"...

   pJustOneDim->Add (pFirstDim) ;

 

   // Add the single dimension into the drawing...

   CComPtr<GeneralDimensionsEnumerator> pGenDimsEnum1;

   hRes = pGenDims->Retrieve(pThisView,

                             CComVariant(pJustOneDim), // This tell it to get just the first dimension

                             &pGenDimsEnum1);

 

#endif

}

 

Listing the DimensionConstraints...

 

 

 

 

 

 

 

 

 

 

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