<?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: Creating a selection box using the API. in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/Creating-a-selection-box-using-the-API/m-p/187600#M5653</link>
    <description>Once again, I'd like to thank you for your dedication in trying to help me; I really appreciate it.&lt;BR /&gt;
&lt;BR /&gt;
Right now I've put my project in pause and may continue it in the future. Anyway, I'll keep the thread up to date as soon as I lay my hands again on the code (if that ever happens).&lt;BR /&gt;
&lt;BR /&gt;
Thank you again,&lt;BR /&gt;
&lt;BR /&gt;
Siwar</description>
    <pubDate>Sun, 16 Sep 2012 19:43:12 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2012-09-16T19:43:12Z</dc:date>
    <item>
      <title>Creating a selection box using the API.</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Creating-a-selection-box-using-the-API/m-p/187594#M5647</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;Hi everyone ! &lt;IMG style="display: inline;" src="https://community.graphisoft.com/legacyfs/online/emojis/icon_biggrin.gif" border="0" /&gt; &lt;BR /&gt;&lt;BR /&gt;Here I come again, hoping I could get some help on something I've put a lot of time in without much success.&lt;BR /&gt;&lt;BR /&gt;My question is the following : Is there any way to create a selection box using the API and then be able to collect elements within or intersecting with the selection ?&lt;BR /&gt;&lt;BR /&gt;To be more precise, I'd like to create an "invisible" selection box that would not be displayed but would still select the elements within.&lt;BR /&gt;&lt;BR /&gt;I've searched thoroughly in the documentation as well as in this forum's topics...in vain, at least for now.&lt;BR /&gt;&lt;BR /&gt;Any help would be greatly appreciated. Feel free to ask for more precision concerning my question. I thank you all in advance.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Kindly,&lt;BR /&gt;&lt;BR /&gt;Siwar&lt;/DIV&gt;</description>
      <pubDate>Wed, 02 Aug 2023 14:19:18 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Creating-a-selection-box-using-the-API/m-p/187594#M5647</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-08-02T14:19:18Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a selection box using the API.</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Creating-a-selection-box-using-the-API/m-p/187595#M5648</link>
      <description>Hi Siwar! &lt;BR /&gt;
 &lt;BR /&gt;
You can create a marquee using the API and select the elements within. After the operation you can remove that. I know it's not exactly what you want but it works almost the same. &lt;BR /&gt;
 &lt;BR /&gt;
Here is a short example code for you: &lt;BR /&gt;
 
&lt;PRE&gt; 
	GSErrCode            err; 
	API_SelectionInfo    selectionInfo; 
	API_Element          tElem; 
	API_Neig             **selNeigs; 
 
	// set the corners of the selection box 
	selectionInfo.marquee.box.xMin = 0.0; 
	selectionInfo.marquee.box.xMax = 10.0; 
	selectionInfo.marquee.box.yMin = 0.0; 
	selectionInfo.marquee.box.yMax = 10.0; 
	selectionInfo.typeID = API_MarqueeHorBox; 
 
	ACAPI_Selection_SetMarquee (&amp;amp;selectionInfo); 
 
	// collect elements 
	err = ACAPI_Selection_Get (&amp;amp;selectionInfo, &amp;amp;selNeigs, false); 
	BMKillHandle ((GSHandle *) &amp;amp;selectionInfo.marquee.coords); 
	if (err == APIERR_NOSEL) 
		err = NoError; 
 
	if (err != NoError) { 
		BMKillHandle ((GSHandle *) &amp;amp;selNeigs); 
		return; 
	} 
 
	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++) { 
			tElem.header.typeID = Neig_To_ElemID ((*selNeigs)[ii].neigID); 
			// filter elements 
			if (tElem.header.typeID == API_DimensionID) 
				continue; 
 
			tElem.header.guid = (*selNeigs)[ii].guid; 
			tElem.header.index = 0; 
			if (ACAPI_Element_Get (&amp;amp;tElem) != NoError) 
				continue; 
 
			// now tElem is one of the elements in the created marquee box 
		} 
	} 
	BMKillHandle ((GSHandle *) &amp;amp;selNeigs); 
 
	// remove selection box 
	selectionInfo.typeID = API_SelEmpty; 
	ACAPI_Selection_SetMarquee (&amp;amp;selectionInfo); 
&lt;/PRE&gt;

Regards,&lt;BR /&gt;
Tibi</description>
      <pubDate>Tue, 28 Aug 2012 13:52:43 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Creating-a-selection-box-using-the-API/m-p/187595#M5648</guid>
      <dc:creator>Tibor Lorantfy</dc:creator>
      <dc:date>2012-08-28T13:52:43Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a selection box using the API.</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Creating-a-selection-box-using-the-API/m-p/187596#M5649</link>
      <description>Tibi, thank you for your help, though I can't say that it turned out to be successful.&lt;BR /&gt;
&lt;BR /&gt;
The selection marquee did show up on the screen with proprer dimensions, but it didn't select anything.&lt;BR /&gt;
I thought the nSel variable would count all the elements inside the marquee, but all it did was counting the elements that I was selecting by myself.&lt;BR /&gt;
&lt;BR /&gt;
Do you have any examples of this code in action ? &lt;BR /&gt;
&lt;BR /&gt;
Thank you again for your response.&lt;BR /&gt;
&lt;BR /&gt;
Siwar</description>
      <pubDate>Thu, 30 Aug 2012 09:08:09 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Creating-a-selection-box-using-the-API/m-p/187596#M5649</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-08-30T09:08:09Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a selection box using the API.</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Creating-a-selection-box-using-the-API/m-p/187597#M5650</link>
      <description>Oh, finally I understood what you need. &lt;BR /&gt;
Only few more lines needed to attach to my previous example code to success &lt;IMG src="https://community.graphisoft.com/legacyfs/online/emojis/icon_smile.gif" style="display : inline;" /&gt; &lt;BR /&gt;
 &lt;BR /&gt;
So I hope it's just what you want, I highlighted the important new lines: &lt;BR /&gt;
 
&lt;PRE&gt; 
	GSErrCode            err; 
	API_SelectionInfo    selectionInfo; 
	API_Neig             **selNeigs; 
 
	// set the corners of the selection box 
	selectionInfo.marquee.box.xMin = 0.0; 
	selectionInfo.marquee.box.xMax = 10.0; 
	selectionInfo.marquee.box.yMin = 0.0; 
	selectionInfo.marquee.box.yMax = 10.0; 
	selectionInfo.typeID = API_MarqueeHorBox; 
 
	ACAPI_Selection_SetMarquee (&amp;amp;selectionInfo); 
 
	// collect elements 
	err = ACAPI_Selection_Get (&amp;amp;selectionInfo, &amp;amp;selNeigs, false); 
	BMKillHandle ((GSHandle *) &amp;amp;selectionInfo.marquee.coords); 
	if (err == APIERR_NOSEL) 
		err = NoError; 
 
	if (err != NoError) { 
		BMKillHandle ((GSHandle *) &amp;amp;selNeigs); 
		return; 
	} 
 
	if (selectionInfo.typeID != API_SelEmpty) { 
		// you can deselect all before the operation like this  
		err = ACAPI_Element_Select (NULL, 0, false); 
		if (err != NoError) 
			ACAPI_WriteReport ("ACAPI_Element_Select deselect all error", true); 
		
// ------------------------------------------------------------------------------------------ 
		UInt32   nSel = BMGetHandleSize ((GSHandle) selNeigs) / sizeof (API_Neig); 
 
		// select the elements within the marquee 
		ACAPI_Element_Select (selNeigs, nSel, true); 
		if (err != NoError) 
			ACAPI_WriteReport ("ACAPI_Element_Select select all error", true);
// ------------------------------------------------------------------------------------------ 
	} 
	BMKillHandle ((GSHandle *) &amp;amp;selNeigs); 
 
	// remove selection box 
	selectionInfo.typeID = API_SelEmpty; 
	ACAPI_Selection_SetMarquee (&amp;amp;selectionInfo); 
&lt;/PRE&gt;</description>
      <pubDate>Fri, 31 Aug 2012 07:55:37 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Creating-a-selection-box-using-the-API/m-p/187597#M5650</guid>
      <dc:creator>Tibor Lorantfy</dc:creator>
      <dc:date>2012-08-31T07:55:37Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a selection box using the API.</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Creating-a-selection-box-using-the-API/m-p/187598#M5651</link>
      <description>Hi !&lt;BR /&gt;
&lt;BR /&gt;
This time, it worked ! Thank you for your help. &lt;IMG src="https://community.graphisoft.com/legacyfs/online/emojis/icon_smile.gif" style="display : inline;" /&gt;&lt;BR /&gt;
&lt;BR /&gt;
As an auxiliary question, is there any way to be able to modify the selection marquee to have something more complex, not just limited by 2 coordinates (like a polyline or so) ? Indeed, that would make the selection process much more precise and reliable, allowing to get the selection within 4 coordinates instead of 2.&lt;BR /&gt;
I've seen in the documentation that the SetMarquee fonction can be based on a polyline rather than a fixed box, but I was not able to make it work.&lt;BR /&gt;
Do you have any clue about such method ? &lt;IMG src="https://community.graphisoft.com/legacyfs/online/emojis/icon_biggrin.gif" style="display : inline;" /&gt;&lt;BR /&gt;
&lt;BR /&gt;
Kindly,&lt;BR /&gt;
&lt;BR /&gt;
Siwar</description>
      <pubDate>Mon, 03 Sep 2012 08:20:57 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Creating-a-selection-box-using-the-API/m-p/187598#M5651</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-09-03T08:20:57Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a selection box using the API.</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Creating-a-selection-box-using-the-API/m-p/187599#M5652</link>
      <description>Hi Siwar! &lt;BR /&gt;
 &lt;BR /&gt;
Here's a short example code for that method: &lt;BR /&gt;
 
&lt;PRE&gt;	GSErrCode           err; 
	API_Neig            **selNeigs; 
	API_SelectionInfo   selectionInfo; 
	Int32				nCoords = 6; // first and last coordinates are the same, so this will be only a pentagon 
 
	selectionInfo.typeID		    = API_MarqueePoly; 
	selectionInfo.marquee.nCoords = nCoords; 
 
	// Allocate memory and set the coordinates 
	API_Coord* coords = reinterpret_cast&amp;lt;API_Coord*&amp;gt; (BMAllocatePtr (nCoords * sizeof (API_Coord), ALLOCATE_CLEAR, 0));; 
	if (coords != NULL) { 
		coords[0].x =  2.0; coords[0].y = 0.0; 
		coords[1].x =  5.0; coords[1].y = 3.0; 
		coords[2].x =  0.0; coords[2].y = 5.0; 
		coords[3].x = -5.0; coords[3].y = 3.0; 
		coords[4].x = -2.0; coords[4].y = 0.0; 
		coords[5].x =  2.0; coords[5].y = 0.0; 
		selectionInfo.marquee.coords = &amp;amp;coords; 
 
		ACAPI_Selection_SetMarquee (&amp;amp;selectionInfo); 
		// Releasing allocated memory 
		BMKillPtr ((GSPtr *) &amp;amp;coords); 
 
		// collect elements within the pentagon 
		err = ACAPI_Selection_Get (&amp;amp;selectionInfo, &amp;amp;selNeigs, false); 
		BMKillHandle ((GSHandle *) &amp;amp;selectionInfo.marquee.coords); 
		if (err == APIERR_NOSEL) 
			err = NoError; 
 
		if (err != NoError) { 
			BMKillHandle ((GSHandle *) &amp;amp;selNeigs); 
			return; 
		} 
 
		// ... 
		// ... 
	} 
&lt;/PRE&gt; &lt;BR /&gt;
 &lt;BR /&gt;
I hope this helps again  &lt;IMG src="https://community.graphisoft.com/legacyfs/online/emojis/icon_wink.gif" style="display : inline;" /&gt;  &lt;BR /&gt;
 &lt;BR /&gt;
Best, &lt;BR /&gt;
Tibi</description>
      <pubDate>Mon, 10 Sep 2012 08:37:47 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Creating-a-selection-box-using-the-API/m-p/187599#M5652</guid>
      <dc:creator>Tibor Lorantfy</dc:creator>
      <dc:date>2012-09-10T08:37:47Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a selection box using the API.</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Creating-a-selection-box-using-the-API/m-p/187600#M5653</link>
      <description>Once again, I'd like to thank you for your dedication in trying to help me; I really appreciate it.&lt;BR /&gt;
&lt;BR /&gt;
Right now I've put my project in pause and may continue it in the future. Anyway, I'll keep the thread up to date as soon as I lay my hands again on the code (if that ever happens).&lt;BR /&gt;
&lt;BR /&gt;
Thank you again,&lt;BR /&gt;
&lt;BR /&gt;
Siwar</description>
      <pubDate>Sun, 16 Sep 2012 19:43:12 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Creating-a-selection-box-using-the-API/m-p/187600#M5653</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-09-16T19:43:12Z</dc:date>
    </item>
  </channel>
</rss>

