Hi everyone,
I'm using the code provided in the SolidWorks sample to obtain control and knot points for a spline:
However, while I get correct values for the number of dimensions and the order of the spline, I am not getting correct values for the number of control points and the periodic flag for the spline. Here are the relevant code snippets:
union SplinePackedData
{
double doublevalue[2];
int intvalue[4];
}
VARIANT_BOOL ForceNonPeriodic = FALSE;
HRESULT hres = NOERROR;
long DataSize, NoSplines;
swSketch->GetSplineParamsCount3(ForceNonPeriodic, &DataSize, &NoSplines);
if (NoSplines > 0)
{
int dim, nctrlpts, nknots, order, periodic;
int index = 0;
double *pdata;
SplinePackedData* pPackedData;
pdata = (double *) malloc(sizeof(double)*DataSize);
hres = swSketch->IGetSplineParams3(ForceNonPeriodic, pdata);
while (index < DataSize)
{
pPackedData = (SplinePackedData*)&pdata[index];
dim = pPackedData->intvalue[0];
order = pPackedData->intvalue[1];
nctrlpts = pPackedData->intvalue[2];
periodic = pPackedData->intvalue[3];
.
.
.
}
}
I am get a value of 0 for the number of control points and garbage for the periodic flag, but I'm getting correct values for the number of dimensions and the order of the spline. Interesting enough, if I use the DataSize to infer the number of control points (using DataSize = 2 + numKnots + numControlPoints*Dim + 3), then I get the correct answer for a simple test case that I can confirm within SolidWorks. So the number of control points is clearly correctly being used inside of the code, but I am doing something incorrect in getting the value for the number of contol points from the packed data structure. Any help would be greatly appreciated. Thanks!
SolidworksApi macros