<?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: Code to select elements in Archicad by GUIDs from clipboard in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/Code-to-select-elements-in-Archicad-by-GUIDs-from-clipboard/m-p/223128#M3714</link>
    <description>I recommend you this new blog post at our API Site:&lt;BR /&gt;
&lt;A href="http://archicadapi.graphisoft.com/browser-control-and-javascript-connection" target="_blank"&gt;&lt;LINK_TEXT text="http://archicadapi.graphisoft.com/brows ... connection"&gt;http://archicadapi.graphisoft.com/browser-control-and-javascript-connection&lt;/LINK_TEXT&gt;&lt;/A&gt;&lt;BR /&gt;
Especially the video in it demonstrates something similar what you wanted to implement (select element by GUID from clipboard):&lt;BR /&gt;
&lt;A href="https://ttprivatenew.s3.amazonaws.com/pulse/lorantfyt/attachments/11509975/browser_control_example.mp4" target="_blank"&gt;&lt;LINK_TEXT text="https://ttprivatenew.s3.amazonaws.com/p ... xample.mp4"&gt;https://ttprivatenew.s3.amazonaws.com/pulse/lorantfyt/attachments/11509975/browser_control_example.mp4&lt;/LINK_TEXT&gt;&lt;/A&gt;</description>
    <pubDate>Thu, 19 Sep 2019 09:36:18 GMT</pubDate>
    <dc:creator>Tibor Lorantfy</dc:creator>
    <dc:date>2019-09-19T09:36:18Z</dc:date>
    <item>
      <title>Code to select elements in Archicad by GUIDs from clipboard</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Code-to-select-elements-in-Archicad-by-GUIDs-from-clipboard/m-p/223119#M3705</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;Is it possible to select elements in Archicad by GUID/s from the clipboard? GUIDs will be copied to the clipboard with line breaks.&lt;BR /&gt;&lt;BR /&gt;I have played with the code given in the examples to select walls from excel sheet without a success.&lt;BR /&gt;
&lt;PRE&gt; static void	Do_SelectWallsFromExcel(void)
{
	DBPrintf("Selecting walls based on Excel document...\n");

	GS::Array&amp;lt;API_Guid&amp;gt; apiguids;
	ACAPI_Goodies(APIAny_GetSelectedElementID, &amp;amp;apiguids);
	GS::Array&amp;lt;API_Guid&amp;gt; selection;

	libxl::Book* book = xlCreateXMLBook();
	if (DBERROR(book == nullptr))
		return;

	IO::Location location;
	IO::fileSystem.GetSpecialLocation(IO::FileSystem::UserDocuments, &amp;amp;location);
	location.AppendToLocal(IO::Name("export.xlsx"));
	GS::UniString filepath;
	location.ToPath(&amp;amp;filepath);

	bool loaded = book-&amp;gt;load(UNISTR_TO_LIBXLSTR(filepath));
	if (DBERROR(!loaded))
		return;

	libxl::Sheet* sheet = book-&amp;gt;getSheet(0);
	if (DBERROR(sheet == nullptr))
		return;

	for (int i = 0; i &amp;lt; sheet-&amp;gt;lastRow(); ++i) {
		GS::Guid xlGsGuid;
		const auto* cellContentPtr = sheet-&amp;gt;readStr(i, 0);
		if (cellContentPtr == nullptr)
			continue;

		GSErrCode err = xlGsGuid.ConvertFromString(cellContentPtr);
		if (err != NoError)
			continue;

		API_Guid xlApiGuid = GSGuid2APIGuid(xlGsGuid);
		if (!apiguids.Contains(xlApiGuid))
			continue;
		selection.Push(xlApiGuid);
	}

	book-&amp;gt;release();

	USize selCount = selection.GetSize();
	API_Neig** selNeig = (API_Neig**)(BMAllocateHandle(selCount * sizeof(API_Neig), ALLOCATE_CLEAR, 0));
	for (UIndex i = 0; i &amp;lt; selCount; ++i) {
		(*selNeig)&lt;I&gt;.neigID = APINeig_Wall;
		(*selNeig)&lt;I&gt;.guid = selection&lt;I&gt;;
	}

	GSErrCode err = ACAPI_Element_Select(selNeig, selCount, true);
	if (DBERROR(err != NoError))
		DBPrintf("Selection of %d wall(s) failed.\n", selCount);
	else
		DBPrintf("%d walls successfully selected\n", selCount);
	BMKillHandle(reinterpret_cast&amp;lt;GSHandle*&amp;gt; (&amp;amp;selNeig));
}
&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;
&lt;/DIV&gt;</description>
      <pubDate>Wed, 05 Oct 2022 11:28:18 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Code-to-select-elements-in-Archicad-by-GUIDs-from-clipboard/m-p/223119#M3705</guid>
      <dc:creator>SajW</dc:creator>
      <dc:date>2022-10-05T11:28:18Z</dc:date>
    </item>
    <item>
      <title>Re: Code to select elements in Archicad by GUIDs from clipboard</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Code-to-select-elements-in-Archicad-by-GUIDs-from-clipboard/m-p/223120#M3706</link>
      <description>Hi SajW,&lt;BR /&gt;
&lt;BR /&gt;
I can see that you copied this code from the Database_Control example Add-On and you changed few lines.&lt;BR /&gt;
I don't understand why you made this change:
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;GS::Array&amp;lt;API_Guid&amp;gt; apiguids;
// Original line from Database_Control example Add-On:
ACAPI_Element_GetElemList (API_WallID, &amp;amp;apiguids);
// Changed line by SajW:
ACAPI_Goodies (APIAny_GetSelectedElementID, &amp;amp;apiguids);&lt;/PRE&gt;
If you revert this change, then it should work &lt;IMG src="https://community.graphisoft.com/legacyfs/online/emojis/icon_smile.gif" style="display : inline;" /&gt; Make sure that the Excel table contains the GUIDs of the exisiting placed walls.&lt;BR /&gt;

&lt;BLOCKQUOTE&gt;SajW wrote:&lt;BR /&gt;Is it possible to select elements in archiCAD by GUID/s from the clipboard? GUIDs will be copied to the clipboard with line breaks.&lt;/BLOCKQUOTE&gt;

Easy peasy &lt;E&gt;&lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/E&gt;&lt;BR /&gt;
These few lines will do the job for you:&lt;BR /&gt;

&lt;PRE&gt;static GSErrCode	SelectWallsFromClipboard (const GS::UniString&amp;amp; clipboardString)
{
	GS::Array&amp;lt;GS::UniString&amp;gt; guidStrings;
	clipboardString.Split ("\n", GS::UniString::SkipEmptyParts, &amp;amp;guidStrings);

	const USize count = guidStrings.GetSize ();
	API_Neig** neigs = (API_Neig**) (BMAllocateHandle (count * sizeof (API_Neig), ALLOCATE_CLEAR, 0));
	for (UIndex i = 0; i &amp;lt; count; ++i) {
		(*neigs)&lt;I&gt;.guid = APIGuidFromString (guidStrings&lt;I&gt;.ToCStr ().Get ());
	}

	GSErrCode err = ACAPI_Element_Select (neigs, count, true);
	BMKillHandle (reinterpret_cast&amp;lt;GSHandle*&amp;gt; (&amp;amp;neigs));
	return err;
}&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 May 2019 19:56:51 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Code-to-select-elements-in-Archicad-by-GUIDs-from-clipboard/m-p/223120#M3706</guid>
      <dc:creator>Tibor Lorantfy</dc:creator>
      <dc:date>2019-05-14T19:56:51Z</dc:date>
    </item>
    <item>
      <title>Re: Code to select elements in Archicad by GUIDs from clipboard</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Code-to-select-elements-in-Archicad-by-GUIDs-from-clipboard/m-p/223121#M3707</link>
      <description>&lt;PRE&gt;static GSErrCode	SelectWallsFromClipboard (const GS::UniString&amp;amp; clipboardString)
{
	GS::Array&amp;lt;GS::UniString&amp;gt; guidStrings;
	clipboardString.Split ("\n", GS::UniString::SkipEmptyParts, &amp;amp;guidStrings);

	const USize count = guidStrings.GetSize ();
	API_Neig** neigs = (API_Neig**) (BMAllocateHandle (count * sizeof (API_Neig), ALLOCATE_CLEAR, 0));
	for (UIndex i = 0; i &amp;lt; count; ++i) {
		(*neigs)&lt;I&gt;.guid = APIGuidFromString (guidStrings&lt;I&gt;.ToCStr ().Get ());
	}

	GSErrCode err = ACAPI_Element_Select (neigs, count, true);
	BMKillHandle (reinterpret_cast&amp;lt;GSHandle*&amp;gt; (&amp;amp;neigs));
	return err;
}&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;

Thanks for this code, but I am having trouble calling this function.. How do I call it?</description>
      <pubDate>Tue, 21 May 2019 02:55:44 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Code-to-select-elements-in-Archicad-by-GUIDs-from-clipboard/m-p/223121#M3707</guid>
      <dc:creator>SajW</dc:creator>
      <dc:date>2019-05-21T02:55:44Z</dc:date>
    </item>
    <item>
      <title>Re: Code to select elements in Archicad by GUIDs from clipboard</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Code-to-select-elements-in-Archicad-by-GUIDs-from-clipboard/m-p/223122#M3708</link>
      <description>&lt;BLOCKQUOTE&gt;SajW wrote:&lt;BR /&gt;
Thanks for this code, but I am having trouble calling this function.. How do I call it?
&lt;/BLOCKQUOTE&gt;

&lt;BR /&gt;
Simply call it this way:
&lt;PRE&gt;// Get string from clipboard
GS::UniString clipboardString;
Clipboard::GetInstance ().GetUniString (Clipboard::uniTextTypeId, clipboardString);

// Call the function by passing the string from clipboard
SelectWallsFromClipboard (clipboardString);&lt;/PRE&gt;

Update:&lt;BR /&gt;
After we investigated SajW's issue, we figured it out that Clipboard::uniTextTypeId value should be used as first parameter when calling Clipboard::GetUniString function (and make sure to use the same value if you are using Clipboard::SetUniString function also).</description>
      <pubDate>Tue, 21 May 2019 06:43:36 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Code-to-select-elements-in-Archicad-by-GUIDs-from-clipboard/m-p/223122#M3708</guid>
      <dc:creator>Tibor Lorantfy</dc:creator>
      <dc:date>2019-05-21T06:43:36Z</dc:date>
    </item>
    <item>
      <title>Re: Code to select elements in Archicad by GUIDs from clipboard</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Code-to-select-elements-in-Archicad-by-GUIDs-from-clipboard/m-p/223123#M3709</link>
      <description>This code does not work for me.. does nothing.. were you able to test it?&lt;BR /&gt;
I have tried to call the function but does not work. Can you explain about the return type of the calling.</description>
      <pubDate>Fri, 24 May 2019 03:29:27 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Code-to-select-elements-in-Archicad-by-GUIDs-from-clipboard/m-p/223123#M3709</guid>
      <dc:creator>SajW</dc:creator>
      <dc:date>2019-05-24T03:29:27Z</dc:date>
    </item>
    <item>
      <title>Re: Code to select elements in Archicad by GUIDs from clipboard</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Code-to-select-elements-in-Archicad-by-GUIDs-from-clipboard/m-p/223124#M3710</link>
      <description>&lt;PRE&gt; void	Do_SelectWallsFromExcel(void)
{

	 GS::UniString clipboardString;
	 Clipboard::GetInstance().GetUniString(Clipboard::textTypeId, clipboardString);

	// Call the function by passing the string from clipboard
	SelectWallsFromClipboard(clipboardString);

}&lt;/PRE&gt;

I tried to call it inside the Database_control example Do_SelectWallsFromExcel, but I cannot get it working</description>
      <pubDate>Fri, 24 May 2019 07:14:55 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Code-to-select-elements-in-Archicad-by-GUIDs-from-clipboard/m-p/223124#M3710</guid>
      <dc:creator>SajW</dc:creator>
      <dc:date>2019-05-24T07:14:55Z</dc:date>
    </item>
    <item>
      <title>Re: Code to select elements in Archicad by GUIDs from clipboard</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Code-to-select-elements-in-Archicad-by-GUIDs-from-clipboard/m-p/223125#M3711</link>
      <description>&lt;BLOCKQUOTE&gt;SajW wrote:&lt;BR /&gt;I have tried to call the function but does not work.&lt;/BLOCKQUOTE&gt;

Are you sure the clipboard contains GUIDs of existing elements separated by a '\n' character?&lt;BR /&gt;
When you debug the code, what is the content of the guidString array inside the SelectWallsFromClipboard functions?</description>
      <pubDate>Fri, 24 May 2019 07:50:42 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Code-to-select-elements-in-Archicad-by-GUIDs-from-clipboard/m-p/223125#M3711</guid>
      <dc:creator>Tibor Lorantfy</dc:creator>
      <dc:date>2019-05-24T07:50:42Z</dc:date>
    </item>
    <item>
      <title>Re: Code to select elements in Archicad by GUIDs from clipboard</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Code-to-select-elements-in-Archicad-by-GUIDs-from-clipboard/m-p/223126#M3712</link>
      <description>I have the values seperated by \n.&lt;BR /&gt;
&lt;BR /&gt;
however there is this warning,&lt;BR /&gt;
&lt;BR /&gt;
Severity	Code	Description	Project	File	Line	Suppression State&lt;BR /&gt;
Warning	LNK4099	PDB 'API_c.pdb' was not found with 'ACAP_STATD.lib(ACAPlib.obj)' or at 'C:\Program Files\GRAPHISOFT\API Development Kit 22.3004\Examples\Database_Control\Build\x64\Debug\API_c.pdb'; linking object as if no debug info	Database_Control	C:\Program Files\GRAPHISOFT\API Development Kit 22.3004\Examples\Database_Control\ACAP_STATD.lib(ACAPlib.obj)	1</description>
      <pubDate>Fri, 24 May 2019 09:31:05 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Code-to-select-elements-in-Archicad-by-GUIDs-from-clipboard/m-p/223126#M3712</guid>
      <dc:creator>SajW</dc:creator>
      <dc:date>2019-05-24T09:31:05Z</dc:date>
    </item>
    <item>
      <title>Re: Code to select elements in Archicad by GUIDs from clipboard</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Code-to-select-elements-in-Archicad-by-GUIDs-from-clipboard/m-p/223127#M3713</link>
      <description>&lt;BLOCKQUOTE&gt;Tibor wrote:&lt;BR /&gt;
&lt;BR /&gt;
Are you sure the clipboard contains GUIDs of existing elements separated by a '\n' character?&lt;BR /&gt;
When you debug the code, what is the content of the guidString array inside the SelectWallsFromClipboard functions?
&lt;/BLOCKQUOTE&gt;

Value of guidStrings array is something like this.&lt;BR /&gt;
&lt;BR /&gt;
[1] ({"㉄㤹䐷ㄹ㈭䘵ⵆ㘴䐳䄭䘸ⵅ㔶㤹㤰㈳㐶㍆湜䔲䕆䄰㘰䔭うⵂ㠴㥅䈭㘲ⴶ㘸䈹䉁䐹㠸"})&lt;BR /&gt;
&lt;BR /&gt;
I think the clipboard value has been converted to some other characters.</description>
      <pubDate>Mon, 10 Jun 2019 09:48:15 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Code-to-select-elements-in-Archicad-by-GUIDs-from-clipboard/m-p/223127#M3713</guid>
      <dc:creator>SajW</dc:creator>
      <dc:date>2019-06-10T09:48:15Z</dc:date>
    </item>
    <item>
      <title>Re: Code to select elements in Archicad by GUIDs from clipboard</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Code-to-select-elements-in-Archicad-by-GUIDs-from-clipboard/m-p/223128#M3714</link>
      <description>I recommend you this new blog post at our API Site:&lt;BR /&gt;
&lt;A href="http://archicadapi.graphisoft.com/browser-control-and-javascript-connection" target="_blank"&gt;&lt;LINK_TEXT text="http://archicadapi.graphisoft.com/brows ... connection"&gt;http://archicadapi.graphisoft.com/browser-control-and-javascript-connection&lt;/LINK_TEXT&gt;&lt;/A&gt;&lt;BR /&gt;
Especially the video in it demonstrates something similar what you wanted to implement (select element by GUID from clipboard):&lt;BR /&gt;
&lt;A href="https://ttprivatenew.s3.amazonaws.com/pulse/lorantfyt/attachments/11509975/browser_control_example.mp4" target="_blank"&gt;&lt;LINK_TEXT text="https://ttprivatenew.s3.amazonaws.com/p ... xample.mp4"&gt;https://ttprivatenew.s3.amazonaws.com/pulse/lorantfyt/attachments/11509975/browser_control_example.mp4&lt;/LINK_TEXT&gt;&lt;/A&gt;</description>
      <pubDate>Thu, 19 Sep 2019 09:36:18 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Code-to-select-elements-in-Archicad-by-GUIDs-from-clipboard/m-p/223128#M3714</guid>
      <dc:creator>Tibor Lorantfy</dc:creator>
      <dc:date>2019-09-19T09:36:18Z</dc:date>
    </item>
  </channel>
</rss>

