-
Notifications
You must be signed in to change notification settings - Fork 0
Spring Generator
File: Shape_Generation_Scripts/Spring_Generator.py
Version: 1.1
Document Type: Part
Generates a parametric helical compression spring solid directly in CATIA from user-defined parameters. Settings are saved between sessions.
Open ends: A GSD helix is created as the sweep path. A circular wire cross-section sketch is placed on a plane normal to the helix at its start point and swept along the helix using a Part Design Rib to produce the solid.
Closed ends: Three helices are joined (bottom dead coil, active body, top dead coil). The solid is built entirely in GSD: a tubular surface is created with HybridShapeSweepExplicit (profile circle swept along the joined spine), flat end caps are filled with HybridShapeFill, all three surfaces are joined, and the closed surface is converted to a solid with CloseSurface. The Rib is not used for closed ends.
| Requirement | Value |
|---|---|
| Python | >= 3.10 |
| pycatia | >= 0.8.3 |
| wxPython | Required |
| Open document | Part |
| Hybrid Design Mode | Should be off (script handles this automatically) |
- Open a CATPart document
- Run the script
- The parameter dialog appears — enter your spring parameters
- Click OK — a progress bar shows while the geometry is being created
- The spring solid is added as a new body in the part
- The construction geometry (helix spine, profile plane or cap surfaces) is hidden automatically after generation
| 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, including dead end coils if Closed Ends is on |
| Active Coils | Number of load-bearing coils (not including dead end coils) |
| Clockwise | Winding direction — ticked = right-hand (clockwise from above), unticked = left-hand |
| Closed Ends | If ticked, one dead coil (pitch = wire diameter) is added at each end — see below |
When Closed Ends is ticked, the spring is built from three joined helices:
| Segment | Pitch | Height |
|---|---|---|
| Bottom dead coil | Wire diameter (coils touching) | 1 × wire diameter |
| Active body | (Free length − 2 × wire diameter) ÷ active coils | Free length − 2 × wire diameter |
| Top dead coil | Wire diameter (coils touching) | 1 × wire diameter |
The three helices are joined into a single spine curve (Helix_Join). Free length includes both dead coils. The start point of each segment is calculated so that all three helices connect without gaps.
The solid is then built using the GSD surface workflow:
-
HybridShapeSweepExplicitsweeps the bottom end cap circle along the joined spine (smooth option disabled) - Two
HybridShapeFillfeatures cap the open ends — each boundary circle lies in a plane perpendicular to the spine at the respective endpoint - The tube and both caps are joined into a closed surface
-
CloseSurfaceconverts the surface to a solid
The script validates inputs before generating:
- All numeric fields must be greater than zero
- Wire diameter must be less than the coil radius (Mean Coil Diameter ÷ 2)
- Open ends: pitch (free length ÷ active coils) ≤ wire diameter → overlap warning
- Closed ends: free length must be greater than 2 × wire diameter; main coil pitch ≤ wire diameter → overlap warning
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.
- The spring axis is aligned with the Z-axis, with the base at the origin
- The body is named with the key parameters:
Spring | Wd:3.0mm | Cd:25.0mm | L:80.0mm | N:8.0 | CW - The construction geometric set (
Spring_Construction) is created inside the spring body and hidden automatically after generation; it remains in the tree for editing - Hybrid Design Mode is temporarily disabled during generation if it is on, and restored afterwards
Getting Started
Contributing
- Copy Name and Colour
- Export Properties To CSV
- Find And Select By Name
- Hide Planes And Axis Systems
- Rename Hybrid Shapes
- Replace Name Hybrid Shapes
- Reset Visual Properties
- Screenshot White Background
- Swap Names
- Toggle Show Hide Geometric Set
- Add Border And Title Block
- Add Border And Title Block With Values
- Batch CATDrawing To DXF
- Batch CATDrawing To PDF
- Create Drawing Border And Title Block
- Create Drawing Border And Title Block With Values
- Export Drawing Dimensions To CSV
- Update All Drawing Views
- Update Title Block From Properties
- Update Title Block Headings
- Axis To Axis Keep History
- Axis To Axis Keep History And Structure
- Axis To Axis Keep Name
- Axis To Axis Keep Name And Structure
- Batch Isolate Geometric Set
- Check Duplicate Names In Geometric Set
- Check Open Bodies
- Colour Code By Geometric Set
- Copy Geometric Set To New Part
- Copy Parameters Between Parts
- Create Construction Planes
- Create Spline From Coordinates
- Create ISM OSM STEP Files
- Delete Deactivated Features
- Export 3D Annotations To CSV
- Export All Parameters To CSV
- Export Curve Lengths Surface Areas To CSV
- Export Geometric Set Structure To CSV
- Export Holes To CSV
- Export Mass CoG Inertia To CSV
- Export Parameter Dependencies To CSV
- Export Points Axis and Geo Set To CSV
- Export Points Axis and Geo Set To XYZ
- Export Points Geo Set To CSV
- Export Points Geo Set To XYZ
- Export Sketch Constraints To CSV
- Extract Boundary Curves
- IGES Export Curve Axis
- Insert Points Catia
- Insert Points Catia Keep History
- Insert Points Catia With Names
- Insert Points Catia With Names Keep History
- Join Explicit No Connect
- Join Explicit No Connect Curve
- Join Explicit No Connect Surface
- List Properties To CSV
- Match Properties In Geometric Set
- Measure Curve With 3 Points As Circle
- Measure Curve With 3 Points As Circle Keep Con
- Measure Radius Surface
- Measure Radius Surface Keep Con
- Measure Radius Surface Keep Con Auto Edge
- Mirror Keep History
- Mirror Keep History And Structure
- Mirror Keep Name
- Mirror Keep Name And Structure
- Publish Hybrid Shapes In Geometric Set
- Reorder Geometric Set Alphabetically
- Rotate Angle Keep History
- Rotate Angle Keep History And Structure
- Rotate Angle Keep Name
- Rotate Angle Keep Name And Structure
- Rotate Three Points Keep History
- Rotate Three Points Keep History And Structure
- Rotate Three Points Keep Name
- Rotate Three Points Keep Name And Structure
- Scale Keep History
- Scale Keep History And Structure
- Scale Keep Name
- Scale Keep Name And Structure
- Select By Colour
- Spline Through Points In Geometric Set
- Translate Direction Distance Keep History
- Translate Direction Distance Keep History And Structure
- Translate Direction Distance Keep Name
- Translate Direction Distance Keep Name And Structure
- Custom Coordinate Airfoil Generator
- Ellipse Generator
- Hole Size Test Plate Generator
- Involute Gear Generator
- NACA 4 Digit Airfoil Generator
- NACA 5 Digit Airfoil Generator
- Plot 2D Function
- Plot 3D Parametric Curve
- Regular Polygon Generator
- Sine Wave Curve Generator
- Spring Generator
- Check Operation Parameters Against Limits
- Export NC Program Names To CSV
- Export Process Table Parameters
- Export Resource List
- Export Tool List From Process
- Rename Operations From Tool Name
- Batch Instance Name Equal Part Number
- Batch Rename Instances
- BOM Export To CSV
- BOM Export With Materials
- Check Missing Files
- Clash Detection Export
- Export Assembly As STEP
- Export Component Positions To CSV
- Save Child Parts To STEP
- Save Child Parts To STL
- Backup CATIA Settings
- Clear Script Settings
- Clear CATIA Temp Files
- Configure CATIA Version Settings
- Kill CATIA Processes
- Open CATIA Settings Folder
- Reset CATIA Settings
- Restore CATIA Settings
- Set CATIA Environment Variable
- Toggle CATIA No Start Document
Legal