cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 
Developer forum

Append items to a Library (GDL) array parameter from a C++ addon

BenjiDev
Booster

Hello, 

I can successfully modify items in an array parameter of a Library (GDL) object using the approach described here APIAny_​OpenParametersID.

Since API_​ChangeParamType takes an "ind1" and "ind2" its quite straightforward to do so.

Now how do i go about appending items to the array, or maybe completely replace the array with new values? If ind1 or ind2 is out of bounds i will get an error.

 

According to  API_​AddParType:

For parameters with array modifier, you can change the dimensions of the array on the fly when you create or modify an element. This enables you to put just a placeholder for an array into the library part parameter, and adjust that when you actually place the library part.

 

Does this mean you can change dim1 and dim2 in the  API_​AddParType struct directly?

 

But at the same time it is discouraged to modify API_​AddParType (taken from APIAny_​OpenParametersID):

 

The only way to ensure full parameter consistency while changing a value of a Library Part parameter is to use the functions provided for this operation. If you manipulate the API_AddParType handle directly, the parameter list may become invalid.

 

and from API_​AddParType:

 

It is strongly advised to use the APIAny_OpenParametersIDAPIAny_ChangeAParameterIDAPIAny_GetActParametersIDAPIAny_CloseParametersID functions to modify a parameter in the parameter list.

 

What is the recommended/safe/standard way to append items / resize a GDL array parameter from the C++ side then?

Thanks

1 ACCEPTED SOLUTION

Solution
BenjiDev
Booster

Alright, in the section about API_​AddParType  under remarks, it says:

For parameters with array modifier, you can change the dimensions of the array on the fly when you create or modify an element. 

Do they mean that i can change dim1 and dim2 in API_​AddParType  to the desired size and then set the item? But I interpret the docs as modyfing API_​AddParType directly is an incorrect approach:

 

If you manipulate the API_AddParType handle directly, the parameter list may become invalid.

 

AND

 

It is strongly advised to use the APIAny_OpenParametersIDAPIAny_ChangeAParameterIDAPIAny_GetActParametersIDAPIAny_CloseParametersID functions to modify a parameter in the parameter list.

 

So what is the recommended approach to appending items / resizing a GDL array from C++ then? I am getting a feeling from the docs that API_​AddParType should not be modified directly.

View solution in original post

1 REPLY 1

Solution
BenjiDev
Booster

Alright, in the section about API_​AddParType  under remarks, it says:

For parameters with array modifier, you can change the dimensions of the array on the fly when you create or modify an element. 

Do they mean that i can change dim1 and dim2 in API_​AddParType  to the desired size and then set the item? But I interpret the docs as modyfing API_​AddParType directly is an incorrect approach:

 

If you manipulate the API_AddParType handle directly, the parameter list may become invalid.

 

AND

 

It is strongly advised to use the APIAny_OpenParametersIDAPIAny_ChangeAParameterIDAPIAny_GetActParametersIDAPIAny_CloseParametersID functions to modify a parameter in the parameter list.

 

So what is the recommended approach to appending items / resizing a GDL array from C++ then? I am getting a feeling from the docs that API_​AddParType should not be modified directly.

Still looking?

Browse more topics

Back to forum

See latest solutions

Accepted solutions

Start a new discussion!