<?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: Copy the GUID/s of the current selection(single or multiple objects) to Clipboard in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/Copy-the-GUID-s-of-the-current-selection-single-or-multiple/m-p/219027#M3689</link>
    <description>&lt;LI-CODE lang="cpp"&gt;static void CopyGUIDsOfCurrentSelectionToClipboard()
{
	GS::UniString string;

	const GS::Array&amp;lt;API_Guid&amp;gt;	guidsOfCurrentSelection = GetSelectedElements();
	for (UIndex ii = 0; ii &amp;lt; guidsOfCurrentSelection.GetSize(); ++ii) {
		string += APIGuidToString(guidsOfCurrentSelection[ii]) + '\n';
	}

	Clipboard::GetInstance().Empty();
	Clipboard::GetInstance().SetUniString(Clipboard::uniTextTypeId, string);
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It works.&lt;BR /&gt;I had to call Empty() as well.&lt;/P&gt;</description>
    <pubDate>Sun, 19 Sep 2021 12:59:26 GMT</pubDate>
    <dc:creator>SajW</dc:creator>
    <dc:date>2021-09-19T12:59:26Z</dc:date>
    <item>
      <title>Copy the GUID/s of the current selection(single or multiple objects) to Clipboard</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Copy-the-GUID-s-of-the-current-selection-single-or-multiple/m-p/219023#M3685</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;Can someone help me to write the code to Copy the GUID/s of the current selection(single or multiple objects) to Clipboard.&lt;BR /&gt;&lt;BR /&gt;So far I have used the Database_Control Example without any success.&lt;/DIV&gt;</description>
      <pubDate>Wed, 05 Oct 2022 11:27:39 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Copy-the-GUID-s-of-the-current-selection-single-or-multiple/m-p/219023#M3685</guid>
      <dc:creator>SajW</dc:creator>
      <dc:date>2022-10-05T11:27:39Z</dc:date>
    </item>
    <item>
      <title>Re: Copy the GUID/s of the current selection(single or multiple objects) to Clipboard</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Copy-the-GUID-s-of-the-current-selection-single-or-multiple/m-p/219024#M3686</link>
      <description>&lt;LI-CODE lang="cpp"&gt;#include "ClipBoard.hpp"


static GS::Array&amp;lt;API_Guid&amp;gt;	GetSelectedElements ()
{
	GSErrCode            err;
	API_SelectionInfo    selectionInfo;
	API_Neig             **selNeigs;

	err = ACAPI_Selection_Get (&amp;amp;selectionInfo, &amp;amp;selNeigs, false);
	BMKillHandle ((GSHandle *)&amp;amp;selectionInfo.marquee.coords);
	if (err != NoError || selectionInfo.typeID == API_SelEmpty) {
		BMKillHandle ((GSHandle *)&amp;amp;selNeigs);
		return GS::Array&amp;lt;API_Guid&amp;gt;();
	}

	const UInt32 nSel = BMGetHandleSize ((GSHandle)selNeigs) / sizeof (API_Neig);

	GS::Array&amp;lt;API_Guid&amp;gt; guidArray;
	for (UInt32 i = 0; i &amp;lt; nSel; ++i) {
		guidArray.Push ((*selNeigs).guid);
	}

	BMKillHandle ((GSHandle *)&amp;amp;selNeigs);

	return guidArray;
}


static void CopyGUIDsOfCurrentSelectionToClipboard ()
{
	GS::UniString string;

	const GS::Array&amp;lt;API_Guid&amp;gt;	guidsOfCurrentSelection = GetSelectedElements ();
	for (UIndex ii = 0; ii &amp;lt; guidsOfCurrentSelection.GetSize (); ++ii) {
		string += APIGuidToString (guidsOfCurrentSelection[ii]) + '\n';
	}

	Clipboard::GetInstance ().SetUniString (Clipboard::uniTextTypeId, string);
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Simply call CopyGUIDsOfCurrentSelectionToClipboard function to use.&lt;BR /&gt;You're welcome &lt;IMG style="display: inline;" src="https://community.graphisoft.com/legacyfs/online/emojis/icon_wink.gif" border="0" /&gt;&lt;BR /&gt;&lt;BR /&gt;UPDATE: I modified the code, now it's platform independent, works both on Windows and macOS platforms.&lt;/P&gt;</description>
      <pubDate>Sun, 19 Sep 2021 13:01:55 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Copy-the-GUID-s-of-the-current-selection-single-or-multiple/m-p/219024#M3686</guid>
      <dc:creator>Tibor Lorantfy</dc:creator>
      <dc:date>2021-09-19T13:01:55Z</dc:date>
    </item>
    <item>
      <title>Re: Copy the GUID/s of the current selection(single or multiple objects) to Clipboard</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Copy-the-GUID-s-of-the-current-selection-single-or-multiple/m-p/219025#M3687</link>
      <description>Severity	Code	Description	Project	File	Line	Suppression State&lt;BR /&gt;
Error (active)	E1696	cannot open source file "ClipBoard.hpp"	&lt;BR /&gt;
&lt;BR /&gt;
Cannot solve the error associated with the #Include. Do you have any suggestion?</description>
      <pubDate>Mon, 29 Apr 2019 04:17:38 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Copy-the-GUID-s-of-the-current-selection-single-or-multiple/m-p/219025#M3687</guid>
      <dc:creator>SajW</dc:creator>
      <dc:date>2019-04-29T04:17:38Z</dc:date>
    </item>
    <item>
      <title>Re: Copy the GUID/s of the current selection(single or multiple objects) to Clipboard</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Copy-the-GUID-s-of-the-current-selection-single-or-multiple/m-p/219026#M3688</link>
      <description>You're right, sorry, ClipBoard.hpp is not part of the public API Development Kit.&lt;BR /&gt;
&lt;BR /&gt;
Which version of ARCHICAD are you using?&lt;BR /&gt;
&lt;BR /&gt;
If you use ARCHICAD 22, then feel free to copy ClipBoard.hpp from this zip file into the Support\Modules\GSUtils folder inside the Development Kit.</description>
      <pubDate>Mon, 29 Apr 2019 06:42:32 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Copy-the-GUID-s-of-the-current-selection-single-or-multiple/m-p/219026#M3688</guid>
      <dc:creator>Tibor Lorantfy</dc:creator>
      <dc:date>2019-04-29T06:42:32Z</dc:date>
    </item>
    <item>
      <title>Re: Copy the GUID/s of the current selection(single or multiple objects) to Clipboard</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Copy-the-GUID-s-of-the-current-selection-single-or-multiple/m-p/219027#M3689</link>
      <description>&lt;LI-CODE lang="cpp"&gt;static void CopyGUIDsOfCurrentSelectionToClipboard()
{
	GS::UniString string;

	const GS::Array&amp;lt;API_Guid&amp;gt;	guidsOfCurrentSelection = GetSelectedElements();
	for (UIndex ii = 0; ii &amp;lt; guidsOfCurrentSelection.GetSize(); ++ii) {
		string += APIGuidToString(guidsOfCurrentSelection[ii]) + '\n';
	}

	Clipboard::GetInstance().Empty();
	Clipboard::GetInstance().SetUniString(Clipboard::uniTextTypeId, string);
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It works.&lt;BR /&gt;I had to call Empty() as well.&lt;/P&gt;</description>
      <pubDate>Sun, 19 Sep 2021 12:59:26 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Copy-the-GUID-s-of-the-current-selection-single-or-multiple/m-p/219027#M3689</guid>
      <dc:creator>SajW</dc:creator>
      <dc:date>2021-09-19T12:59:26Z</dc:date>
    </item>
    <item>
      <title>Re: Copy the GUID/s of the current selection(single or multiple objects) to Clipboard</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Copy-the-GUID-s-of-the-current-selection-single-or-multiple/m-p/306539#M3690</link>
      <description>&lt;P&gt;-&lt;/P&gt;</description>
      <pubDate>Mon, 20 Sep 2021 12:02:37 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Copy-the-GUID-s-of-the-current-selection-single-or-multiple/m-p/306539#M3690</guid>
      <dc:creator>SajW</dc:creator>
      <dc:date>2021-09-20T12:02:37Z</dc:date>
    </item>
    <item>
      <title>Re: Copy the GUID/s of the current selection(single or multiple objects) to Clipboard</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Copy-the-GUID-s-of-the-current-selection-single-or-multiple/m-p/306718#M3691</link>
      <description>&lt;P&gt;Hi Guys,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let me inform you that clipboard handling is supported by C++ API from version 25.&lt;/P&gt;
&lt;P&gt;The DGClipboard.hpp is part of the development kit (Support\Modules\DGLib). Using the DG::Clipboard singleton instance you can get or set the content of the clipboard easily.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please note that the code I previously posted at this topic is outdated (worked for previous versions).&lt;/P&gt;
&lt;P&gt;Here is the updated example code:&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;#include "APIEnvir.h"
#include "ACAPinc.h"
#include "APICommon.h"

#include "DGClipboard.hpp"


static GS::Array&amp;lt;API_Guid&amp;gt;	GetSelectedElements ()
{
	API_SelectionInfo	selectionInfo = {};
	GS::Array&amp;lt;API_Neig&amp;gt;	selNeigs;

	ACAPI_Selection_Get (&amp;amp;selectionInfo, &amp;amp;selNeigs, false);
	BMKillHandle ((GSHandle*)&amp;amp;selectionInfo.marquee.coords);

	return selNeigs.Transform&amp;lt;API_Guid&amp;gt; ([](const API_Neig&amp;amp; neig) { return neig.guid; });
}


static void CopyGUIDsOfSelectedElementsToClipboard ()
{
	GS::UniString string;

	const GS::Array&amp;lt;API_Guid&amp;gt;	guidsOfCurrentSelection = GetSelectedElements ();
	for (const API_Guid&amp;amp; guid : guidsOfCurrentSelection) {
		string += APIGuidToString (guid) + '\n';
	}

	DG::Clipboard::GetInstance ().Clear ();
	DG::Clipboard::GetInstance ().SetUniString (DG::Clipboard::uniTextTypeId, string);
}


static GSErrCode	SelectElementsFromClipboard ()
{
	GS::UniString clipboardString;
	DG::Clipboard::GetInstance ().GetUniString (DG::Clipboard::uniTextTypeId, clipboardString);

	GS::Array&amp;lt;GS::UniString&amp;gt; guidStrings;
	clipboardString.Split ("\n", GS::UniString::SkipEmptyParts, &amp;amp;guidStrings);

	const USize count = guidStrings.GetSize ();
	GS::Array&amp;lt;API_Neig&amp;gt; neigs = guidStrings.Transform&amp;lt;API_Neig&amp;gt; ([] (const GS::UniString &amp;amp; string) {
		return API_Neig (APIGuidFromString (string.ToCStr ().Get ()));
	});

	return ACAPI_Element_Select (neigs, true);
}&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 20 Sep 2021 16:05:59 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Copy-the-GUID-s-of-the-current-selection-single-or-multiple/m-p/306718#M3691</guid>
      <dc:creator>Tibor Lorantfy</dc:creator>
      <dc:date>2021-09-20T16:05:59Z</dc:date>
    </item>
  </channel>
</rss>

