2018-12-11 09:51 AM - last edited on 2022-10-04 04:52 PM by Daniel Kassai
Solved! Go to Solution.
2018-12-13 04:50 PM
GS::Array<API_CWPanelType> GetCurtainWallPanelsInOrder (const API_Guid& cwGuid) { GS::Array<API_CWPanelType> result; API_Element cwElement; BNZeroMemory (&cwElement, sizeof (API_Element)); cwElement.header.guid = cwGuid; GSErrCode err = ACAPI_Element_Get (&cwElement); if (err == NoError) { API_ElementMemo cwMemo; BNZeroMemory (&cwMemo, sizeof (API_ElementMemo)); err = ACAPI_Element_GetMemo (cwElement.header.guid, &cwMemo, APIMemoMask_CWallSegments | APIMemoMask_CWallPanels); if (err == NoError && cwMemo.cWallSegments != nullptr && cwMemo.cWallPanelGridIDTable != nullptr) { GS::HashTable<API_Guid, API_CWPanelType> cwPanelTable; for (UIndex ii = 0; ii < cwElement.curtainWall.nPanels; ++ii) { const API_CWPanelType& cwPanel = cwMemo.cWallPanels[ii]; cwPanelTable.Add (cwPanel.head.guid, cwPanel); } using CWPanelSegmentGridID = GS::Pair<UInt32, API_GridElemID>; GS::Array<CWPanelSegmentGridID> segmentGridIDs; GS::HashTable<CWPanelSegmentGridID, GS::Array<API_CWPanelType>> reversedCWPanelGridIDTable; for (auto it = cwMemo.cWallPanelGridIDTable->EnumeratePairs (); it != nullptr; ++it) { const API_CWPanelType& cwPanel = cwPanelTable[*it->key]; const GS::Array<API_GridElemID>& cwPanelGridIDs = *it->value; for (auto it = cwPanelGridIDs.Enumerate (); it != nullptr; ++it) { const API_GridElemID& gridID = *it; CWPanelSegmentGridID segmentGridID (cwPanel.filler_1[0]/*cwPanel.segmentID*/, gridID); if (reversedCWPanelGridIDTable.ContainsKey (segmentGridID)) reversedCWPanelGridIDTable[segmentGridID].Push (cwPanel); else reversedCWPanelGridIDTable.Add (segmentGridID, { cwPanel }); segmentGridIDs.Push (segmentGridID); } } GS::Sort (segmentGridIDs.Begin (), segmentGridIDs.End (), [](const auto& lhs, const auto& rhs) { if (lhs.first == rhs.first) return lhs.second < rhs.second; return lhs.first < rhs.first; }); for (auto it = segmentGridIDs.Enumerate (); it != nullptr; ++it) { const CWPanelSegmentGridID& segmentGridID = *it; result.Append (reversedCWPanelGridIDTable[segmentGridID]); } } ACAPI_DisposeElemMemoHdls (&cwMemo); } return result; }
2018-12-13 12:10 PM
2018-12-13 04:50 PM
GS::Array<API_CWPanelType> GetCurtainWallPanelsInOrder (const API_Guid& cwGuid) { GS::Array<API_CWPanelType> result; API_Element cwElement; BNZeroMemory (&cwElement, sizeof (API_Element)); cwElement.header.guid = cwGuid; GSErrCode err = ACAPI_Element_Get (&cwElement); if (err == NoError) { API_ElementMemo cwMemo; BNZeroMemory (&cwMemo, sizeof (API_ElementMemo)); err = ACAPI_Element_GetMemo (cwElement.header.guid, &cwMemo, APIMemoMask_CWallSegments | APIMemoMask_CWallPanels); if (err == NoError && cwMemo.cWallSegments != nullptr && cwMemo.cWallPanelGridIDTable != nullptr) { GS::HashTable<API_Guid, API_CWPanelType> cwPanelTable; for (UIndex ii = 0; ii < cwElement.curtainWall.nPanels; ++ii) { const API_CWPanelType& cwPanel = cwMemo.cWallPanels[ii]; cwPanelTable.Add (cwPanel.head.guid, cwPanel); } using CWPanelSegmentGridID = GS::Pair<UInt32, API_GridElemID>; GS::Array<CWPanelSegmentGridID> segmentGridIDs; GS::HashTable<CWPanelSegmentGridID, GS::Array<API_CWPanelType>> reversedCWPanelGridIDTable; for (auto it = cwMemo.cWallPanelGridIDTable->EnumeratePairs (); it != nullptr; ++it) { const API_CWPanelType& cwPanel = cwPanelTable[*it->key]; const GS::Array<API_GridElemID>& cwPanelGridIDs = *it->value; for (auto it = cwPanelGridIDs.Enumerate (); it != nullptr; ++it) { const API_GridElemID& gridID = *it; CWPanelSegmentGridID segmentGridID (cwPanel.filler_1[0]/*cwPanel.segmentID*/, gridID); if (reversedCWPanelGridIDTable.ContainsKey (segmentGridID)) reversedCWPanelGridIDTable[segmentGridID].Push (cwPanel); else reversedCWPanelGridIDTable.Add (segmentGridID, { cwPanel }); segmentGridIDs.Push (segmentGridID); } } GS::Sort (segmentGridIDs.Begin (), segmentGridIDs.End (), [](const auto& lhs, const auto& rhs) { if (lhs.first == rhs.first) return lhs.second < rhs.second; return lhs.first < rhs.first; }); for (auto it = segmentGridIDs.Enumerate (); it != nullptr; ++it) { const CWPanelSegmentGridID& segmentGridID = *it; result.Append (reversedCWPanelGridIDTable[segmentGridID]); } } ACAPI_DisposeElemMemoHdls (&cwMemo); } return result; }
2018-12-13 05:12 PM