Sub main
oInvApp = ThisApplication
Dim outerRad As Double = 10 'Torus outter circle radius(cm)
Dim oThick As Double = 0.2 'Torus thickness(cm) <outerRad
Dim oAngle As Double = 180 'Torus outter circle sweep angle (degree) ≤360
Dim oRevolveAngle As Double = 120 'Torus sweep angle (degree) ≤360
Dim oTorusRad As Double = 10 'Torus radius(cm)
CreateTorus(outerRad, oThick, oAngle, oRevolveAngle, oTorusRad)
End Sub
Function CreateTorus(outerRad As Double, othick As Double, oAngle As Double, oRevolveAngle As Double, oTorusRad As Double)
Dim oDoc As PartDocument = oInvApp.Documents.Add(kPartDocumentObject)
Dim oDef As PartComponentDefinition = oDoc.ComponentDefinition
Dim oWorkplane As WorkPlane = oDef.WorkPlanes.Item(2)
Dim oSketch As PlanarSketch = oDef.Sketches.Add(oWorkplane)
Dim oTG As TransientGeometry = oInvApp.TransientGeometry
Dim oP2d As Point2d = oTG.CreatePoint2d(oTorusRad, 0)
If oAngle = 360 Then
oSketch.SketchCircles.AddByCenterRadius(oP2d, outerRad)
oSketch.SketchCircles.AddByCenterRadius(oP2d, outerRad - othick)
Else
Dim oOutArc As SketchArc = oSketch.SketchArcs.AddByCenterStartSweepAngle(oP2d, outerRad, -oAngle / 180 * PI / 2, oAngle / 180 * PI)
Dim oInArc As SketchArc = oSketch.SketchArcs.AddByCenterStartSweepAngle(oP2d, outerRad - othick, -oAngle / 180 * PI / 2, oAngle / 180 * PI)
oSketch.SketchLines.AddByTwoPoints(oOutArc.StartSketchPoint, oInArc.StartSketchPoint)
oSketch.SketchLines.AddByTwoPoints(oOutArc.EndSketchPoint, oInArc.EndSketchPoint)
End If
Dim oProfile As Profile = oSketch.Profiles.AddForSolid
Dim oAxis As WorkAxis = oDef.WorkAxes.Item(3)
Dim oRevolve As RevolveFeature = oDef.Features.RevolveFeatures.AddByAngle(oProfile, oAxis, oRevolveAngle / 180 * PI, kSymmetricExtentDirection, kNewBodyOperation)
End Function
1.draw a sketch of you want to revolve
2.make a revolvefeature
3.done
maybe like this. is it your wanted?