[SOLVED] API_BuildingMaterialType->id crashes
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2016-06-28
12:02 PM
- last edited on
2023-07-12
09:06 PM
by
Doreena Deng
2016-06-28
12:02 PM
I am trying to access the ID of a building material through API_BuildingMaterialType.id. But the returned attribute got a null value for the id (also for manufacturer and description). (EDIT: And also on API_Attribute.header->uniStringNamePtr)
short cnt; ACAPI_Attribute_GetNum(API_BuildingMaterialID, &cnt); cnt++; for (short i = 1; i < cnt; i++) { API_Attribute attr; BNZeroMemory(&attr, sizeof(API_Attribute)); attr.header.typeID = API_BuildingMaterialID; attr.header.index = i; err = ACAPI_Attribute_Get(&attr); if (err != NoError) continue; API_BuildingMaterialType bm = attr.buildingMaterial; if (!bm.id->IsEmpty()) // <----------- crashes when accessed //... //... }This is for both AC18 and AC19.
~ReignBough~
ARCHICAD 27 INT (since AC18)
Windows 11 Pro, AMD Ryzen 7, 3.20GHz, 32.0GB RAM, 64-bit OS
ARCHICAD 27 INT (since AC18)
Windows 11 Pro, AMD Ryzen 7, 3.20GHz, 32.0GB RAM, 64-bit OS
Labels:
- Labels:
-
Add-On (C++)
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2016-07-01 04:42 AM
2016-07-01
04:42 AM
The solution for this is to pass a pointer to a valid GS::UniString variable in the ‘id’ field:
GS::UniString attrId; ACAPI_Attribute attr; BNZeroMemory (&attr, sizeof (attr)); attr.header.typeID = API_BuildingMaterialID; attr.header.index = ….; attr.buildingMaterial.id = &attrId; if (ACAPI_Attribute_Get (&attr) == NoError) { //... code here ... }This works similarly for ‘manufacturer’ and ‘description’.
~ReignBough~
ARCHICAD 27 INT (since AC18)
Windows 11 Pro, AMD Ryzen 7, 3.20GHz, 32.0GB RAM, 64-bit OS
ARCHICAD 27 INT (since AC18)
Windows 11 Pro, AMD Ryzen 7, 3.20GHz, 32.0GB RAM, 64-bit OS