Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void TestGetAttribute(const IModelObjectPtr mdlobj) {
- assert(mdlobj, "Model object not defined");
- IPropertyMngPtr propmng(GetKompas());
- IPropertyPtr prop = propmng->GetProperty({}, L"ADEM Тип геометрии");
- std::vector<IBody7Ptr> bodies;
- //-----------------------GetResultBodies7-----------------------
- bool res = false;
- bodies.clear();
- if (mdlobj)
- {
- IFeature7Ptr objFeature7(mdlobj->GetOwner());
- if (objFeature7)
- {
- _bstr_t name = objFeature7->Name;
- MessageT(name);
- _variant_t arr = objFeature7->GetResultBodies();
- if (arr.vt == (VT_ARRAY | VT_DISPATCH))
- {
- long iUBound = 0, iLBound = 0;
- ::SafeArrayGetUBound(const_cast<SAFEARRAY*>(V_ARRAY(&arr)), 1, &iUBound); // Верхняя граница массива
- ::SafeArrayGetLBound(const_cast<SAFEARRAY*>(V_ARRAY(&arr)), 1, &iLBound); // Нижняя граница массива
- long count = iUBound - iLBound + 1; // Кол-во элементов в массиве
- for (long i = 0; i < count; i++) // Пройдём по всем объектам массива
- {
- IDispatchPtr el(nullptr);
- ::SafeArrayGetElement(V_ARRAY(&arr), &i, &el);
- bodies.push_back(IBody7Ptr(el));
- }
- }
- else if (arr.vt == VT_DISPATCH)
- bodies.push_back(IBody7Ptr(arr.pdispVal));
- res = true;
- }
- else
- ASSERT(FALSE); // Где?
- }
- //-----------------------GetResultBodies7-----------------------
- IBody7Ptr body(bodies.size() == 1 ? bodies[0] : nullptr);
- IPropertyKeeperPtr propkprbody = body;
- IPropertyKeeperPtr propkprpart = mdlobj->Part;
- _variant_t valbody, valpart;
- if (propkprbody) {
- propkprbody->GetPropertyValue(prop, &valbody, true, {});
- }
- else if (propkprpart) {
- propkprpart->GetPropertyValue(prop, &valpart, true, {});
- }
- VARIANT Value = valbody.vt != VT_EMPTY ? valbody : valpart;
- TCHAR buf[255];
- _stprintf_s(buf, _T("Value = %d"), Value.iVal);
- Value.vt == VT_EMPTY ? MessageT(L"Empty Value") : MessageT(buf);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement