Archicad C++ API
About Archicad add-on development using the C++ API.
SOLVED!

Pointer Array Length

poco2013
Mentor
This is a novice question so maybe someone can help!!

I am using Goodies(APIAny_ActParametersID, &getParams, Nullptr);

getParams->params (API_AddParType) returns a pointer to a list of the parameters in a Library Part

How do I get the number parameters pointed to in order to iterate through the list and find the parameter I'm interested in?? I tried sizeof and just got garbage , so doing something wrong?

Thanks
Gerry

Windows 11 - Visual Studio 2022; ArchiCAD 27
1 ACCEPTED SOLUTION

Accepted Solutions
Solution
Viktor Kovacs
Graphisoft
Graphisoft
This one is a bit tricky. Here is the relevant code from Element_Test Add-On:

API_GetParamsType getParams;
BNZeroMemory (&getParams, sizeof (API_GetParamsType));
err = ACAPI_Goodies (APIAny_GetActParametersID, &getParams);
if (err == NoError) {
	UInt32 nParams = BMGetHandleSize ((GSHandle) getParams.params) / sizeof (API_AddParType);
	for (UInt32 ii = 0; ii < nParams; ++ii) {
		const API_AddParType& actParam = (*getParams.params)[ii];
		DBPrintf ("%-3u. param: \"%s\" (%s)\n", ii, actParam.name, (actParam.flags & API_ParFlg_Disabled) != 0 ? "disabled" : "");
	}
}
ACAPI_Goodies (APIAny_CloseParametersID);
ACAPI_DisposeAddParHdl (&getParams.params);

View solution in original post

2 REPLIES 2
Solution
Viktor Kovacs
Graphisoft
Graphisoft
This one is a bit tricky. Here is the relevant code from Element_Test Add-On:

API_GetParamsType getParams;
BNZeroMemory (&getParams, sizeof (API_GetParamsType));
err = ACAPI_Goodies (APIAny_GetActParametersID, &getParams);
if (err == NoError) {
	UInt32 nParams = BMGetHandleSize ((GSHandle) getParams.params) / sizeof (API_AddParType);
	for (UInt32 ii = 0; ii < nParams; ++ii) {
		const API_AddParType& actParam = (*getParams.params)[ii];
		DBPrintf ("%-3u. param: \"%s\" (%s)\n", ii, actParam.name, (actParam.flags & API_ParFlg_Disabled) != 0 ? "disabled" : "");
	}
}
ACAPI_Goodies (APIAny_CloseParametersID);
ACAPI_DisposeAddParHdl (&getParams.params);
poco2013
Mentor
Thanks Viklor:
UInt32 nParams = BMGetHandleSize ((GSHandle) getParams.params) / sizeof (API_AddParType);
was exactly what I was looking for. Don't know how I missed it but I did.

Thanks again
Gerry

Windows 11 - Visual Studio 2022; ArchiCAD 27

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!