Quantcast
Channel: ArchiCAD-Talk - Developer Forum
Viewing all articles
Browse latest Browse all 564

How to get currently selected Library Part

$
0
0
Author:gehairing
Posted: Mon Nov 02, 2015 6:07 pm (GMT+1)


Me again Smile

I have finally found out what was wrong.

Here is the working code (draft code...to be cleaned Wink )

Code:
   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, &paramNum, &addPars);
                  if (err == NoError)
                  {
                     for (Int32 i = 0; i < paramNum; i++)
                     {
                        GS::UniString us = (*addPars)[i].uDescname;
                        if(us == L"BimObject id")
                        {
                           
                // Todo : Do someting here

      BMKillHandle ((GSHandle *) &selNeigs);
                           return;
                        }
                     }
                  }
               }
            }
         }
         BMKillHandle ((GSHandle *) &selNeigs);
      }
   }


Viewing all articles
Browse latest Browse all 564

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>