<?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: Using API_RoomRelation structure in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/Using-API-RoomRelation-structure/m-p/194099#M6759</link>
    <description>&lt;BLOCKQUOTE&gt;suresha wrote:&lt;BR /&gt;&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;			element.header.index = (long) relData.objects[ind];
//Here the object index I get seems to be invalid.			
			lastErr = ACAPI_Element_Get ( &amp;amp;element );
&lt;/PRE&gt;

When I pass the object index to ACAPI_Element_Get, I am getting error 13 which is not in the error list.&lt;/BLOCKQUOTE&gt;
The error is actually 1 line above where you discover the problem. &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;relData.objects&lt;E&gt;&lt;/E&gt; is a handle, not a pointer, so you have to dereference it twice. That's why you have had to cast the value as (long) - the compiler was actually giving you a useful warning there.&lt;BR /&gt;
&lt;BR /&gt;
So instead of:&lt;PRE&gt;element.header.index = (long) relData.objects[ind];&lt;/PRE&gt;...you should write:&lt;PRE&gt;element.header.index = (*relData.objects)[ind];&lt;/PRE&gt;</description>
    <pubDate>Thu, 24 Sep 2009 09:09:03 GMT</pubDate>
    <dc:creator>Ralph Wessel</dc:creator>
    <dc:date>2009-09-24T09:09:03Z</dc:date>
    <item>
      <title>Using API_RoomRelation structure</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Using-API-RoomRelation-structure/m-p/194098#M6758</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;I am newbie here. Trying to write a program to Cycle through all the Zones. Find related objects in each Zone and Modify a Parameter.&lt;BR /&gt;&lt;BR /&gt;Following is part of the code.&lt;BR /&gt;&lt;BR /&gt;
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;static GSErrCode CycleZoneObjects ( const long index, const char *floor_param, const char *floor_type )
{
	GSErrCode				lastErr;
	API_RoomRelation        relData;
	API_ElemTypeID			typeID;
	long                    ind;
	char					buffer[256];
	API_Element				element;
	API_ElementMemo			memo;

	typeID = API_ObjectID;

	lastErr = ACAPI_Element_GetRelations (API_ZoneID, index,
		typeID, &amp;amp;relData);
	
	if ( lastErr != NoError )
			return lastErr;
	sprintf ( buffer, "Found %d Related Objects", relData.nObject );
	WriteReport_Alert( buffer, true );
	//continue;
	{

		for ( ind=0; ind &amp;lt; relData.nObject; ind++)
		{
			BNZeroMemory (&amp;amp;element, sizeof (API_Element));
			element.header.typeID = typeID;
			element.header.index = (long) relData.objects[ind];
//Here the object index I get seems to be invalid.			
			lastErr = ACAPI_Element_Get ( &amp;amp;element );
			if (lastErr == NoError )
			{
				lastErr = ACAPI_Element_GetMemo_Masked ( element.header.typeID, element.header.index, APIMemoMask_AddPars, &amp;amp;memo);
				SetFloorParValue ( &amp;amp;memo.params, floor_param, floor_type);
				ACAPI_DisposeElemMemoHdls (&amp;amp;memo);
			}
			if (lastErr != NoError )
				WriteReport_Alert("ACAPI_Element_Get/Memo in ZoneObjects Error", true );
		}
	}

	ACAPI_DisposeRoomRelationHdls (&amp;amp;relData);
	return lastErr;
}


static GSErrCode CycleZones ( void)
{
	GSErrCode       lastErr;
	API_ElemTypeID  typeID;
	API_Element		elem;
	API_ElementMemo elemMemo;
	long            nElem, i;
	char			floor_param[] = "floor_f";
	char			floor_type[50];
	char			buffer[256];

	typeID = API_ZoneID;
	lastErr = ACAPI_Element_GetNum (typeID, &amp;amp;nElem);
	if (lastErr != NoError)
		return lastErr;

	sprintf ( buffer, "Found %ld Zones", nElem );
	WriteReport_Alert( buffer, true );

	for (i = 1; i &amp;lt;= nElem &amp;amp;&amp;amp; !lastErr; i++) 
	{
		if (!ACAPI_Element_Filter (typeID, i, APIFilt_OnVisLayer | APIFilt_OnActFloor))
			continue;
			
		BNZeroMemory (&amp;amp;elem, sizeof (API_Element));

		elem.header.typeID = typeID;
		elem.header.index = i;
		lastErr = ACAPI_Element_Get (&amp;amp;elem);
		if (lastErr == NoError &amp;amp;&amp;amp; elem.header.hasMemo) 
		{
			lastErr = ACAPI_Element_GetMemo_Masked ( typeID, i, APIMemoMask_AddPars, &amp;amp;elemMemo);
			/* Custom element processing */
			GetFloorParValue ( &amp;amp;elemMemo.params, floor_param, floor_type);
			if (CHEqualASCII(floor_type, "Tiles", CS_CaseInsensitive) ||
				CHEqualASCII(floor_type, "Carpet", CS_CaseInsensitive) )
			{
				sprintf(buffer, "The floor type is %s\n", floor_type);
				WriteReport_Alert(buffer, true);
				CycleZoneObjects ( elem.header.index, floor_param, floor_type );
			}
			ACAPI_DisposeElemMemoHdls (&amp;amp;elemMemo);
		}
	}
	return lastErr;
}


static void	DoZoneCycling (void)

{
	CycleZones();
	return;

}
&lt;/PRE&gt;
I am having trouble getting the right object index from API_RoomRelation structure. When I pass the object index to ACAPI_Element_Get, I am getting error 13 which is not in the error list.&lt;BR /&gt;&lt;BR /&gt;Also, I get the number of objects as 4 when there is only one object in the zone (3 more than the actual objects).&lt;BR /&gt;&lt;BR /&gt;This is on ArchiCAD 10 using API 10.22&lt;/DIV&gt;</description>
      <pubDate>Thu, 03 Aug 2023 11:40:03 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Using-API-RoomRelation-structure/m-p/194098#M6758</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-08-03T11:40:03Z</dc:date>
    </item>
    <item>
      <title>Re: Using API_RoomRelation structure</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Using-API-RoomRelation-structure/m-p/194099#M6759</link>
      <description>&lt;BLOCKQUOTE&gt;suresha wrote:&lt;BR /&gt;&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;			element.header.index = (long) relData.objects[ind];
//Here the object index I get seems to be invalid.			
			lastErr = ACAPI_Element_Get ( &amp;amp;element );
&lt;/PRE&gt;

When I pass the object index to ACAPI_Element_Get, I am getting error 13 which is not in the error list.&lt;/BLOCKQUOTE&gt;
The error is actually 1 line above where you discover the problem. &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;relData.objects&lt;E&gt;&lt;/E&gt; is a handle, not a pointer, so you have to dereference it twice. That's why you have had to cast the value as (long) - the compiler was actually giving you a useful warning there.&lt;BR /&gt;
&lt;BR /&gt;
So instead of:&lt;PRE&gt;element.header.index = (long) relData.objects[ind];&lt;/PRE&gt;...you should write:&lt;PRE&gt;element.header.index = (*relData.objects)[ind];&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 Sep 2009 09:09:03 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Using-API-RoomRelation-structure/m-p/194099#M6759</guid>
      <dc:creator>Ralph Wessel</dc:creator>
      <dc:date>2009-09-24T09:09:03Z</dc:date>
    </item>
    <item>
      <title>Re: Using API_RoomRelation structure</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Using-API-RoomRelation-structure/m-p/194100#M6760</link>
      <description>Thank you very much Ralph!! &lt;BR /&gt;
&lt;BR /&gt;
Regards,</description>
      <pubDate>Thu, 24 Sep 2009 11:40:41 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Using-API-RoomRelation-structure/m-p/194100#M6760</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-09-24T11:40:41Z</dc:date>
    </item>
  </channel>
</rss>

