<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to get currently selected Library Part in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/How-to-get-currently-selected-Library-Part/m-p/230094#M4948</link>
    <description>Me again &lt;IMG src="https://community.graphisoft.com/legacyfs/online/emojis/icon_smile.gif" style="display : inline;" /&gt;&lt;BR /&gt;
&lt;BR /&gt;
I have finally found out what was wrong.&lt;BR /&gt;
&lt;BR /&gt;
Here is the working code (draft code...to be cleaned &lt;E&gt;&lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/E&gt; )&lt;BR /&gt;

&lt;PRE&gt;	GSErrCode err; 
	 
	// Get selected elements
	API_SelectionInfo selectionInfo; 
	API_Neig **selNeigs;
	err = ACAPI_Selection_Get (&amp;amp;selectionInfo, &amp;amp;selNeigs, false); 
	if (err == NoError) 
	{ 
		if (selectionInfo.typeID != API_SelEmpty) 
		{ 
			UInt32    ii, nSel; 
			nSel = BMGetHandleSize ((GSHandle) selNeigs) / sizeof (API_Neig); 
			for (ii = 0; ii &amp;lt; nSel &amp;amp;&amp;amp; err == NoError; ii++) 
			{ 
				GS::UniString selectedGuid = APIGuidToString((*selNeigs)[ii].guid);
				API_NeigID selectedID = (*selNeigs)[ii].neigID;
			
				API_Element  element;
				BNZeroMemory (&amp;amp;element, sizeof (API_Element));
				element.header.guid  = (*selNeigs)[ii].guid;
				err = ACAPI_Element_Get(&amp;amp;element);
				if(err == NoError)
				{
					// Find the library part
					API_LibPart libpart;
					BNZeroMemory (&amp;amp;libpart, sizeof (libpart));
					libpart.index = element.object.libInd;

					err = ACAPI_LibPart_Get (&amp;amp;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, &amp;amp;aParam, &amp;amp;bParam, &amp;amp;paramNum, &amp;amp;addPars);
						if (err == NoError) 
						{
							for (Int32 i = 0; i &amp;lt; paramNum; i++) 
							{
								GS::UniString us = (*addPars)&lt;I&gt;.uDescname;
								if(us == L"BimObject id")
								{
									
                // Todo : Do someting here

		BMKillHandle ((GSHandle *) &amp;amp;selNeigs);
									return;
								}
							}
						}
					}
				}
			} 
			BMKillHandle ((GSHandle *) &amp;amp;selNeigs);
		}
	}&lt;/I&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 02 Nov 2015 17:07:36 GMT</pubDate>
    <dc:creator>gehairing</dc:creator>
    <dc:date>2015-11-02T17:07:36Z</dc:date>
    <item>
      <title>How to get currently selected Library Part</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/How-to-get-currently-selected-Library-Part/m-p/230093#M4947</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;Hi all &lt;IMG style="display: inline;" src="https://community.graphisoft.com/legacyfs/online/emojis/icon_smile.gif" border="0" /&gt;&lt;BR /&gt;&lt;BR /&gt;I try to get the currently selected library part.&lt;BR /&gt;I mean the object selected (in green) by user in the current model.&lt;BR /&gt;&lt;BR /&gt;I have tried following code but it doesn't seem to work &lt;IMG style="display: inline;" src="https://community.graphisoft.com/legacyfs/online/emojis/icon_sad.gif" border="0" /&gt;&lt;BR /&gt;
&lt;PRE&gt;	GSErrCode err; 
	 
	// Get selected elements
	API_SelectionInfo selectionInfo; 
	API_Neig **selNeigs;
	err = ACAPI_Selection_Get (&amp;amp;selectionInfo, &amp;amp;selNeigs, false); 
	if (err == NoError) 
	{ 
		if (selectionInfo.typeID != API_SelEmpty) 
		{ 
			UInt32    ii, nSel; 
			nSel = BMGetHandleSize ((GSHandle) selNeigs) / sizeof (API_Neig); 
			for (ii = 0; ii &amp;lt; nSel &amp;amp;&amp;amp; err == NoError; ii++) 
			{ 
				GS::UniString selectedGuid = APIGuidToString((*selNeigs)[ii].guid);
				API_NeigID selectedID = (*selNeigs)[ii].neigID;
			
				API_Element  element;
				BNZeroMemory (&amp;amp;element, sizeof (API_Element));
				element.header.guid  = (*selNeigs)[ii].guid;
				err = ACAPI_Element_Get(&amp;amp;element);
				if(err == NoError)
				{
					// Find the library part
					API_LibPart libpart;
					BNZeroMemory (&amp;amp;libpart, sizeof (libpart));
					libpart.index = element.object.libInd;

					err = ACAPI_LibPart_Search (&amp;amp;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, &amp;amp;aParam, &amp;amp;bParam, &amp;amp;paramNum, &amp;amp;addPars);
						if (err == NoError) 
						{
							for (Int32 i = 0; i &amp;lt; paramNum; i++) 
							{
								if(CHCompareCStrings ("BimObject id", (*addPars)&lt;I&gt;.name) == 0)
								{
									std::wstring objectUrl = L"xxx";
									ShowPlatform(objectUrl);
									BMKillHandle ((GSHandle *) &amp;amp;selNeigs);
									return;
								}
							}
						}
					}
				}
			} 
			BMKillHandle ((GSHandle *) &amp;amp;selNeigs);
		}
	} &lt;/I&gt;&lt;/PRE&gt;
What am i doing wrong in this code ?&lt;BR /&gt;(this is a quick and dirty testing code)&lt;/DIV&gt;</description>
      <pubDate>Thu, 13 Jul 2023 12:56:53 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/How-to-get-currently-selected-Library-Part/m-p/230093#M4947</guid>
      <dc:creator>gehairing</dc:creator>
      <dc:date>2023-07-13T12:56:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to get currently selected Library Part</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/How-to-get-currently-selected-Library-Part/m-p/230094#M4948</link>
      <description>Me again &lt;IMG src="https://community.graphisoft.com/legacyfs/online/emojis/icon_smile.gif" style="display : inline;" /&gt;&lt;BR /&gt;
&lt;BR /&gt;
I have finally found out what was wrong.&lt;BR /&gt;
&lt;BR /&gt;
Here is the working code (draft code...to be cleaned &lt;E&gt;&lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/E&gt; )&lt;BR /&gt;

&lt;PRE&gt;	GSErrCode err; 
	 
	// Get selected elements
	API_SelectionInfo selectionInfo; 
	API_Neig **selNeigs;
	err = ACAPI_Selection_Get (&amp;amp;selectionInfo, &amp;amp;selNeigs, false); 
	if (err == NoError) 
	{ 
		if (selectionInfo.typeID != API_SelEmpty) 
		{ 
			UInt32    ii, nSel; 
			nSel = BMGetHandleSize ((GSHandle) selNeigs) / sizeof (API_Neig); 
			for (ii = 0; ii &amp;lt; nSel &amp;amp;&amp;amp; err == NoError; ii++) 
			{ 
				GS::UniString selectedGuid = APIGuidToString((*selNeigs)[ii].guid);
				API_NeigID selectedID = (*selNeigs)[ii].neigID;
			
				API_Element  element;
				BNZeroMemory (&amp;amp;element, sizeof (API_Element));
				element.header.guid  = (*selNeigs)[ii].guid;
				err = ACAPI_Element_Get(&amp;amp;element);
				if(err == NoError)
				{
					// Find the library part
					API_LibPart libpart;
					BNZeroMemory (&amp;amp;libpart, sizeof (libpart));
					libpart.index = element.object.libInd;

					err = ACAPI_LibPart_Get (&amp;amp;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, &amp;amp;aParam, &amp;amp;bParam, &amp;amp;paramNum, &amp;amp;addPars);
						if (err == NoError) 
						{
							for (Int32 i = 0; i &amp;lt; paramNum; i++) 
							{
								GS::UniString us = (*addPars)&lt;I&gt;.uDescname;
								if(us == L"BimObject id")
								{
									
                // Todo : Do someting here

		BMKillHandle ((GSHandle *) &amp;amp;selNeigs);
									return;
								}
							}
						}
					}
				}
			} 
			BMKillHandle ((GSHandle *) &amp;amp;selNeigs);
		}
	}&lt;/I&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 02 Nov 2015 17:07:36 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/How-to-get-currently-selected-Library-Part/m-p/230094#M4948</guid>
      <dc:creator>gehairing</dc:creator>
      <dc:date>2015-11-02T17:07:36Z</dc:date>
    </item>
  </channel>
</rss>

