ACAPI_​LibPart_​GetParams

Returns the default parameters of a registered Library Part.

    GSErrCode  ACAPI_LibPart_GetParams (
        Int32                 libInd,
        double*               a,
        double*               b,
        Int32*                addParNum,
        API_AddParType***     addPars
    );

 

Parameters

libInd
Index of the library part.
a
The A parameter of the the Library Part
b
The B parameter of the the Library Part
addParNum
The number of additive parameters; others than A and B
addPars
The additive parameters

 

Return Values

NoError
The function has completed with success.
APIERR_BADPARS
Invalid libInd, or
any of the parameters are nullptr, or
the addressed Library Part is a macro, picture file etc.
APIERR_MEMFULL
not enough memory to complete the operation

For other common API errors see the API Errors.

 

Remarks

This function is used to get the default parameters of the requested Library Part defined by libInd.

In the a and b parameters, the values of the A and B variables are returned; in the addParNum and addPars parameters the additive parameter list is returned, the number of the parameters and the actual values, respectively.

Refer to the API_AddParType to get more information on a Library Part parameter.

It is absolutely important that the function returns a formalized data handle to describe the parameter list. The content is not equal to the section handle returned by the ACAPI_LibPart_GetSection function called with the API_SectParamDef argument.

The function works only on real Library Parts. In the case the type of the target Library Part is not listed below, the function returns an error code. This is since other type of Library Parts are just simple picture or text files which are enumerated and registered from the active library folders; such a picture or macro.

Applicable type of Library Parts which have parameter list are:

Do not forget to dispose the additive parameter handle if it is not needed any more. Use the ACAPI_DisposeAddParHdl function for this purpose.

 

Example


static void  DumpParameters (Int32 libInd, API_LibTypeID typeID)

{
    API_LibPartDetails   details;
    double               a, b;
    Int32                addParNum, i, ind, i1, i2;
    API_AddParType       **addPars = nullptr;
    double               value;
    char                 *valueStr;
    GSErrCode            err;

    err = ACAPI_LibPart_GetParams (libInd, &a, &b, &addParNum, &addPars);
    if (err) {
        GiveMessage_Err ("ACAPI_LibPart_GetParams", err);
        return;
    }

    GiveMessage_Val ("    a", a, false);
    GiveMessage_Val ("    b", b, false);
    for (i = 0; i < addParNum; i++) {
        if ((*addPars)[i].typeMod == API_ParSimple) {
            DumpOneParam ((*addPars)[i].typeID, (*addPars)[i].name, (*addPars)[i].flags,
                          (*addPars)[i].value.real, (*addPars)[i].value.str,
                          0,0);

        } else {
            ind = 0;
            DumpOneParam ((*addPars)[i].typeID, (*addPars)[i].name, (*addPars)[i].flags,
                          0.0, nullptr,
                          -(*addPars)[i].dim1, -(*addPars)[i].dim2);
            for (i1 = 1; i1 <= (*addPars)[i].dim1; i1++) {
                for (i2 = 1; i2 <= (*addPars)[i].dim2; i2++) {
                    if ((*addPars)[i].typeID != APIParT_CString) {
                        value = (Int32) ((double *) *(*addPars)[i].value.array) [ind];
                        valueStr = nullptr;
                        ind ++;
                    } else {
                        value = 0.0;
                        valueStr = *(*addPars)[i].value.array + ind;
                        ind += strlen (valueStr) + 1;
                    }
                    DumpOneParam ((*addPars)[i].typeID, nullptr, 0,
                                  value, valueStr,
                                  i1, i2);
                }
            }
        }
    }
    ACAPI_DisposeAddParHdl (&addPars);

    if (typeID == APILib_ObjectID ||
        typeID == APILib_LampID ||
        typeID == APILib_LabelID ||
        typeID == APILib_RoomID) {
        err = ACAPI_LibPart_GetDetails (libInd, &details);
        if (!err) {
            GiveMessage_Num ("    fixSize", details.object.fixSize, false);
            GiveMessage_Num ("    autoHsp", details.object.autoHotspot, false);
        }
    }

    if (typeID == APILib_DoorID ||
        typeID == APILib_WindowID) {
        err = ACAPI_LibPart_GetDetails (libInd, &details);
    }

    return;
}

See the implementation of the DumpOneParam function in API_AddParType.

 

Requirements

Version: API 1.3 or later
Header: ACAPinc.h

 

See Also

API_AddParType,
ACAPI_DisposeAddParHdl,
LibPart Manager, API Functions