ParameterPtr and get_XCount

Top  Previous  Next

Some Inventor API COM functions take a ParameterPtr, even to get simple integers, like the count in a RectangularPattern. Here is how to declare and use the parameter pointer in those cases:


       //CComPtr<Parameter> iXCount ; // this works too

       ParameterPtr iXCount ;

       pRectPattern->get_XCount (&iXCount) ;



So you can use CComPtr<Parameter> or ParameterPtr. Here is an example of getting an integer value:


       CComPtr<Parameter> XCountParam ;

       pRectPatFeat->get_XCount (&XCountParam) ;

       const int ikXCount = XCountParam->GetValue () ;


       TRACE (L"Component %d is called %s, and the x count is %d\n",iRect,bstrName,ikXCount) ;


So you need to use GetValue().


Note that you have to look at the pointers because if there is no y count it is assumed to be 1. I assume. The following code will print out the x and y counts of a rectangular array.


       CComPtr<Parameter> pXCountParam ;

       pRangoPattern->get_XCount (&pXCountParam) ;

       int iXCount = 1 ; // Init to 1 is important

       if (pXCountParam != nullptr) {

           iXCount = pXCountParam->GetValue () ;


       CComPtr<Parameter> pYCountParam ;

       pRangoPattern->get_YCount (&pYCountParam) ;

       int iYCount = 1 ; // Init to 1 is important

       if (pYCountParam != nullptr) {

           iYCount = pYCountParam->GetValue () ;



       gLogger.Printf(ekLogMsg, L"Rect X count = %d Y count = %d",iXCount,iYCount);







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