2009-09-24 04:18 AM - last edited on 2023-08-03 01:40 PM by Doreena Deng
static GSErrCode CycleZoneObjects ( const long index, const char *floor_param, const char *floor_type ) { GSErrCode lastErr; API_RoomRelation relData; API_ElemTypeID typeID; long ind; char buffer[256]; API_Element element; API_ElementMemo memo; typeID = API_ObjectID; lastErr = ACAPI_Element_GetRelations (API_ZoneID, index, typeID, &relData); if ( lastErr != NoError ) return lastErr; sprintf ( buffer, "Found %d Related Objects", relData.nObject ); WriteReport_Alert( buffer, true ); //continue; { for ( ind=0; ind < relData.nObject; ind++) { BNZeroMemory (&element, sizeof (API_Element)); element.header.typeID = typeID; element.header.index = (long) relData.objects[ind]; //Here the object index I get seems to be invalid. lastErr = ACAPI_Element_Get ( &element ); if (lastErr == NoError ) { lastErr = ACAPI_Element_GetMemo_Masked ( element.header.typeID, element.header.index, APIMemoMask_AddPars, &memo); SetFloorParValue ( &memo.params, floor_param, floor_type); ACAPI_DisposeElemMemoHdls (&memo); } if (lastErr != NoError ) WriteReport_Alert("ACAPI_Element_Get/Memo in ZoneObjects Error", true ); } } ACAPI_DisposeRoomRelationHdls (&relData); return lastErr; } static GSErrCode CycleZones ( void) { GSErrCode lastErr; API_ElemTypeID typeID; API_Element elem; API_ElementMemo elemMemo; long nElem, i; char floor_param[] = "floor_f"; char floor_type[50]; char buffer[256]; typeID = API_ZoneID; lastErr = ACAPI_Element_GetNum (typeID, &nElem); if (lastErr != NoError) return lastErr; sprintf ( buffer, "Found %ld Zones", nElem ); WriteReport_Alert( buffer, true ); for (i = 1; i <= nElem && !lastErr; i++) { if (!ACAPI_Element_Filter (typeID, i, APIFilt_OnVisLayer | APIFilt_OnActFloor)) continue; BNZeroMemory (&elem, sizeof (API_Element)); elem.header.typeID = typeID; elem.header.index = i; lastErr = ACAPI_Element_Get (&elem); if (lastErr == NoError && elem.header.hasMemo) { lastErr = ACAPI_Element_GetMemo_Masked ( typeID, i, APIMemoMask_AddPars, &elemMemo); /* Custom element processing */ GetFloorParValue ( &elemMemo.params, floor_param, floor_type); if (CHEqualASCII(floor_type, "Tiles", CS_CaseInsensitive) || CHEqualASCII(floor_type, "Carpet", CS_CaseInsensitive) ) { sprintf(buffer, "The floor type is %s\n", floor_type); WriteReport_Alert(buffer, true); CycleZoneObjects ( elem.header.index, floor_param, floor_type ); } ACAPI_DisposeElemMemoHdls (&elemMemo); } } return lastErr; } static void DoZoneCycling (void) { CycleZones(); return; }I am having trouble getting the right object index from API_RoomRelation structure. When I pass the object index to ACAPI_Element_Get, I am getting error 13 which is not in the error list.
2009-09-24 11:09 AM
suresha wrote:The error is actually 1 line above where you discover the problem.element.header.index = (long) relData.objects[ind]; //Here the object index I get seems to be invalid. lastErr = ACAPI_Element_Get ( &element );When I pass the object index to ACAPI_Element_Get, I am getting error 13 which is not in the error list.
element.header.index = (long) relData.objects[ind];...you should write:
element.header.index = (*relData.objects)[ind];
2009-09-24 01:40 PM