We value your input! Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey
2016-02-22 08:29 PM - last edited on 2023-07-12 09:11 PM by Doreena Deng
//... (*addPars).typeMod = 2; (*addPars).typeID = APIParT_Integer; (*addPars).dim1 = 5; (*addPars).dim2 = 1; (*addPars).value.array = BMAllocateHandle(sizeof(GSHandle), ALLOCATE_CLEAR, 0); *(*addPars).value.array = BMAllocatePtr(5 * sizeof(int), ALLOCATE_CLEAR, 0); if ((*addPars).value.array == NULL || *(*addPars).value.array == NULL){ ACAPI_WriteReport("NOPE!", true); return; } for (int j = 0; j < 5; j++){ (int)((int *)*(*addPars).value.array) = msg.intarrays(intArrayCounter).lst(j); } //...My question is how to correctly work with the array of the parameters.
2016-02-23 06:09 PM
pAddPar = &(*addPars)[3]; pAddPar->typeID = APIParT_RealNum; pAddPar->typeMod = API_ParArray; pAddPar->dim1 = 3; pAddPar->dim2 = 4; CHTruncate ("matrix", pAddPar->name, sizeof (pAddPar->name)); GS::ucscpy (pAddPar->uDescname, L("Array parameter with real numbers")); pAddPar->value.array = BMAllocateHandle (pAddPar->dim1 * pAddPar->dim2 * sizeof (double), ALLOCATE_CLEAR, 0); double** arrHdl = reinterpret_cast<double**>(pAddPar->value.array); for (Int32 k = 0; k < pAddPar->dim1; k++) for (Int32 j = 0; j < pAddPar->dim2; j++) (*arrHdl)[k * pAddPar->dim2 + j] = (k == j ? 1.1 : 0.0);
2016-02-23 06:26 PM
2016-02-24 03:44 PM
(*addPars).value.array = BMAllocateHandle(4 * sizeof(char), ALLOCATE_CLEAR, 0); char** arrHdl = reinterpret_cast<char**>((*addPars).value.array); //(*addPars).value.array = BMAllocateHandle(4 * sizeof(double), ALLOCATE_CLEAR, 0); //double** arrHdl = reinterpret_cast<double**>((*addPars).value.array); (*arrHdl)[0] = 'a'; (*arrHdl)[1] = '\0'; (*arrHdl)[2] = 'b'; (*arrHdl)[3] = '\0';
//actualSize is the number of characters of every strings you want added plus the number of said strings //ex: you want two strings "abc" and "st", the value of actualSize will be 3 + 2 + 2 = 7 //to note that the dim1 will still be the number of strings you want, in this example, 2. But you will allocate space for every character plus every separator '\0'. //the final value of the array will be "abc\0st\0" int numberOfStrings = 2; (*addPars).dim1 = numberOfStrings; (*addPars).dim2 = 1 (*addPars).value.array = BMAllocateHandle(actualSize * (*addPars).dim2 * sizeof(GS::uchar_t), ALLOCATE_CLEAR, 0); GS::uchar_t** arrHdl = reinterpret_cast<GS::uchar_t**>((*addPars).value.array);Hope that this can help anyone with the same problem.