2015-11-02 05:25 PM - last edited on 2023-07-13 02:56 PM by Doreena Deng
GSErrCode err; // Get selected elements API_SelectionInfo selectionInfo; API_Neig **selNeigs; err = ACAPI_Selection_Get (&selectionInfo, &selNeigs, false); if (err == NoError) { if (selectionInfo.typeID != API_SelEmpty) { UInt32 ii, nSel; nSel = BMGetHandleSize ((GSHandle) selNeigs) / sizeof (API_Neig); for (ii = 0; ii < nSel && err == NoError; ii++) { GS::UniString selectedGuid = APIGuidToString((*selNeigs)[ii].guid); API_NeigID selectedID = (*selNeigs)[ii].neigID; API_Element element; BNZeroMemory (&element, sizeof (API_Element)); element.header.guid = (*selNeigs)[ii].guid; err = ACAPI_Element_Get(&element); if(err == NoError) { // Find the library part API_LibPart libpart; BNZeroMemory (&libpart, sizeof (libpart)); libpart.index = element.object.libInd; err = ACAPI_LibPart_Search (&libpart, false); if (err == NoError) { double aParam = 0.0; double bParam = 0.0; Int32 paramNum = 0; API_AddParType** addPars = NULL; err = ACAPI_LibPart_GetParams (libpart.index, &aParam, &bParam, ¶mNum, &addPars); if (err == NoError) { for (Int32 i = 0; i < paramNum; i++) { if(CHCompareCStrings ("BimObject id", (*addPars).name) == 0) { std::wstring objectUrl = L"xxx"; ShowPlatform(objectUrl); BMKillHandle ((GSHandle *) &selNeigs); return; } } } } } } BMKillHandle ((GSHandle *) &selNeigs); } }What am i doing wrong in this code ?
2015-11-02 06:07 PM
GSErrCode err; // Get selected elements API_SelectionInfo selectionInfo; API_Neig **selNeigs; err = ACAPI_Selection_Get (&selectionInfo, &selNeigs, false); if (err == NoError) { if (selectionInfo.typeID != API_SelEmpty) { UInt32 ii, nSel; nSel = BMGetHandleSize ((GSHandle) selNeigs) / sizeof (API_Neig); for (ii = 0; ii < nSel && err == NoError; ii++) { GS::UniString selectedGuid = APIGuidToString((*selNeigs)[ii].guid); API_NeigID selectedID = (*selNeigs)[ii].neigID; API_Element element; BNZeroMemory (&element, sizeof (API_Element)); element.header.guid = (*selNeigs)[ii].guid; err = ACAPI_Element_Get(&element); if(err == NoError) { // Find the library part API_LibPart libpart; BNZeroMemory (&libpart, sizeof (libpart)); libpart.index = element.object.libInd; err = ACAPI_LibPart_Get (&libpart); if (err == NoError) { double aParam = 0.0; double bParam = 0.0; Int32 paramNum = 0; API_AddParType** addPars = NULL; err = ACAPI_LibPart_GetParams (libpart.index, &aParam, &bParam, ¶mNum, &addPars); if (err == NoError) { for (Int32 i = 0; i < paramNum; i++) { GS::UniString us = (*addPars).uDescname; if(us == L"BimObject id") { // Todo : Do someting here BMKillHandle ((GSHandle *) &selNeigs); return; } } } } } } BMKillHandle ((GSHandle *) &selNeigs); } }