2014-01-15 04:45 PM - last edited on 2023-08-01 04:36 PM by Doreena Deng
2014-01-15 10:12 PM
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) { }
2014-01-16 02:55 PM
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 ()));
2014-01-16 03:35 PM
// 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 } } }
2014-01-16 05:32 PM