GSModeler element to API_element
Anonymous
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2014-01-15
04:45 PM
- last edited on
‎2023-08-01
04:36 PM
by
Doreena Deng
‎2014-01-15
04:45 PM
Hi All,
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?
Thanks: Andor
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?
Thanks: Andor
Labels:
- Labels:
-
Add-On (C++)
4 REPLIES 4
Anonymous
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2014-01-15 10:12 PM
‎2014-01-15
10:12 PM
This is the place I am stuck at. Overall am I heading to the right direction to get the wanted properties of the elements?
API_Element apiElement; API_ElementMemo memo; GSErrCode err; //const API_Guid APIGuid; BNZeroMemory (&element, sizeof (API_Element)); const GS::Guid GSGuid = element.GetElemGuid(); //&APIGuid = GSGuid2APIGuid ( &GSGuid); err = ACAPI_Element_GetMemo(const API_Guid& GSGuid2APIGuid(&GSGuid), &memo); if (err == NoError) { }

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2014-01-16 02:55 PM
‎2014-01-16
02:55 PM
Szia Andor,
here is a short example code to get the volume and surface areas of an element:
Soon I will write an example for getting materials too.
Best Regards,
Tibor
here is a short example code to get the volume and surface areas of an element:
GSErrCode PrintElementSurfaceAndVolume (const API_Guid& 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 = &quantity; params.minOpeningSize = EPS; err = ACAPI_Element_GetQuantities (guid, ¶ms, &quantities, &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 ()));
Soon I will write an example for getting materials too.
Best Regards,
Tibor

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2014-01-16 03:35 PM
‎2014-01-16
03:35 PM
Szia Andor,
to get the material informations of a GModeler element you should iterate through the polygons of the element.
Hope this helps!
Best Regards,
Tibor
to get the material informations of a GModeler element you should iterate through the polygons of the element.
// 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->GetElementNum (); ModelerAPI::Element element; ModelerAPI::Body body; ModelerAPI::Polygon polygon; for (iElement = 1; iElement <= nElements; iElement++) { model->GetElement (iElement, &element); nBody = element.GetBodyNum (); for (iBody = 1; iBody <= nBody; iBody++) { element.GetBody (iBody, &body); nPoly = body.GetPolygonCount (); for (iPgon = 1; iPgon <= nPoly; iPgon++) { body.GetPolygon (iPgon, &polygon); // now you can get the material of this polygon ModelerAPI::Material material; model->GetMaterial (polygon.GetMaterialIndex (), &material); ModelerAPI::Color color = material.GetSurfaceColor (); double alpha = material.GetTransparency (); // check other available informations about the material in GSModelDevLib/ModelMaterial.hpp } } }
Hope this helps!
Best Regards,
Tibor
Anonymous
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2014-01-16 05:32 PM
‎2014-01-16
05:32 PM
Szia Tibor!
Thanks a lot
Thanks a lot
