<?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: GSModeler element to API_element in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/GSModeler-element-to-API-element/m-p/123953#M5870</link>
    <description>Szia Andor, &lt;BR /&gt;
 &lt;BR /&gt;
here is a short example code to get the volume and surface areas of an element: &lt;BR /&gt;
 
&lt;PRE&gt;GSErrCode PrintElementSurfaceAndVolume (const API_Guid&amp;amp; guid) 
{ 
	API_Quantity      quantity, mask; 
	API_Quantities    quantities; 
	API_QuantityPar   params; 
	char              s[256] = { '\0' }; 
	GSErrCode         err; 
 
	ACAPI_ELEMENT_QUANTITY_MASK_CLEAR (mask); 
	ACAPI_ELEMENT_QUANTITY_MASK_SET (mask, wall, surface1); 
	ACAPI_ELEMENT_QUANTITY_MASK_SET (mask, wall, surface2); 
	ACAPI_ELEMENT_QUANTITY_MASK_SET (mask, wall, volume); 
	// Check API_Quantity and API_WallQuantity in the documentation for other options to set! 
 
	quantities.quantityData = &amp;amp;quantity; 
	params.minOpeningSize = EPS; 
	err = ACAPI_Element_GetQuantities (guid, &amp;amp;params, &amp;amp;quantities, &amp;amp;mask); 
	if (err == NoError) { 
	    sprintf (s, "surface1: %.2lf  surface2: %.2lf  volume: %.2lf", quantity.wall.surface1, quantity.wall.surface2, quantity.wall.volume); 
	    ACAPI_WriteReport (s, true); 
	} 
	return err; 
}

// how to use this function:

ModelerAPI::Element element;
	//...
	//...
PrintElementSurfaceAndVolume (GSGuid2APIGuid (element.GetElemGuid ()));&lt;/PRE&gt;
 &lt;BR /&gt;
Soon I will write an example for getting materials too. &lt;BR /&gt;
 &lt;BR /&gt;
Best Regards, &lt;BR /&gt;
Tibor</description>
    <pubDate>Thu, 16 Jan 2014 13:55:32 GMT</pubDate>
    <dc:creator>Tibor Lorantfy</dc:creator>
    <dc:date>2014-01-16T13:55:32Z</dc:date>
    <item>
      <title>GSModeler element to API_element</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/GSModeler-element-to-API-element/m-p/123951#M5868</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;Hi All,&lt;BR /&gt;&lt;BR /&gt;I have the GSModeler elements of a model, and I would like to get parameters from it. (material, volume, etc..). Could you please share a piece of code how can I get this through the API?&lt;BR /&gt;&lt;BR /&gt;Thanks: Andor&lt;/DIV&gt;</description>
      <pubDate>Tue, 01 Aug 2023 14:36:42 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/GSModeler-element-to-API-element/m-p/123951#M5868</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-08-01T14:36:42Z</dc:date>
    </item>
    <item>
      <title>Re: GSModeler element to API_element</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/GSModeler-element-to-API-element/m-p/123952#M5869</link>
      <description>This is the place I am stuck at. Overall am I heading to the right direction to get the wanted properties of the elements?&lt;BR /&gt;

	&lt;PRE&gt;API_Element      apiElement;
	API_ElementMemo  memo;
	GSErrCode        err;
	//const API_Guid		 APIGuid;
	BNZeroMemory (&amp;amp;element, sizeof (API_Element));
	const GS::Guid GSGuid = element.GetElemGuid();
	//&amp;amp;APIGuid =  GSGuid2APIGuid ( &amp;amp;GSGuid);
	err = ACAPI_Element_GetMemo(const API_Guid&amp;amp;    GSGuid2APIGuid(&amp;amp;GSGuid), &amp;amp;memo);
	if (err == NoError) {
		
	}&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Jan 2014 21:12:58 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/GSModeler-element-to-API-element/m-p/123952#M5869</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-01-15T21:12:58Z</dc:date>
    </item>
    <item>
      <title>Re: GSModeler element to API_element</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/GSModeler-element-to-API-element/m-p/123953#M5870</link>
      <description>Szia Andor, &lt;BR /&gt;
 &lt;BR /&gt;
here is a short example code to get the volume and surface areas of an element: &lt;BR /&gt;
 
&lt;PRE&gt;GSErrCode PrintElementSurfaceAndVolume (const API_Guid&amp;amp; guid) 
{ 
	API_Quantity      quantity, mask; 
	API_Quantities    quantities; 
	API_QuantityPar   params; 
	char              s[256] = { '\0' }; 
	GSErrCode         err; 
 
	ACAPI_ELEMENT_QUANTITY_MASK_CLEAR (mask); 
	ACAPI_ELEMENT_QUANTITY_MASK_SET (mask, wall, surface1); 
	ACAPI_ELEMENT_QUANTITY_MASK_SET (mask, wall, surface2); 
	ACAPI_ELEMENT_QUANTITY_MASK_SET (mask, wall, volume); 
	// Check API_Quantity and API_WallQuantity in the documentation for other options to set! 
 
	quantities.quantityData = &amp;amp;quantity; 
	params.minOpeningSize = EPS; 
	err = ACAPI_Element_GetQuantities (guid, &amp;amp;params, &amp;amp;quantities, &amp;amp;mask); 
	if (err == NoError) { 
	    sprintf (s, "surface1: %.2lf  surface2: %.2lf  volume: %.2lf", quantity.wall.surface1, quantity.wall.surface2, quantity.wall.volume); 
	    ACAPI_WriteReport (s, true); 
	} 
	return err; 
}

// how to use this function:

ModelerAPI::Element element;
	//...
	//...
PrintElementSurfaceAndVolume (GSGuid2APIGuid (element.GetElemGuid ()));&lt;/PRE&gt;
 &lt;BR /&gt;
Soon I will write an example for getting materials too. &lt;BR /&gt;
 &lt;BR /&gt;
Best Regards, &lt;BR /&gt;
Tibor</description>
      <pubDate>Thu, 16 Jan 2014 13:55:32 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/GSModeler-element-to-API-element/m-p/123953#M5870</guid>
      <dc:creator>Tibor Lorantfy</dc:creator>
      <dc:date>2014-01-16T13:55:32Z</dc:date>
    </item>
    <item>
      <title>Re: GSModeler element to API_element</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/GSModeler-element-to-API-element/m-p/123954#M5871</link>
      <description>Szia Andor,  &lt;BR /&gt;
  &lt;BR /&gt;
to get the material informations of a GModeler element you should iterate through the polygons of the element.  &lt;BR /&gt;
  
&lt;PRE&gt;// first you should get the model  
	ModelerAPI::Model model;  
  
// then you can iterate through the elements, bodies and polygons of the model  
	Int32						iElement = 0, iBody = 0, iPgon = 0;  
	Int32						nBody = 0, nPoly = 0;  
	Int32						nElements = model-&amp;gt;GetElementNum ();  
	ModelerAPI::Element			element;  
	ModelerAPI::Body				body;  
	ModelerAPI::Polygon			polygon;
  
	for (iElement = 1; iElement &amp;lt;= nElements; iElement++) {  
		model-&amp;gt;GetElement (iElement, &amp;amp;element);  
		nBody = element.GetBodyNum ();  
  
		for (iBody = 1; iBody &amp;lt;= nBody; iBody++) {  
			element.GetBody (iBody, &amp;amp;body);  
			nPoly = body.GetPolygonCount ();  
  
			for (iPgon = 1; iPgon &amp;lt;= nPoly; iPgon++) {  
				body.GetPolygon (iPgon, &amp;amp;polygon);  
  
				// now you can get the material of this polygon  
				ModelerAPI::Material material;  
				model-&amp;gt;GetMaterial (polygon.GetMaterialIndex (), &amp;amp;material);  
				ModelerAPI::Color color = material.GetSurfaceColor ();  
				double alpha = material.GetTransparency ();  
				// check other available informations about the material in GSModelDevLib/ModelMaterial.hpp  
			}  
		}  
	}&lt;/PRE&gt; &lt;BR /&gt;
  &lt;BR /&gt;
Hope this helps!  &lt;BR /&gt;
  &lt;BR /&gt;
Best Regards,  &lt;BR /&gt;
Tibor</description>
      <pubDate>Thu, 16 Jan 2014 14:35:49 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/GSModeler-element-to-API-element/m-p/123954#M5871</guid>
      <dc:creator>Tibor Lorantfy</dc:creator>
      <dc:date>2014-01-16T14:35:49Z</dc:date>
    </item>
    <item>
      <title>Re: GSModeler element to API_element</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/GSModeler-element-to-API-element/m-p/123955#M5872</link>
      <description>Szia Tibor!&lt;BR /&gt;
&lt;BR /&gt;
Thanks a lot &lt;IMG src="https://community.graphisoft.com/legacyfs/online/emojis/icon_smile.gif" style="display : inline;" /&gt;</description>
      <pubDate>Thu, 16 Jan 2014 16:32:33 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/GSModeler-element-to-API-element/m-p/123955#M5872</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-01-16T16:32:33Z</dc:date>
    </item>
  </channel>
</rss>

