How to get the RectangularPatterns in a PartComponentDefinition |
Top Previous Next |
What you need to remember is that a RectangularPattern is a feature, so you need to get the features of a part in order to get any rectanguar patterns inside that part.
Here is a function which lists the names of rectangular patterns inside the part parameter passed to it:
void ListRectangularPatternFeatures (CComPtr<PartComponentDefinition>& pPartCompDef) { // Get the list of features... CComPtr<PartFeatures> pFeaturesList ; pPartCompDef->get_Features(&pFeaturesList) ;
// Get the list of rectangular features, we will add to this list.... CComPtr<RectangularPatternFeatures> pRectPatList ; pFeaturesList->get_RectangularPatternFeatures (&pRectPatList) ;
const long ikNumRecFeats = pRectPatList->GetCount() ;
TRACE (L"There are %d rectangular pattern features\n",ikNumRecFeats) ;
for (int iRect = 1 ; iRect <= ikNumRecFeats ; iRect++) {
CComPtr <RectangularPatternFeature> pRectPatFeat ; pRectPatList->get_Item (CComVariant(iRect),&pRectPatFeat) ;
BSTR bstrName = pRectPatFeat->GetName () ;
TRACE (L"Component %d is called %s\n",iRect,bstrName) ;
::SysFreeString(bstrName); } }
Error checking has been removed for brevity and clarity, but, as always, you should check the return values of the various Inventor API functions.
How to add a RectangularPattern to a PartComponentDefinition. |
Text, images and diagrams © 2021 Owen F. Ransen. All rights reserved. (But copy the source code as much as you want!)