AnsweredAssumed Answered

Arc Length/GetLength2 Differences

Question asked by Mark Fosdike on Oct 26, 2016
Latest reply on Oct 27, 2016 by Mark Fosdike

I'm using the below code to "goal seek" the desired length of a spline. Essentially I have a spline which has been trimmed to an oversized circle, and it runs a loop which adjusts the circle size smaller, measures the difference between the spline length and the desired spline length and feeds that back into the next circle size. This approaches the desired length then exits the loop when it's within 10^-6 m.


To date this method has worked quite well. However, I'm finding that lately the measured spline according to the GetLength2 function gives a different value than the Arc Length when measured in Solidworks. Does anyone know why this varies, and by so much?


Thanks for your help! Code and snapshots below:



CircleDiam = 0.7


    While SplineMeasure > sinDesiredArcRootLower + 0.000001


        Set myDimension = Part.Parameter("D1@" & SketchNo2)

        myDimension.SystemValue = CircleDiam

        Part.ClearSelection2 True


        Part.ClearSelection2 True

        SelectSkSegFs (jj + 4) 'Part.Extension.SelectByID2 "Spline2", "SKETCHSEGMENT", 0, 0, 0, False, 0, Nothing, 0

        Set swSketchSeg = swSelMgr.GetSelectedObject5(1)

        Set swCurve = swSketchSeg.GetCurve


        bRet = swCurve.GetEndParams(nStartParam, nEndParam, bIsClosed, bIsPeriodic)

        Debug.Assert bRet


        vStart = swCurve.Evaluate(nStartParam)

        vEnd = swCurve.Evaluate(nEndParam)


        ExtractFields vStart(6), nStartSuccess, nDummy

        ExtractFields vEnd(6), nEndSuccess, nDummy

        Debug.Assert nStartSuccess

        Debug.Assert nEndSuccess


        SplineMeasure = swCurve.GetLength2(nStartParam, nEndParam)


        Debug.Print "Length = " & swCurve.GetLength2(nStartParam, nEndParam) * 1000# & " mm"


        CircleDiam = CircleDiam * (sinDesiredArcRootLower + SplineMeasure) / (2 * SplineMeasure)