A shell shape is a solid defined by a 2D surface that lacks volumetric thickness.
In analysis, it is used for structural analysis or in other types of analysis by generating a mesh with very thin thickness.
In the Geometry Editor, it is created by extruding a line to form an extruded surface.
This script creates a straight line and defines an extruded surface to generate a rectangular shell solid.
Preconditions
- The start coordinates, width and height of the shell are set using the equation.
Script Function
- Register variables for the shell's start coordinates, width and height as equation parameters.
- Create a reference plane offset from the ZX plane along the Y-axis and create a sketch on this plane.
Set the variable representing the Y-coordinate of the start to the Y-axis offset distance.
On the sketch plane, the X-direction corresponds to the global Z-direction and the Y-direction corresponds to the global X-direction. - Create a line representing the shell width 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. - Extrude the created straight line in the Y-axis direction to create a rectangular shell shape.
# 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
ShellWidth = 100
ShellHeight = 100
ShellStartX = 0
ShellStartY = 0
ShellStartZ = 0
# Equation names
EqWidth = u"width"
EqHeight = u"height"
EqStartX = u"start_x"
EqStartY = u"start_y"
EqStartZ = u"start_z"
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 createShellEquations():
"""Register the width, height, and start coordinates of the shell as equations."""
designTable = geomDoc.GetDesignTable()
equationDataList = [
(EqWidth, ShellWidth),
(EqHeight, ShellHeight),
(EqStartX, ShellStartX),
(EqStartY, ShellStartY),
(EqStartZ, ShellStartZ),
]
designTable.EditStart()
for equationName, expression in equationDataList:
designTable.AddEquation(equationName)
equation = designTable.GetEquation(equationName)
setupEquation(equation, expression)
designTable.EditEnd()
def createOffsetZXPlane(part):
"""Create a ZX plane offset by start_y."""
refZXPlane = part.GetPlaneZX()
offsetPlane = part.CreateReferencePlane()
offsetPlane.SetTypeByString(u"Distance")
offsetPlane.SetPropertyByReference(u"Plane", refZXPlane)
offsetPlane.SetProperty(u"Distance", EqStartY)
return offsetPlane
def createSketchOnShellPlane(part):
"""Create a sketch on the ZX plane offset by start_y."""
offsetPlane = createOffsetZXPlane(part)
offsetPlaneRef = geomDoc.CreateReferenceFromItem(offsetPlane)
sketch = part.CreateSketch(offsetPlaneRef)
return sketch
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 drawBaseShapeForShell(sketch, width):
"""Create a line used as the basis of the shell and constrain its dimensions and position."""
sketch.OpenSketch()
# In a sketch on the ZX plane, the sketch X direction is treated as the Z direction and the sketch Y direction is treated as the X direction.
sketchStartX = ShellStartZ
sketchStartY = ShellStartX
# Line representing the width of the shell
startVertex = sketch.CreateVertex(sketchStartX, sketchStartY)
endVertex = sketch.CreateVertex(sketchStartX, sketchStartY + width)
startRef = geomDoc.CreateReferenceFromItem(startVertex)
endRef = geomDoc.CreateReferenceFromItem(endVertex)
widthLine = sketch.CreateLine(
sketchStartX,
sketchStartY,
sketchStartX,
sketchStartY + width
)
widthLineRef = geomDoc.CreateReferenceFromItem(widthLine)
sketch.CreateMonoConstraint(u"verticality", widthLineRef)
# Constrain the length of the line using an equation.
widthConstraint = sketch.CreateBiConstraint(u"distance", startRef, endRef)
setConstraintExpression(widthConstraint, u"Distance", EqWidth)
# Constrain the X position of the start point using an equation.
startXConstraint = sketch.CreateMonoConstraint(u"distancefromxaxis", startRef)
startXDistanceExpression = getDistanceExpressionFromSignedValue(EqStartX, ShellStartX)
setConstraintExpression(startXConstraint, u"Distance", startXDistanceExpression)
# Constrain the Z position of the line using an equation.
startZConstraint = sketch.CreateMonoConstraint(u"distancefromyaxis", startRef)
startZDistanceExpression = getDistanceExpressionFromSignedValue(EqStartZ, ShellStartZ)
setConstraintExpression(startZConstraint, u"Distance", startZDistanceExpression)
sketch.CloseSketch()
def createShellByExtrude(part, sketch):
"""Create a rectangular shell by extruding the line in the Y-axis direction."""
extrudeSurface = part.CreateExtrudeSurface(sketch)
extrudeSurface.SetTypeByName(u"OneSide")
extrudeSurface.SetReverse(False)
extrudeSurface.SetProperty(u"Height", EqHeight)
return extrudeSurface
def createShellPart(part):
"""Create a shell with equations in the specified Part."""
sketch = createSketchOnShellPlane(part)
drawBaseShapeForShell(sketch, ShellWidth)
createShellByExtrude(part, sketch)
def main():
"""Create a Part containing a shell with equations."""
createShellEquations()
part = createNewPart()
createShellPart(part)
part.ClosePart()
main()


