3D preview of Spur Gear (Module 2, 20T)
Loading the interactive model…
Interactive 3D model of Spur Gear (Module 2, 20T)

Gears and transmission

Spur Gear (Module 2, 20T)

1 views
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

NameValueRange
Module2 mm0.5 – 6
Number of Teeth20 teeth8 – 100
Face Width10 mm3 – 50
Helix Angle0 deg0 – 30
Bore Diameter6 mm2 – 30
Keyway Width2 mm0 – 12
Keyway Depth1.4 mm0 – 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.

Spur Gear (Module 2, 20T) - Free CAD Model (STEP, STL) | TextoCAD