//---------------------------------------------------------------------- // 获取属性 //----------------------------------------------------------------------
CATIAttributesDescription *piAttrDesc = NULL;
rc = spRootProduct->QueryInterface(IID_CATIAttributesDescription, (void **) &piAttrDesc);
if (FAILED(rc) || (NULL == piAttrDesc)) {
cout << "QueryInterface CATIAttributesDescription error" << endl;
return 4;
}
CATIInstance *piInstance = NULL;
rc = spRootProduct->QueryInterface(IID_CATIInstance, (void **) &piInstance);
if (FAILED(rc) || (NULL == piInstance)) {
cout << "QueryInterface CATIInstance error" << endl;
return 4;
}
CATListValCATAttributeInfos attrInfoList;
piAttrDesc->List(&attrInfoList);
for (int i = 1; i <= attrInfoList.Size(); i++) {
CATAttributeInfos attrInfo = attrInfoList[i];
const CATUnicodeString& propertyName = attrInfo.Name();
const CATUnicodeString& valueType = attrInfo.Type()->Name();
CATIValue *pValue = piInstance->GetValue(propertyName);
CATUnicodeString value = "";
pValue->AsString(value);
cout << propertyName << "-" << valueType << "-" << value << endl;
if (pValue) {
pValue->Release();
pValue = NULL;
}
}