Hello,
i am using solidworks 2010.
i draw a parabola and i need to get points from the parabola, and i want to get avery some delta (like 0.5 mm) xyz point.
for spline and curve i use this macro: ( this don't work on parabola)
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swSelMgr As SldWorks.SelectionMgr
Dim swSketchSeg As SldWorks.SketchSegment
Dim swCurve As SldWorks.Curve
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swSelMgr = swModel.SelectionManager
Set swSketchSeg = swSelMgr.GetSelectedObject6(1, -1)
Set swCurve = swSketchSeg.GetCurve
Dim vPts As Variant
vPts = SplitCurveByChord(swCurve, 0.05)
swModel.ClearSelection2 True
swModel.SketchManager.Insert3DSketch True
Dim i As Integer
For i = 0 To (UBound(vPts) + 1) / 3 - 1
swModel.SketchManager.CreatePoint vPts(i * 3), vPts(i * 3 + 1), vPts(i * 3 + 2)
Next
swModel.SketchManager.Insert3DSketch True
End Sub
Function SplitCurveByChord(swCurve As SldWorks.Curve, chordLength As Double) As Variant
Dim swCurveSpline As SldWorks.Curve
Dim nStartParam As Double
Dim nEndParam As Double
Dim bIsClosed As Boolean
Dim bIsPeriodic As Boolean
Dim incr As Double
Dim i As Integer
Dim vParam As Variant
Dim retVal() As Double
swCurve.GetEndParams nStartParam, nEndParam, bIsClosed, bIsPeriodic
Dim curveLength As Double
curveLength = swCurve.GetLength3(nStartParam, nEndParam)
ReDim retVal(CInt(curveLength / chordLength) * 3 - 1)
incr = (nEndParam - nStartParam) / (curveLength / chordLength)
For i = 0 To (UBound(retVal) + 1) / 3 - 1
vParam = swCurve.Evaluate2(nStartParam + i * incr, 1)
retVal(i * 3) = vParam(0)
retVal(i * 3 + 1) = vParam(1)
retVal(i * 3 + 2) = vParam(2)
Next
SplitCurveByChord = retVal
End Function
thanks for the help.