A step-by-step tutorial for creating and running Solid Edge macros using Python and COM automation. This guide covers environment setup, script execution, and integration with Solid Edge's COM API.
Using Conda:
conda create -n solidEdgeEnv python=3.11
conda activate solidEdgeEnv
Using venv:
python -m venv solidEdgeEnv
solidEdgeEnv\Scripts\activate.bat # Windows
pip install -r requirements.txt
git clone https://github.com/RylanBosquez/solidEdgeMacroTutorial.git
cd solidEdgeMacroTutorial
solidEdgeMacroTutorial/
├── assets/ # Exported files (PDF, DXF, DWG, JT)
├── scripts/ # Python automation scripts
│ ├── AssemblyDocumentAutomation/ # Scripts for assemblies (insert, traverse, constrain)
│ ├── BOMAndMetadata/ # Scripts for BOM export and metadata extraction
│ ├── DraftDocumentAutomation/ # Scripts for drawing views, dimensions, title block
│ ├── PartDocumentAutomation/ # Scripts for part creation and feature access
│ ├── PrintingAndExport/ # Scripts for printing and sheet/image export
│ ├── Utilities/ # Scripts for general automation tasks
├── requirements.txt # Python dependencies
└── README.md # This file
- Open Solid Edge and load a document.
- Run any script from the
scripts/
folder to automate tasks like:- Exporting to PDF, DXF, DWG, JT
- Reading document properties
- Creating parts or drawings programmatically
Example:
cd scripts/Utilities
python solidEdgeVersion.py
- Launch and connect to Solid Edge
- Open existing documents
- Create new part documents
- Export drawings to PDF, DXF, DWG, JT
- Read standard and custom document properties
- Extract parts list (BOM) from Draft documents
- Create drawing views (e.g., front, side, isometric)
- Extract dimensions from Draft documents
- Read and modify title block text
- Export sheet thumbnails as images
- Solid Edge installed
- Windows OS (COM automation is Windows-only)
- Python 3.11
comtypes
package
- Most scripts assume Solid Edge is already running.
- Only Draft documents support DXF/DWG/JT export.
- All exports are saved to the
assets/
folder.