https://github.com/ogunerkutay/solidworks-3d-curve-generator
Generate, analyze, and visualize 3D clothoid curves seamlessly across SolidWorks, Python, and Excel. VBA macros for SolidWorks CAD modeling with Python scripts for curve analysis and visualization.
https://github.com/ogunerkutay/solidworks-3d-curve-generator
clothoid curve solidworks-macro
Last synced: 7 months ago
JSON representation
Generate, analyze, and visualize 3D clothoid curves seamlessly across SolidWorks, Python, and Excel. VBA macros for SolidWorks CAD modeling with Python scripts for curve analysis and visualization.
- Host: GitHub
- URL: https://github.com/ogunerkutay/solidworks-3d-curve-generator
- Owner: ogunerkutay
- Created: 2024-12-31T08:19:28.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-12-31T08:24:22.000Z (9 months ago)
- Last Synced: 2024-12-31T09:24:43.750Z (9 months ago)
- Topics: clothoid, curve, solidworks-macro
- Language: Python
- Homepage:
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SolidWorks 3D Curve Generator VBA Macros and Python Integration
This repository includes multiple solutions for generating and analyzing 3D clothoid curves (spirals) using both SolidWorks VBA macros and Python scripts. The primary focus is on integrating SolidWorks for CAD modeling, Excel for data analysis, and Python for curve visualization and curvature computation.
## Features
### 1. SolidWorks VBA Macros
#### First Macro (Basic Clothoid Curve)
- Generates a 3D clothoid curve using parametric equations x(t)=cos(t²) and y(t)=sin(t²)
- The z-coordinate is fixed at 0, but can be adjusted if needed
- Automatically creates a 3D sketch in SolidWorks with points calculated at discrete intervals#### Second Macro (Flexible Clothoid Curve)
- Allows for custom start and end points in 3D space (startX, startY, startZ, endX, endY, endZ)
- Linear interpolation between points combined with sine wave functions
- Dynamic curve shape modification in 3D space**Parameters:**
- `numPoints`: Number of points for the curve (default: 100)
- `deltaT`: Step size for the parametric values
- `startX, startY, startZ`: Starting point coordinates
- `endX, endY, endZ`: Ending point coordinates*Note: Results are automatically converted to SolidWorks' default unit system (meters)*
### 2. Python Curve and Curvature Visualization
#### First Python Script
- Generates 2D plot of the clothoid curve in the XY-plane
- Integrates parametric equations numerically using `numpy.cumsum()`
- Plots curvature κ(t) as 2t
- Displays curve and curvature function in separate subplots#### Second Python Script
- Includes all functionality of the first script
- Saves generated data (t, x, y, and curvature values) to Excel
- Uses pandas DataFrame for data management
- Creates `curve_and_curvature.xlsx` for analysis**Parameters:**
- `t`: Parameter range (0 to 2 or 1)
- `x(t)`: cos(t²) for x-coordinate
- `y(t)`: sin(t²) for y-coordinate
- `kappa(t)`: Curvature function (2t)### 3. Excel Integration
- Data export to Excel file with columns for t, x, y, and kappa
- Facilitates curve analysis using spreadsheet tools
- Compatible with both SolidWorks and Python workflows## Installation
### Prerequisites
- SolidWorks (any recent version)
- Python 3.x
- Required Python packages:
```bash
pip install numpy matplotlib pandas
```## Usage
### SolidWorks VBA Macros
1. Open a part document in SolidWorks
2. Access the VBA editor (Tools > Macro > New)
3. Copy and paste the macro code
4. Run the macro to generate the 3D clothoid curve### Python Scripts
1. First Script (Visualization):
```bash
python clothoid.py
```2. Second Script (Excel Export):
```bash
python excelclothoid.py
```## Notes
- SolidWorks macros require an active part document
- Python scripts provide independent visualization and analysis
- Excel integration enables data portability between tools## Contributing
Feel free to submit issues and enhancement requests!