Gears and transmission
Spur Gear (Module 2, 20T)
- Bounding box
- 44.0 × 44.0 × 10.0 mm
- Engine
- Precision B-rep
- Parameters
- 7
- Published
- October 26, 2026
Download
Free to download and use. See the terms.
The prompt
import openpyxl import ezdxf from ezdxf import zoom def generate_cad_from_excel(excel_path, output_dxf_path): # 1. 創建全新的 CAD 圖紙 (支援多層次與中文字體) doc = ezdxf.new('R2010', setup=True) msp = doc.modelspace() # 2. 開啟並讀取 Excel 負載表數據 wb = openpyxl.load_workbook(excel_path, data_only=True) sheet = wb.active # 定義 CAD 繪圖的初始起點與間距 (橫平豎直畫圖) x_start = 0 y_start = 0 y_gap = 50 # 每層樓在圖紙上的垂直間距 print("正在讀取 Excel 數據並自動繪製低壓配電圖...") # 3. 逐行讀取 Excel 內的樓層、保護裝置與電纜數據 (從第3行數據層開始) for row in range(3, sheet.max_row + 1): floor = sheet.cell(row=row, column=1).value # 樓層位址 db_name = sheet.cell(row=row, column=2).value # 配電箱名稱 mccb_spec = sheet.cell(row=row, column=4).value # 總櫃保護裝置 (如 63A MCCB) cable_spec = sheet.cell(row=row, column=5).value # 電纜規格 (如 4C x 16mm²) # 略過空行或電房起點 if not floor or "總低壓電房" in str(db_name): continue # 4. 根據 Excel 數據,在 CAD 空間中自動繪製圖形 current_y = y_start + (row * y_gap) # 繪製主幹水平線 (母線/Busbar 示意線) msp.add_line((x_start, current_y), (x_start + 100, current_y), dxfattribs={'layer': 'POWER_LINE', 'color': 1}) # 繪製一個代表斷路器 (MCCB) 的標準矩形符號 msp.add_lwpolyline([(x_start + 40, current_y - 5), (x_start + 60, current_y - 5), (x_start + 60, current_y + 5), (x_start + 40, current_y + 5)], close=True, dxfattribs={'layer': 'SWITCH_GEAR', 'color': 2}) # 5. 自動將 Excel 內的文字標註到對應的電路旁邊 msp.add_text(f"Location: {floor} ({db_name})", dxfattribs={'height': 3.5, 'color': 7}).set_placement((x_start, current_y + 8)) msp.add_text(f"Protection: {mccb_spec}", dxfattribs={'height': 3.0, 'color': 3}).set_placement((x_start + 110, current_y + 2)) msp.add_text(f"Cable: {cable_spec}", dxfattribs={'height': 3.0, 'color': 4}).set_placement((x_start + 110, current_y - 4)) # 畫一條垂直垂直線代表上升主幹線 (Riser Feeder) msp.add_line((x_start + 50, current_y), (x_start + 50, current_y - y_gap), dxfattribs={'layer': 'RISER', 'color': 5}) # 自動調整 CAD 視口大小,確保圖形完整顯示 zoom.extents(msp) # 6. 儲存為 DXF 格式 (可直接轉存或打印為 DWF) doc.saveas(output_dxf_path) print(f"成功將 Excel 數據轉化為 CAD 向量圖紙!已儲存至: {output_dxf_path}") # 執行腳本 generate_cad_from_excel("Building_Electrical_Load_Distribution_Chart.xlsx", "Auto_Generated_SLD.dxf")
Parameters
| Name | Value | Range |
|---|---|---|
| Module | 2 mm | 0.5 – 6 |
| Number of Teeth | 20 teeth | 8 – 100 |
| Face Width | 10 mm | 3 – 50 |
| Helix Angle | 0 deg | 0 – 30 |
| Bore Diameter | 6 mm | 2 – 30 |
| Keyway Width | 2 mm | 0 – 12 |
| Keyway Depth | 1.4 mm | 0 – 6 |
Every value above is a live dimension. Open a model like this in the editor and each one becomes a slider you can drag before exporting.
More models
Browse the full gallery →Spur Gearbox
design gearbox
Involute Spur Gear with Keyway
Precision Involute Spur Gear with Hub and Keyway: Module (m) of 2.0 mm, 40 teeth (z), Pitch Circle Diameter (d) of 80.00 mm, 20° pressure angle (\alpha), 15.00 mm face width (b), a
Parametric Helical Gear
Create a parametric helical gear with the following specifications: 32 teeth, normal module of 3 mm, right-hand helix, total face width of 80 mm, and a central bore hole with a dia
Rod with Spur Gear
Metal rod diameter is 20 mm and length is 100 mm and right side attach a gear and their OD is 50 mm
Two-Stage Spur Gear Reduction Assembly
Design a 2-stage spur gear reduction set for 3D printing with an overall 10:1 ratio. Stage 1: A 12-tooth pinion driving a 36-tooth gear (3:1). Stage 2: A 12-tooth pinion coupled
Assembled 2WD Sumo Robot
Design a compact, aggressive 2-wheel-drive competition SUMO ROBOT. Main chassis: 260×200×6 mm plywood. 2 STD D-shaft gear motors. 2 wheels: Ø50×20 mm. Controller board: 100×60 mm.
