Skip to content

Spring Generator

KaiUR edited this page May 21, 2026 · 6 revisions

Spring Generator

File: Shape_Generation_Scripts/Spring_Generator.py
Version: 1.0
Document Type: Part


Description

Generates a parametric helical compression spring solid directly in CATIA from user-defined parameters. The spring geometry is built using a GSD helix as the sweep path and a Part Design Rib as the solid. A circular wire cross-section is swept along the helix to produce a fully solid spring body. Settings are saved between sessions.


Requirements

Requirement Value
Python >= 3.10
pycatia >= 0.8.3
wxPython Required
Open document Part
Hybrid Design Mode Should be off (script handles this automatically)

Usage

  1. Open a CATPart document
  2. Run the script
  3. The parameter dialog appears — enter your spring parameters
  4. Click OK — a progress bar shows while the geometry is being created
  5. The spring solid is added as a new body in the part

Parameters

Parameter Description
Wire Diameter (mm) Diameter of the wire cross-section
Coil Diameter (mm) Mean coil diameter (centre of wire to centre of wire)
Free Length (mm) Overall uncompressed length of the spring
Number of Coils Total number of active coils
Clockwise Winding direction — ticked = right-hand (clockwise), unticked = left-hand

Validation

The script validates inputs before generating and exits with an error if:

  • Wire diameter is zero or negative
  • Coil diameter is zero or negative
  • Free length is zero or negative
  • Number of coils is zero or negative
  • Pitch (free length ÷ coils) is less than or equal to wire diameter (coils would overlap)
  • Wire diameter is greater than or equal to the coil radius (physically impossible geometry)

Settings Persistence

Parameters are saved automatically to:

%APPDATA%\pycatia_scripts\Spring_Generator\user_presets.json

The next time the script runs, your last-used values are pre-filled in the dialog.


Notes

  • The spring axis is aligned with the Z-axis, with the base at the origin
  • The body is placed in a new body in the part named Spring
  • Hybrid Design Mode is temporarily disabled during generation if it is on, and restored afterwards
  • The helix, axis line, profile plane, and sketch are left as construction geometry in the part tree; only the Rib solid is the final output

Home


Getting Started


Contributing


Any Document Scripts


Drawing Document Scripts


Part Document Scripts


Shape Generation Scripts


Process Document Scripts


Product Document Scripts


Utility Scripts


Legal

Clone this wiki locally