The revolve function in the Geometry Editor includes a helical option.
By using this, a helical shape can be created following a procedure very similar to that used for a torus.
This script creates a helix by revolving a circular region with helical option around the axis offset from the center of the circle.
Preconditions
- The start coordinates, pitch, turn, helical radius and tube radius of the helix are set using the equation.
Script Function
- Register variables for the helix's start coordinates, pitch, turn, helical radius and tube radius as equation parameters.
- Create a reference plane offset from the YZ plane along the X-axis and create a sketch on this plane.
Set the variable representing the X-coordinate of the start to the X-axis offset distance.
On the sketch plane, the X-direction corresponds to the global Y-direction and the Y-direction corresponds to the global Z-direction. - Create a circular cross-section, a straight line to be the helix axis and a construction line based on the specified start position and apply constraints.
Constrain the start point by distances from the X-axis and Y-axis, assigning the corresponding start coordinate variables to these distances.
Apply a radius constraint to the circular cross-section and apply a distance constraint—corresponding to the helix radius—to the construction line connecting the start point and the center of the circular cross-section. - Create a region defined by the circular cross-section.
- Revolve the circular region with helical option using pitch around the line to create a helix shape.
The rotation angle is calculated by multiplying 360 degrees by the number of turns.
# Copyright (c) 2026 JSOL CORPORATION
#
# This script is released under the MIT License.
# See the full license text at:
# https://www.jmag-international.com/scriptlibrary/jmag_script_library_mit/
app = designer.GetApplication()
geomApp = app.CreateGeometryEditor()
geomDoc = geomApp.GetDocument()
# Dimensional parameters
HelixPitch = 50
HelixStartX = 0
HelixStartY = 0
HelixStartZ = 0
HelixTurn = 5
HelicalRadius = 100
TubeRadius = 20
# Equation names
EqPitch = u"pitch"
EqStartX = u"start_x"
EqStartY = u"start_y"
EqStartZ = u"start_z"
EqTurn = u"turn"
EqHelicalRadius = u"helical_radius"
EqTubeRadius = u"tube_radius"
def createNewPart():
"""Create a new Part and open it in edit mode."""
assm = geomDoc.GetAssembly()
part = assm.CreatePart()
part.OpenPart()
return part
def setupEquation(equation, expression):
"""Configure the basic settings for equations in DesignTable."""
# The argument of SetType
# 0: Value
# 1: Expression
equation.SetType(0)
equation.SetExpression(str(expression))
def createHelixEquations():
"""Register the helix start coordinates, pitch, number of turns, and radii as equations."""
designTable = geomDoc.GetDesignTable()
equationDataList = [
(EqPitch, HelixPitch),
(EqStartX, HelixStartX),
(EqStartY, HelixStartY),
(EqStartZ, HelixStartZ),
(EqTurn, HelixTurn),
(EqHelicalRadius, HelicalRadius),
(EqTubeRadius, TubeRadius),
]
designTable.EditStart()
for equationName, expression in equationDataList:
designTable.AddEquation(equationName)
equation = designTable.GetEquation(equationName)
setupEquation(equation, expression)
designTable.EditEnd()
def createOffsetYZPlane(part):
"""Create a YZ plane offset by start_x."""
refYZPlane = part.GetPlaneYZ()
offsetPlane = part.CreateReferencePlane()
offsetPlane.SetTypeByString(u"Distance")
offsetPlane.SetPropertyByReference(u"Plane", refYZPlane)
offsetPlane.SetProperty(u"Distance", EqStartX)
return offsetPlane
def createSketchOnHelixPlane(part):
"""Create a sketch on the YZ plane offset by start_x."""
offsetPlane = createOffsetYZPlane(part)
offsetPlaneRef = geomDoc.CreateReferenceFromItem(offsetPlane)
sketch = part.CreateSketch(offsetPlaneRef)
return sketch
def createRegionFromItems(sketch, itemList):
"""Create a region on the sketch from all items in the argument's itemList."""
selection = geomDoc.GetSelection()
selection.Clear()
for item in itemList:
selection.Add(item)
sketch.CreateRegions()
selection.Clear()
def setConstraintExpression(constraint, propertyName, equationName):
"""Set an equation name to the specified constraint property."""
constraint.SetProperty(propertyName, equationName)
def getDistanceExpressionFromSignedValue(equationName, value):
"""Return a distance expression for a signed coordinate value."""
if value < 0:
return u"-" + equationName
return equationName
def drawBaseShapeForHelix(sketch, helicalRadius, tubeRadius):
"""Create the circle that forms the helix cross-section and the helix axis, and generate the region."""
sketch.OpenSketch()
# In a sketch on the YZ plane, the sketch X-direction corresponds to the Y-direction, and the sketch Y-direction corresponds to the Z-direction.
sketchStartX = HelixStartY
sketchStartY = HelixStartZ
# Reference point on the helix axis
axisPointVertex = sketch.CreateVertex(sketchStartX, sketchStartY)
axisPointRef = geomDoc.CreateReferenceFromItem(axisPointVertex)
# Helix axis in the Y-direction
axisLine = sketch.CreateLine(
sketchStartX - helicalRadius,
sketchStartY,
sketchStartX + helicalRadius,
sketchStartY
)
axisRef = geomDoc.CreateReferenceFromItem(axisLine)
sketch.CreateMonoConstraint(u"horizontality", axisRef)
sketch.CreateBiConstraint(u"coincident", axisRef, axisPointRef)
# Constrain the Y-position of the reference point on the helix axis using an equation.
startYConstraint = sketch.CreateMonoConstraint(
u"distancefromyaxis",
axisPointRef
)
startYDistanceExpression = getDistanceExpressionFromSignedValue(
EqStartY,
HelixStartY
)
setConstraintExpression(
startYConstraint,
u"Distance",
startYDistanceExpression
)
# Constrain the Z-position of the helix axis using an equation.
startZConstraint = sketch.CreateMonoConstraint(
u"distancefromxaxis",
axisPointRef
)
startZDistanceExpression = getDistanceExpressionFromSignedValue(
EqStartZ,
HelixStartZ
)
setConstraintExpression(
startZConstraint,
u"Distance",
startZDistanceExpression
)
# Center of the tube cross-section
tubeCenterVertex = sketch.CreateVertex(
sketchStartX,
sketchStartY + helicalRadius
)
tubeCenterRef = geomDoc.CreateReferenceFromItem(tubeCenterVertex)
# Construction line representing the helix radius
radiusLine = sketch.CreateLine(
sketchStartX,
sketchStartY,
sketchStartX,
sketchStartY + helicalRadius
)
radiusLineRef = geomDoc.CreateReferenceFromItem(radiusLine)
# Constrain the construction line to be perpendicular to the helix axis, and set the distance to the tube cross-section center using an equation.
sketch.CreateBiConstraint(u"perpendicularity", axisRef, radiusLineRef)
sketch.CreateBiConstraint(u"coincident", radiusLineRef, axisPointRef)
sketch.CreateBiConstraint(u"coincident", radiusLineRef, tubeCenterRef)
helicalRadiusConstraint = sketch.CreateBiConstraint(
u"distance",
axisPointRef,
tubeCenterRef
)
setConstraintExpression(helicalRadiusConstraint, u"Distance", EqHelicalRadius)
# Circle that forms the tube cross-section
tubeCircle = sketch.CreateCircle(
sketchStartX,
sketchStartY + helicalRadius,
tubeRadius
)
tubeCircleRef = geomDoc.CreateReferenceFromItem(tubeCircle)
# Constrain the radius of the tube cross-section using an equation.
tubeRadiusConstraint = sketch.CreateMonoConstraint(
u"radius",
tubeCircleRef
)
setConstraintExpression(tubeRadiusConstraint, u"Radius", EqTubeRadius)
# Create a closed region from the tube cross-section circle.
createRegionFromItems(sketch, [tubeCircle])
sketch.CloseSketch()
return axisLine
def createHelixByRevolve(part, sketch, axisLine):
"""Rotate the circular region around the helix axis to create the helical shape."""
revolve = part.CreateRevolveSolid(sketch)
revolve.SetTypeByName(u"OneSide")
revolve.SetProperty(u"AxisType", u"SelectEntity")
axisRef = geomDoc.CreateReferenceFromItem(axisLine)
revolve.SetAxis(axisRef)
revolve.SetProperty(u"UseHelical", True)
revolve.SetProperty(u"HelicalPitch", EqPitch)
revolve.SetProperty(u"Reverse", True)
revolve.SetProperty(u"Angle", u"360.0*" + EqTurn)
return revolve
def createHelixPart(part):
"""Create a helical shape with equations in the specified Part."""
sketch = createSketchOnHelixPlane(part)
axisLine = drawBaseShapeForHelix(sketch, HelicalRadius, TubeRadius)
createHelixByRevolve(part, sketch, axisLine)
def main():
"""Create a Part containing a helical shape with equations."""
createHelixEquations()
part = createNewPart()
createHelixPart(part)
part.ClosePart()
main()


