Here's an update...
Try changing "(Cos(n), Sin(n), n)" to "(Cos(n), Sin(n) / 2, n)" or "2 *
(Cos(n), Sin(n), n)" and see the results (wicked!!!)
Formulas are fun :-)
Cheers,
Teun
Public Sub Create3DSplineUsingFormulas()
Const NumberOfPoints = 31
Dim oPartDoc As PartDocument
Dim oCompDef As PartComponentDefinition
Dim oTransGeom As TransientGeometry
Dim oWPs(0 To NumberOfPoints) As WorkPoint
Dim oFitPoints As ObjectCollection
Dim o3DSketch1 As Sketch3D
Dim o3DSpline As SketchSpline3D
Dim oCamera As Camera
Dim n As Double
Set oPartDoc = ThisApplication.Documents.Add(kPartDocumentObject)
Set oCompDef = oPartDoc.ComponentDefinition
Set oTransGeom = ThisApplication.TransientGeometry
For n = 0 To NumberOfPoints
Set oWPs(n) =
oCompDef.WorkPoints.AddFixed(oTransGeom.CreatePoint(Cos(n), Sin(n), n))
Next n
Set oFitPoints = ThisApplication.TransientObjects.CreateObjectCollection
For n = 0 To NumberOfPoints
Call oFitPoints.Add(oWPs(n))
Next n
Set o3DSketch1 = oCompDef.Sketches3D.Add
Set o3DSpline = o3DSketch1.SketchSplines3D.Add(oFitPoints)
Dim oWorkPlane As WorkPlane
Set oWorkPlane = oCompDef.WorkPlanes.AddByNormalToCurve(o3DSpline, oWPs(0))
Dim oSketch2D As PlanarSketch
Set oSketch2D = oCompDef.Sketches.Add(oWorkPlane)
Dim oSketchPoint As SketchPoint
Set oSketchPoint = oSketch2D.AddByProjectingEntity(oWPs(0))
Dim oSketchCircle As SketchCircle
Set oSketchCircle = oSketch2D.SketchCircles.AddByCenterRadius(oSketchPoint,
0.1)
Dim oPath As Path
Set oPath = oCompDef.Features.SweepFeatures.CreatePath(o3DSpline)
Dim oProfile As Profile
Set oProfile = oSketch2D.Profiles.AddForSolid
Dim oSweep As SweepFeature
Set oSweep = oCompDef.Features.SweepFeatures.Add(oProfile, oPath,
kJoinOperation)
Set oCamera = ThisApplication.ActiveView.Camera
oCamera.ViewOrientationType = kIsoTopRightViewOrientation
oCamera.Fit
oCamera.Apply
MsgBox "Done"
End Sub