Skip to content

aust21/spring-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

3D Spring Generator for AutoCAD

This project generates a 3D compression spring geometry as a DXF file and creates an AutoCAD script to sweep the spring wire along the helix. It automates most of the 3D spring creation process in AutoCAD.

Features

  • Generates a helical spring path (3D polyline)
  • Creates a circle profile representing the wire thickness
  • Generates an AutoCAD script (.scr) to perform a sweep, creating a solid spring

Parameters are fully customizable:

Parameter Description
wire_diameter Diameter of the spring wire
nominal_diameter Mean diameter of the spring coil
turns Number of spring turns
pitch Distance between coils
points_per_turn Resolution of the helix (more points → smoother spring)

Installation

Install Autodesk Autocad ≥2025 and sign in before continuing

  1. Install Python (≥3.7 recommended)
  2. Create a virtual environment
python -m venv venv
  1. Activate the virtual environment
venv\Scripts\activate
  1. Install the requirements:
pip install -r requirements.txt

Usage

Open the Python script and adjust spring parameters if needed:

  • wire_diameter = 10
  • nominal_diameter = 60
  • turns = 8
  • pitch = 20
  • points_per_turn = 80

Run the script:

python main.py

This will create two files in the same folder:

  1. spring.dxf -> Contains the helix path and circle profile
  2. spring.scr -> AutoCAD script to sweep the circle along the helix

AutoCAD Instructions

  1. Open spring.dxf in AutoCAD
  2. Type SCRIPT in the command line
  3. Select spring.scr
  4. The script will automatically:
  • Select the circle as the profile
  • Select the helix as the path
  • Perform a sweep, creating a 3D solid spring

If the automatic generation fails, read the command prompt for instructions

  1. Use 3DORBIT and REALISTIC visual style to inspect the spring

Notes / Tips

  1. The profile circle must be created last in the DXF so AutoCAD selects it first in the sweep
  2. The small Z offset avoids AutoCAD errors selecting the profile as the path
  3. For smoother springs, increase points_per_turn (e.g., 120–200)
  4. You can tweak radius and pitch to create compression, extension, or torsion springs

About

3D Spring Generator for AutoCAD

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages