AnsweredAssumed Answered

Array of reference points using InsertReferencePoint

Question asked by Ash Can on Jul 21, 2015
Latest reply on Jul 21, 2015 by Ash Can

I have a spline and am trying to insert references points along the spline, convert these points to a 3d sketch and then export them.


I have this working fine for equally distributed reference points using


Dim UpperSplinePts As Variant
Dim vFeat as Variant
Dim feat as SldWorks.Feature
UpperSplinePts = Part.FeatureManager.InsertReferencePoint(swRefPointAlongCurve, swRefPointAlongCurveEvenlyDistributed, 0#, NumPoints)
---Other processing code---
For Each vFeat In UpperSplinePts
        Set feat = vFeat
        Set swRefPt = feat.GetSpecificFeature2
        Set swRefPtData = feat.GetDefinition
        Set mtPt = swRefPt.GetRefPoint
        Set swSkPt = Part.SketchManager.CreatePoint(mtPt.ArrayData(0), mtPt.ArrayData(1), mtPt.ArrayData(2))


How ever, I am not pleased with the equal distribution and hence am now trying to insert the ref points using the "Percentage along curve " option.

Dim UpperSplinePts As Variant
Dim UpperSplinePt     As Variant
Dim vFeat                 As Variant
Dim feat As SldWorks.Feature
A = 0
For i = 1 To NumPoints
     boolstatus = Part.Extension.SelectByID2(Spline_IDs(1), "EXTSKETCHSEGMENT", 0, 0, 0, False, 0, Nothing, 0) ' Select the Spline
     percentage = Sin(A / 57.2957795130823) ^ 2 * 100
     If percentage > 100 Then percentage = 100
     UpperSplinePt = Part.FeatureManager.InsertReferencePoint(swRefPointAlongCurve, swRefPointAlongCurvePercentage, percentage, 1)
     Part.ClearSelections2 True ' Clear the selected point
     A = A + 90 / NumPoints
Next i


This seems fine, but I am a bit stuck as to how to build an array from the individually returned 'UpperSpinePt' to insert the 3D sketch points.

I have tried

UpperSplinePt(i) = Part.FeatureManager.InsertReferencePoint(swRefPointAlongCurve, swRefPointAlongCurvePercentage, percentage, 1)

but get a type mismatch error.


What would be the right way to do this? I basically want to build up my array of UpperSplinePts based on the pointer returned by UpperSplinePt inside this loop. Would it be possible?