We value your input! Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey
2018-09-10 04:31 PM - last edited on 2023-07-04 02:08 PM by Doreena Deng
//Quick list GS::Array<API_Coord> myLis; API_Coord myPt; myPt.x = 0.0; myPt.y = 0.0; myLis.Push(myPt); myPt; myPt.x = 0.0; myPt.y = 1.0; myLis.Push(myPt); myPt; myPt.x = 1.0; myPt.y = 1.0; myLis.Push(myPt); myPt; myPt.x = 0.0; myPt.y = 1.0; myLis.Push(myPt); SlabDo(myLis); static void SlabDo(GS::Array<API_Coord>& ptList) { API_Element elem; API_ElementMemo mem; BNZeroMemory(&elem, sizeof(API_Element)); BNZeroMemory(&mem, sizeof(API_ElementMemo)); elem.header.typeID = API_SlabID; ACAPI_Element_GetDefaults(&elem, nullptr); // &mem? int ptListSize = ptList.GetSize(); elem.slab.poly.nCoords = ptListSize + 1; elem.slab.poly.nSubPolys = 1; elem.slab.poly.nArcs = 0; mem.coords = (API_Coord**)BMAllocateHandle((elem.detail.poly.nCoords + 1) * sizeof(API_Coord), ALLOCATE_CLEAR, 0); //Works but gives Wrong Poligon Error when doing Slab mem.pends = (Int32**)BMAllocateHandle((elem.detail.poly.nSubPolys + 1) * sizeof(Int32), ALLOCATE_CLEAR, 0); mem.parcs = reinterpret_cast<API_PolyArc**> (BMAllocateHandle(elem.slab.poly.nArcs * sizeof(API_PolyArc), ALLOCATE_CLEAR, 0)); // Gives eerro - not enougth memory if (mem.coords == nullptr || mem.pends == nullptr || mem.parcs == nullptr) { ACAPI_WriteReport("Not enough memory to create slab polygon data", true); ACAPI_DisposeElemMemoHdls(&mem); return; } Int32 iCoord = 1; for (int ii=0; ii < ptListSize; ii++) { ACAPI_WriteReport(GS::ValueToString(ii), true); (*mem.coords)[iCoord].x = ptList[ii].x; ACAPI_WriteReport(GS::ValueToString(ptList[ii].x), true); (*mem.coords)[iCoord].y = ptList[ii].y; ACAPI_WriteReport(GS::ValueToString(ptList[ii].y), true); ++iCoord; } (*mem.coords)[iCoord] = (*mem.coords)[1]; (*mem.pends)[0] = 0; (*mem.pends)[1] = iCoord; const GSErrCode err = ACAPI_Element_Create(&elem, &mem); if (err != NoError) { ACAPI_WriteReport(GS::ValueToString(err), true); } ACAPI_DisposeElemMemoHdls(&mem); }
2018-09-11 10:59 PM
2018-09-12 12:23 PM