狮猿社CATIA

CATIA caa获取文档的属性

2020-01-19  本文已影响0人  锦囊喵

原文链接

  //----------------------------------------------------------------------
    // 4-dump Attributes
    //----------------------------------------------------------------------    
    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;
        }
    }
上一篇下一篇

猜你喜欢

热点阅读