Listing iProperties of an Inventor document

Top  Previous  Next

This will list the iProperties of an Inventor document:

 

// iProperties listing function. Needs a DOC not a PART or ASSEMBLY

void ListIProperties(CComPtr<Document>& pInventorDoc)

{

   CComPtr <PropertySets> pPropSets;

   pInventorDoc->get_PropertySets(&pPropSets);

 

   const long ikNumSets = pPropSets->Count;

 

   // There are several sets of properties, loop over the sets...

   for (long iSet = 1; iSet <= ikNumSets; iSet++) {

       CComPtr<PropertySet> pPropSet;

       pPropSets->get_Item(CComVariant(iSet), &pPropSet);

 

       CComBSTR bstrPropSetName;

       pPropSet->get_Name(&bstrPropSetName);

       CString csPropSetName(bstrPropSetName);

 

       // Loop over the properties of this property set...

       const long ikNumProps = pPropSet->Count;

 

       for (long iProp = 1; iProp <= ikNumProps; iProp++) {

           CComPtr<Property> pThisProp;

           pPropSet->get_Item(CComVariant(iProp), &pThisProp);

 

           _bstr_t bstrPropName = pThisProp->GetDisplayName();

 

           CString csPropName(bstrPropName.GetBSTR());

 

           CComVariant varValue;

           pThisProp->get_Value(&varValue);

 

           // Add more VT_... values for more detail...

           CString csValue;

           if (varValue.vt == VT_BSTR) {

               csValue = CString(varValue.bstrVal);

 

           } else if (varValue.vt == VT_I4) {

               csValue.Format(L"%d", varValue.intVal);

 

           } else {

               csValue.Format(L"vt=%d", varValue.vt);

           }

 

           gLogger.Printf(ekLogMsg, L"<%s> %03d %s  value=%s", csPropSetName, iProp, csPropName, csValue);

       }

   }

}

 

 

You can check for different values of varValue.vt to see different types of properties.

 

You'll get an output something like this:

 

<Design Tracking Properties> 044 FlatPatternExtentsWidth  value=vt=5

<Design Tracking Properties> 045 FlatPatternExtentsLength  value=vt=5

<Design Tracking Properties> 046 FlatPatternExtentsArea  value=vt=5

<Design Tracking Properties> 047 SheetMetalRule  value=

<Design Tracking Properties> 048 LastUpdatedWith  value=2017 (Build 210142000, 142)

<Design Tracking Properties> 049 SheetMetalWidth  value=

<Design Tracking Properties> 050 SheetMetalLength  value=

<Design Tracking Properties> 051 SheetMetalArea  value=

<Design Tracking Properties> 053 Appearance  value=Copper - Satin

<Design Tracking Properties> 054 Flat Pattern Defer Update  value=vt=11

<Inventor User Defined Properties> 001 TC_THICK  value=

<Inventor User Defined Properties> 002 TC_Testing Pressure  value=vt=5

<Inventor User Defined Properties> 003 TC_TO_APPROVER  value=

<Inventor User Defined Properties> 004 TC_CHANGE_NUMBER  value=

<Inventor User Defined Properties> 005 TC_CHANGE_REASON  value=

<Inventor User Defined Properties> 006 TC_CUST_MAT_CODE  value=

<Inventor User Defined Properties> 007 TC_DATE_CREAT  value=19/12/2017

<Inventor User Defined Properties> 008 TC_DATE_DRAWN  value=23/05/2018

<Inventor User Defined Properties> 009 TC_CUST_DWG_NO  value=

<Inventor User Defined Properties> 010 TC_CUSTOMERS  value=

<Inventor User Defined Properties> 011 TC_NOTE  value=

<Inventor User Defined Properties> 012 TC_ORDNO  value=

<Inventor User Defined Properties> 013 TC_MATERIAL  value=

<Inventor User Defined Properties> 014 TC_UOM  value=

<Inventor User Defined Properties> 015 TC_TO_APPROVAL_DATE  value=

 

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