Skip to content

Plot 3D Parametric Curve

KaiUR edited this page May 31, 2026 · 1 revision

Plot 3D Parametric Curve

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


Description

Evaluates three user-entered mathematical expressions x(t), y(t), z(t) over a parameter range and creates the resulting 3D curve in the active CATPart as a GSD point set and spline. All functions from Python's math module are available. If the first and last points coincide (within 0.001 mm) the spline is automatically closed.

Settings are saved between sessions.


Requirements

Requirement Value
Python >= 3.10
pycatia >= 0.8.3
wxPython Required
Open document Part

Usage

  1. Open a CATPart document
  2. Run the script
  3. Enter the three component expressions, parameter range, and number of points in the dialog
  4. Click OK — all expressions are validated then a progress bar shows while geometry is created
  5. A new geometric set is added to the part containing the point set and spline

Parameters

Parameter Description Default
x(t) = X coordinate as a function of t (mm) cos(t) * 50
y(t) = Y coordinate as a function of t (mm) sin(t) * 50
z(t) = Z coordinate as a function of t (mm) t * 5
t start Start value of the parameter range. May use pi and e. 0.0
t end End value of the parameter range. Must be greater than t start. 2 * pi
Points Number of sample points. Minimum 2. 100

Expression Syntax

Each expression is a Python math expression using t as the parameter. Available functions:

Category Functions
Trigonometric sin, cos, tan, asin, acos, atan, atan2
Hyperbolic sinh, cosh, tanh
Power / log sqrt, exp, log, log2, log10
Rounding floor, ceil, fabs
Constants pi, e
Other abs, round

You can also use pi and e directly in the t start and t end fields (e.g. 2*pi, -pi).

Example Curves

Curve x(t) y(t) z(t) t range
Circle (XY, r=50) cos(t)*50 sin(t)*50 0 0 to 2*pi
Helix cos(t)*50 sin(t)*50 t*10 0 to 2*pi
Lissajous sin(3*t)*50 sin(2*t)*50 0 0 to 2*pi

Dialog Buttons

Button Action
OK Validates all expressions and inputs, then generates the curve
Cancel Exits without generating
Reset Defaults Restores factory default values
Clear Saved Deletes the saved user presets file
Help Opens the full in-script user manual

Output

A geometric set named Parametric_x(t)_<expr> is created at the top level of the part tree containing:

Parametric_x(t)_cos(t)x50
├── Points
│   ├── Pt_0001
│   ├── Pt_0002
│   │   ...
│   └── Pt_0100
└── Parametric_Spline  (open or closed)

The spline is automatically closed if the distance between the first and last points is less than 0.001 mm. For a closed curve, the last point is dropped from the point set before building the spline so the geometry is not duplicated.


Settings Persistence

Settings are saved automatically to:

%APPDATA%\pycatia_scripts\Plot_3D_Parametric_Curve\user_presets.json

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


Notes

  • All coordinates produced by the expressions are treated as mm
  • Each expression is validated at t = 1 during dialog validation to catch syntax errors before touching CATIA
  • The geo set name is a sanitised, truncated version of the x(t) expression
  • t start and t end support Python math expressions using pi and e only; full math module not available in those fields

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