relevante Datei für 2D Library Erzeugung
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
"Schaltungstyp": "M",
|
||||
"OFWeiche_center_line_width_mm": 350.129,
|
||||
"OFWeiche_center_line_height_mm": 700.123,
|
||||
"Objekte_width_mm": 386.007,
|
||||
"Objekte_width_mm": 418.55,
|
||||
"Objekte_height_mm": 715.001,
|
||||
"OFWeiche_CP1_x_mm": 365.007,
|
||||
"OFWeiche_CP1_y_mm": 355.001,
|
||||
@@ -26,7 +26,7 @@
|
||||
"Schaltungstyp": "P",
|
||||
"OFWeiche_center_line_width_mm": 350.129,
|
||||
"OFWeiche_center_line_height_mm": 700.123,
|
||||
"Objekte_width_mm": 386.007,
|
||||
"Objekte_width_mm": 418.55,
|
||||
"Objekte_height_mm": 715.001,
|
||||
"OFWeiche_CP1_x_mm": 365.007,
|
||||
"OFWeiche_CP1_y_mm": 355.001,
|
||||
@@ -64,15 +64,15 @@
|
||||
"Schaltungstyp": "M",
|
||||
"OFWeiche_center_line_width_mm": 350.129,
|
||||
"OFWeiche_center_line_height_mm": 700.123,
|
||||
"Objekte_width_mm": 386.007,
|
||||
"Objekte_width_mm": 418.55,
|
||||
"Objekte_height_mm": 715.001,
|
||||
"OFWeiche_CP1_x_mm": 21.0,
|
||||
"OFWeiche_CP1_x_mm": 53.544,
|
||||
"OFWeiche_CP1_y_mm": 355.001,
|
||||
"KurvenRichtung": 2,
|
||||
"SivasnrTEF": null,
|
||||
"OFWeiche_CP2_x_mm": 21.0,
|
||||
"OFWeiche_CP2_x_mm": 53.544,
|
||||
"OFWeiche_CP2_y_mm": 715.001,
|
||||
"OFWeiche_CP3_x_mm": 371.129,
|
||||
"OFWeiche_CP3_x_mm": 403.673,
|
||||
"OFWeiche_CP3_y_mm": 14.878
|
||||
},
|
||||
{
|
||||
@@ -83,15 +83,15 @@
|
||||
"Schaltungstyp": "P",
|
||||
"OFWeiche_center_line_width_mm": 350.129,
|
||||
"OFWeiche_center_line_height_mm": 700.123,
|
||||
"Objekte_width_mm": 386.007,
|
||||
"Objekte_width_mm": 418.55,
|
||||
"Objekte_height_mm": 715.001,
|
||||
"OFWeiche_CP1_x_mm": 21.0,
|
||||
"OFWeiche_CP1_x_mm": 53.544,
|
||||
"OFWeiche_CP1_y_mm": 355.001,
|
||||
"KurvenRichtung": 2,
|
||||
"SivasnrTEF": null,
|
||||
"OFWeiche_CP2_x_mm": 21.0,
|
||||
"OFWeiche_CP2_x_mm": 53.544,
|
||||
"OFWeiche_CP2_y_mm": 715.001,
|
||||
"OFWeiche_CP3_x_mm": 371.129,
|
||||
"OFWeiche_CP3_x_mm": 403.673,
|
||||
"OFWeiche_CP3_y_mm": 14.878
|
||||
},
|
||||
{
|
||||
@@ -121,7 +121,7 @@
|
||||
"Schaltungstyp": "M",
|
||||
"OFWeiche_center_line_width_mm": 400,
|
||||
"OFWeiche_center_line_height_mm": 750,
|
||||
"Objekte_width_mm": 435.878,
|
||||
"Objekte_width_mm": 468.421,
|
||||
"Objekte_height_mm": 764.878,
|
||||
"OFWeiche_CP1_x_mm": 414.878,
|
||||
"OFWeiche_CP1_y_mm": 404.878,
|
||||
@@ -140,7 +140,7 @@
|
||||
"Schaltungstyp": "P",
|
||||
"OFWeiche_center_line_width_mm": 400,
|
||||
"OFWeiche_center_line_height_mm": 750,
|
||||
"Objekte_width_mm": 435.878,
|
||||
"Objekte_width_mm": 468.421,
|
||||
"Objekte_height_mm": 764.878,
|
||||
"OFWeiche_CP1_x_mm": 414.878,
|
||||
"OFWeiche_CP1_y_mm": 404.878,
|
||||
@@ -178,15 +178,15 @@
|
||||
"Schaltungstyp": "M",
|
||||
"OFWeiche_center_line_width_mm": 400,
|
||||
"OFWeiche_center_line_height_mm": 750,
|
||||
"Objekte_width_mm": 435.878,
|
||||
"Objekte_width_mm": 468.421,
|
||||
"Objekte_height_mm": 764.878,
|
||||
"OFWeiche_CP1_x_mm": 21.0,
|
||||
"OFWeiche_CP1_x_mm": 53.544,
|
||||
"OFWeiche_CP1_y_mm": 404.878,
|
||||
"KurvenRichtung": 2,
|
||||
"SivasnrTEF": null,
|
||||
"OFWeiche_CP2_x_mm": 21.0,
|
||||
"OFWeiche_CP2_x_mm": 53.544,
|
||||
"OFWeiche_CP2_y_mm": 764.878,
|
||||
"OFWeiche_CP3_x_mm": 421.0,
|
||||
"OFWeiche_CP3_x_mm": 453.544,
|
||||
"OFWeiche_CP3_y_mm": 14.878
|
||||
},
|
||||
{
|
||||
@@ -197,15 +197,15 @@
|
||||
"Schaltungstyp": "P",
|
||||
"OFWeiche_center_line_width_mm": 400,
|
||||
"OFWeiche_center_line_height_mm": 750,
|
||||
"Objekte_width_mm": 435.878,
|
||||
"Objekte_width_mm": 468.421,
|
||||
"Objekte_height_mm": 764.878,
|
||||
"OFWeiche_CP1_x_mm": 21.0,
|
||||
"OFWeiche_CP1_x_mm": 53.544,
|
||||
"OFWeiche_CP1_y_mm": 404.878,
|
||||
"KurvenRichtung": 2,
|
||||
"SivasnrTEF": null,
|
||||
"OFWeiche_CP2_x_mm": 21.0,
|
||||
"OFWeiche_CP2_x_mm": 53.544,
|
||||
"OFWeiche_CP2_y_mm": 764.878,
|
||||
"OFWeiche_CP3_x_mm": 421.0,
|
||||
"OFWeiche_CP3_x_mm": 453.544,
|
||||
"OFWeiche_CP3_y_mm": 14.878
|
||||
},
|
||||
{
|
||||
@@ -235,7 +235,7 @@
|
||||
"Schaltungstyp": "M",
|
||||
"OFWeiche_center_line_width_mm": 500.23,
|
||||
"OFWeiche_center_line_height_mm": 600.197,
|
||||
"Objekte_width_mm": 521.23,
|
||||
"Objekte_width_mm": 553.774,
|
||||
"Objekte_height_mm": 621.237,
|
||||
"OFWeiche_CP1_x_mm": 521.27,
|
||||
"OFWeiche_CP1_y_mm": 261.237,
|
||||
@@ -254,7 +254,7 @@
|
||||
"Schaltungstyp": "P",
|
||||
"OFWeiche_center_line_width_mm": 500.23,
|
||||
"OFWeiche_center_line_height_mm": 600.197,
|
||||
"Objekte_width_mm": 521.23,
|
||||
"Objekte_width_mm": 553.774,
|
||||
"Objekte_height_mm": 621.237,
|
||||
"OFWeiche_CP1_x_mm": 521.27,
|
||||
"OFWeiche_CP1_y_mm": 261.237,
|
||||
@@ -292,15 +292,15 @@
|
||||
"Schaltungstyp": "M",
|
||||
"OFWeiche_center_line_width_mm": 500.23,
|
||||
"OFWeiche_center_line_height_mm": 600.197,
|
||||
"Objekte_width_mm": 521.23,
|
||||
"Objekte_width_mm": 553.774,
|
||||
"Objekte_height_mm": 621.237,
|
||||
"OFWeiche_CP1_x_mm": 21.0,
|
||||
"OFWeiche_CP1_x_mm": 53.544,
|
||||
"OFWeiche_CP1_y_mm": 261.237,
|
||||
"KurvenRichtung": 2,
|
||||
"SivasnrTEF": null,
|
||||
"OFWeiche_CP2_x_mm": 21.0,
|
||||
"OFWeiche_CP2_x_mm": 53.544,
|
||||
"OFWeiche_CP2_y_mm": 621.237,
|
||||
"OFWeiche_CP3_x_mm": 521.23,
|
||||
"OFWeiche_CP3_x_mm": 553.774,
|
||||
"OFWeiche_CP3_y_mm": 21.04
|
||||
},
|
||||
{
|
||||
@@ -311,15 +311,15 @@
|
||||
"Schaltungstyp": "P",
|
||||
"OFWeiche_center_line_width_mm": 500.23,
|
||||
"OFWeiche_center_line_height_mm": 600.197,
|
||||
"Objekte_width_mm": 521.23,
|
||||
"Objekte_width_mm": 553.774,
|
||||
"Objekte_height_mm": 621.237,
|
||||
"OFWeiche_CP1_x_mm": 21.0,
|
||||
"OFWeiche_CP1_x_mm": 53.544,
|
||||
"OFWeiche_CP1_y_mm": 261.237,
|
||||
"KurvenRichtung": 2,
|
||||
"SivasnrTEF": null,
|
||||
"OFWeiche_CP2_x_mm": 21.0,
|
||||
"OFWeiche_CP2_x_mm": 53.544,
|
||||
"OFWeiche_CP2_y_mm": 621.237,
|
||||
"OFWeiche_CP3_x_mm": 521.23,
|
||||
"OFWeiche_CP3_x_mm": 553.774,
|
||||
"OFWeiche_CP3_y_mm": 21.04
|
||||
},
|
||||
{
|
||||
@@ -349,7 +349,7 @@
|
||||
"Schaltungstyp": "M",
|
||||
"OFWeiche_center_line_width_mm": 700.374,
|
||||
"OFWeiche_center_line_height_mm": 700.185,
|
||||
"Objekte_width_mm": 721.374,
|
||||
"Objekte_width_mm": 753.918,
|
||||
"Objekte_height_mm": 721.225,
|
||||
"OFWeiche_CP1_x_mm": 721.414,
|
||||
"OFWeiche_CP1_y_mm": 361.225,
|
||||
@@ -368,7 +368,7 @@
|
||||
"Schaltungstyp": "P",
|
||||
"OFWeiche_center_line_width_mm": 700.374,
|
||||
"OFWeiche_center_line_height_mm": 700.185,
|
||||
"Objekte_width_mm": 721.374,
|
||||
"Objekte_width_mm": 753.918,
|
||||
"Objekte_height_mm": 721.225,
|
||||
"OFWeiche_CP1_x_mm": 721.414,
|
||||
"OFWeiche_CP1_y_mm": 361.225,
|
||||
@@ -406,15 +406,15 @@
|
||||
"Schaltungstyp": "M",
|
||||
"OFWeiche_center_line_width_mm": 700.374,
|
||||
"OFWeiche_center_line_height_mm": 700.185,
|
||||
"Objekte_width_mm": 721.374,
|
||||
"Objekte_width_mm": 753.918,
|
||||
"Objekte_height_mm": 721.225,
|
||||
"OFWeiche_CP1_x_mm": 21.0,
|
||||
"OFWeiche_CP1_x_mm": 53.544,
|
||||
"OFWeiche_CP1_y_mm": 361.225,
|
||||
"KurvenRichtung": 2,
|
||||
"SivasnrTEF": null,
|
||||
"OFWeiche_CP2_x_mm": 21.0,
|
||||
"OFWeiche_CP2_x_mm": 53.544,
|
||||
"OFWeiche_CP2_y_mm": 721.225,
|
||||
"OFWeiche_CP3_x_mm": 721.374,
|
||||
"OFWeiche_CP3_x_mm": 753.918,
|
||||
"OFWeiche_CP3_y_mm": 21.04
|
||||
},
|
||||
{
|
||||
@@ -425,15 +425,15 @@
|
||||
"Schaltungstyp": "P",
|
||||
"OFWeiche_center_line_width_mm": 700.374,
|
||||
"OFWeiche_center_line_height_mm": 700.185,
|
||||
"Objekte_width_mm": 721.374,
|
||||
"Objekte_width_mm": 753.918,
|
||||
"Objekte_height_mm": 721.225,
|
||||
"OFWeiche_CP1_x_mm": 21.0,
|
||||
"OFWeiche_CP1_x_mm": 53.544,
|
||||
"OFWeiche_CP1_y_mm": 361.225,
|
||||
"KurvenRichtung": 2,
|
||||
"SivasnrTEF": null,
|
||||
"OFWeiche_CP2_x_mm": 21.0,
|
||||
"OFWeiche_CP2_x_mm": 53.544,
|
||||
"OFWeiche_CP2_y_mm": 721.225,
|
||||
"OFWeiche_CP3_x_mm": 721.374,
|
||||
"OFWeiche_CP3_x_mm": 753.918,
|
||||
"OFWeiche_CP3_y_mm": 21.04
|
||||
},
|
||||
{
|
||||
@@ -463,7 +463,7 @@
|
||||
"Schaltungstyp": "M",
|
||||
"OFWeiche_center_line_width_mm": 200.007,
|
||||
"OFWeiche_center_line_height_mm": 749.8,
|
||||
"Objekte_width_mm": 242.047,
|
||||
"Objekte_width_mm": 274.591,
|
||||
"Objekte_height_mm": 749.8,
|
||||
"OFWeiche_CP1_x_mm": 200.007,
|
||||
"OFWeiche_CP1_y_mm": 389.8,
|
||||
@@ -482,7 +482,7 @@
|
||||
"Schaltungstyp": "P",
|
||||
"OFWeiche_center_line_width_mm": 200.007,
|
||||
"OFWeiche_center_line_height_mm": 749.8,
|
||||
"Objekte_width_mm": 242.047,
|
||||
"Objekte_width_mm": 274.591,
|
||||
"Objekte_height_mm": 749.8,
|
||||
"OFWeiche_CP1_x_mm": 200.007,
|
||||
"OFWeiche_CP1_y_mm": 389.8,
|
||||
@@ -501,15 +501,15 @@
|
||||
"Schaltungstyp": "M",
|
||||
"OFWeiche_center_line_width_mm": 200.007,
|
||||
"OFWeiche_center_line_height_mm": 749.8,
|
||||
"Objekte_width_mm": 242.047,
|
||||
"Objekte_width_mm": 274.591,
|
||||
"Objekte_height_mm": 749.8,
|
||||
"OFWeiche_CP1_x_mm": 21.0,
|
||||
"OFWeiche_CP1_x_mm": 53.544,
|
||||
"OFWeiche_CP1_y_mm": 389.8,
|
||||
"KurvenRichtung": 2,
|
||||
"SivasnrTEF": null,
|
||||
"OFWeiche_CP2_x_mm": 21.0,
|
||||
"OFWeiche_CP2_x_mm": 53.544,
|
||||
"OFWeiche_CP2_y_mm": 749.8,
|
||||
"OFWeiche_CP3_x_mm": 221.007,
|
||||
"OFWeiche_CP3_x_mm": 253.551,
|
||||
"OFWeiche_CP3_y_mm": 0.0
|
||||
},
|
||||
{
|
||||
@@ -520,15 +520,15 @@
|
||||
"Schaltungstyp": "P",
|
||||
"OFWeiche_center_line_width_mm": 200.007,
|
||||
"OFWeiche_center_line_height_mm": 749.8,
|
||||
"Objekte_width_mm": 242.047,
|
||||
"Objekte_width_mm": 274.591,
|
||||
"Objekte_height_mm": 749.8,
|
||||
"OFWeiche_CP1_x_mm": 21.0,
|
||||
"OFWeiche_CP1_x_mm": 53.544,
|
||||
"OFWeiche_CP1_y_mm": 389.8,
|
||||
"KurvenRichtung": 2,
|
||||
"SivasnrTEF": null,
|
||||
"OFWeiche_CP2_x_mm": 21.0,
|
||||
"OFWeiche_CP2_x_mm": 53.544,
|
||||
"OFWeiche_CP2_y_mm": 749.8,
|
||||
"OFWeiche_CP3_x_mm": 221.007,
|
||||
"OFWeiche_CP3_x_mm": 253.551,
|
||||
"OFWeiche_CP3_y_mm": 0.0
|
||||
},
|
||||
{
|
||||
@@ -1549,7 +1549,7 @@
|
||||
"Schaltungstyp": "M",
|
||||
"OFWeiche_center_line_width_mm": 101.5,
|
||||
"OFWeiche_center_line_height_mm": 360,
|
||||
"Objekte_width_mm": 141.938,
|
||||
"Objekte_width_mm": 174.482,
|
||||
"Objekte_height_mm": 360,
|
||||
"OFWeiche_CP1_x_mm": 109.552,
|
||||
"OFWeiche_CP1_y_mm": 0.0,
|
||||
@@ -1568,15 +1568,15 @@
|
||||
"Schaltungstyp": "M",
|
||||
"OFWeiche_center_line_width_mm": 101.5,
|
||||
"OFWeiche_center_line_height_mm": 360,
|
||||
"Objekte_width_mm": 141.938,
|
||||
"Objekte_width_mm": 174.482,
|
||||
"Objekte_height_mm": 360,
|
||||
"OFWeiche_CP1_x_mm": 21.0,
|
||||
"OFWeiche_CP1_x_mm": 53.544,
|
||||
"OFWeiche_CP1_y_mm": 0.0,
|
||||
"KurvenRichtung": 2,
|
||||
"SivasnrTEF": null,
|
||||
"OFWeiche_CP2_x_mm": 21.0,
|
||||
"OFWeiche_CP2_x_mm": 53.544,
|
||||
"OFWeiche_CP2_y_mm": 360,
|
||||
"OFWeiche_CP3_x_mm": 122.5,
|
||||
"OFWeiche_CP3_x_mm": 155.044,
|
||||
"OFWeiche_CP3_y_mm": 8.052
|
||||
},
|
||||
{
|
||||
@@ -1587,7 +1587,7 @@
|
||||
"Schaltungstyp": "P",
|
||||
"OFWeiche_center_line_width_mm": 101.5,
|
||||
"OFWeiche_center_line_height_mm": 360,
|
||||
"Objekte_width_mm": 141.938,
|
||||
"Objekte_width_mm": 174.482,
|
||||
"Objekte_height_mm": 360,
|
||||
"OFWeiche_CP1_x_mm": 109.552,
|
||||
"OFWeiche_CP1_y_mm": 0.0,
|
||||
@@ -1606,15 +1606,15 @@
|
||||
"Schaltungstyp": "P",
|
||||
"OFWeiche_center_line_width_mm": 101.5,
|
||||
"OFWeiche_center_line_height_mm": 360,
|
||||
"Objekte_width_mm": 141.938,
|
||||
"Objekte_width_mm": 174.482,
|
||||
"Objekte_height_mm": 360,
|
||||
"OFWeiche_CP1_x_mm": 21.0,
|
||||
"OFWeiche_CP1_x_mm": 53.544,
|
||||
"OFWeiche_CP1_y_mm": 0.0,
|
||||
"KurvenRichtung": 2,
|
||||
"SivasnrTEF": null,
|
||||
"OFWeiche_CP2_x_mm": 21.0,
|
||||
"OFWeiche_CP2_x_mm": 53.544,
|
||||
"OFWeiche_CP2_y_mm": 360,
|
||||
"OFWeiche_CP3_x_mm": 122.5,
|
||||
"OFWeiche_CP3_x_mm": 155.044,
|
||||
"OFWeiche_CP3_y_mm": 8.052
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
|
||||
import json
|
||||
import math
|
||||
|
||||
def modify_json_values(json_file):
|
||||
# 常量定义
|
||||
# Constant definitions
|
||||
WeichenKoerperWidth = 32.5437
|
||||
BogenProfileWidth = 42.080
|
||||
WeichenkProfileWidth = 42.000
|
||||
WeichenGerade = 360.000
|
||||
|
||||
# 读取JSON文件
|
||||
# Read JSON file
|
||||
with open(json_file, 'r', encoding='utf-8') as f:
|
||||
data = json.load(f)
|
||||
process_einzelweiche_items(data, WeichenkProfileWidth,BogenProfileWidth, WeichenGerade)
|
||||
process_einzelweiche_items(data,WeichenKoerperWidth, WeichenkProfileWidth,BogenProfileWidth, WeichenGerade)
|
||||
|
||||
process_doppelweiche_items(data, BogenProfileWidth, WeichenGerade)
|
||||
|
||||
process_dreifachweiche_items(data, WeichenkProfileWidth)
|
||||
# 询问是否保存
|
||||
save_choice = input("\n是否保存所有修改? (直接回车保存,输入n取消): ").lower()
|
||||
# Ask for save confirmation
|
||||
save_choice = input("\nSave all changes? (Press Enter to save, 'n' to cancel): ").lower()
|
||||
if save_choice == 'n':
|
||||
print("所有修改未保存")
|
||||
print("All changes discarded")
|
||||
else:
|
||||
with open(json_file, 'w', encoding='utf-8') as f:
|
||||
json.dump(data, f, indent=2, ensure_ascii=False)
|
||||
print("所有修改已保存!")
|
||||
print("All changes saved!")
|
||||
|
||||
def process_einzelweiche_items(data, WeichenkProfileWidth,BogenProfileWidth, WeichenGerade): # 筛选符合条件的项
|
||||
def process_einzelweiche_items(data,WeichenKoerperWidth, WeichenkProfileWidth,BogenProfileWidth, WeichenGerade): # Filter matching items
|
||||
filtered_items = [
|
||||
item for item in data
|
||||
if (item.get("SivasnrTEF") is None and
|
||||
@@ -33,59 +33,59 @@ def process_einzelweiche_items(data, WeichenkProfileWidth,BogenProfileWidth, Wei
|
||||
item.get("Schaltungstyp") == "M")
|
||||
]
|
||||
|
||||
print(f"共找到 {len(filtered_items)} 项符合条件的记录")
|
||||
print(f"Found {len(filtered_items)} matching records")
|
||||
print("="*50)
|
||||
|
||||
# 遍历每一项
|
||||
# Process each item
|
||||
for idx, item in enumerate(filtered_items, 1):
|
||||
print(f"\n第 {idx} 项:")
|
||||
print(f"\nItem {idx}:")
|
||||
print(f"Sivasnr: {item['Sivasnr']}")
|
||||
print(f"ProfilTyp: {item['ProfilTyp']}")
|
||||
print(f"Schaltungstyp: {item['Schaltungstyp']}")
|
||||
|
||||
# 处理 OFWeiche_center_line_width_mm
|
||||
# Process OFWeiche_center_line_width_mm
|
||||
current_value = item.get("OFWeiche_center_line_width_mm")
|
||||
print(f"\n当前 OFWeiche_center_line_width_mm: {current_value}")
|
||||
choice = input("是否修改? (y修改,直接回车跳过): ").lower()
|
||||
print(f"\nCurrent OFWeiche_center_line_width_mm: {current_value}")
|
||||
choice = input("Modify? (y to modify, Enter to skip): ").lower()
|
||||
if choice == 'y':
|
||||
new_value = input(f"请输入新值 (当前: {current_value}): ")
|
||||
new_value = input(f"Enter new value (current: {current_value}): ")
|
||||
try:
|
||||
old_value = item["OFWeiche_center_line_width_mm"]
|
||||
item["OFWeiche_center_line_width_mm"] = round(float(new_value), 3) if new_value.lower() != 'null' else None
|
||||
print(f"值已更新: {old_value} → {item['OFWeiche_center_line_width_mm']}")
|
||||
print(f"Value updated: {old_value} → {item['OFWeiche_center_line_width_mm']}")
|
||||
except ValueError:
|
||||
print("输入无效,保持原值")
|
||||
print("Invalid input, keeping original value")
|
||||
else:
|
||||
print("跳过修改")
|
||||
print("Skipping modification")
|
||||
|
||||
# 处理 OFWeiche_center_line_height_mm
|
||||
# Process OFWeiche_center_line_height_mm
|
||||
current_value = item.get("OFWeiche_center_line_height_mm")
|
||||
print(f"\n当前 OFWeiche_center_line_height_mm: {current_value}")
|
||||
choice = input("是否修改? (y修改,直接回车跳过): ").lower()
|
||||
print(f"\nCurrent OFWeiche_center_line_height_mm: {current_value}")
|
||||
choice = input("Modify? (y to modify, Enter to skip): ").lower()
|
||||
if choice == 'y':
|
||||
new_value = input(f"请输入新值 (当前: {current_value}): ")
|
||||
new_value = input(f"Enter new value (current: {current_value}): ")
|
||||
try:
|
||||
old_value = item["OFWeiche_center_line_height_mm"]
|
||||
item["OFWeiche_center_line_height_mm"] = round(float(new_value), 3) if new_value.lower() != 'null' else None
|
||||
print(f"值已更新: {old_value} → {item['OFWeiche_center_line_height_mm']}")
|
||||
print(f"Value updated: {old_value} → {item['OFWeiche_center_line_height_mm']}")
|
||||
except ValueError:
|
||||
print("输入无效,保持原值")
|
||||
print("Invalid input, keeping original value")
|
||||
else:
|
||||
print("跳过修改")
|
||||
print("Skipping modification")
|
||||
|
||||
# 计算相关值
|
||||
# Calculate related values
|
||||
if (item["OFWeiche_center_line_width_mm"] is not None and
|
||||
item["OFWeiche_center_line_height_mm"] is not None):
|
||||
|
||||
angle_rad = math.radians(item["KurvenWinkel"])
|
||||
|
||||
# 计算并打印基本值
|
||||
# Calculate and print basic values
|
||||
old_width = item.get("Objekte_width_mm")
|
||||
item["Objekte_width_mm"] = round(
|
||||
item["Objekte_width_mm"] = round(WeichenKoerperWidth+
|
||||
(BogenProfileWidth/2 * math.cos(angle_rad)) +
|
||||
item["OFWeiche_center_line_width_mm"] +
|
||||
WeichenkProfileWidth/2, 3)
|
||||
print(f"\nObjekte_width_mm 计算更新: {old_width} → {item['Objekte_width_mm']}")
|
||||
print(f"\nObjekte_width_mm calculated update: {old_width} → {item['Objekte_width_mm']}")
|
||||
|
||||
old_height = item.get("Objekte_height_mm")
|
||||
if item["KurvenWinkel"] == 22.5:
|
||||
@@ -95,35 +95,35 @@ def process_einzelweiche_items(data, WeichenkProfileWidth,BogenProfileWidth, Wei
|
||||
item["Objekte_height_mm"] = round(
|
||||
(BogenProfileWidth/2 * math.sin(angle_rad)) +
|
||||
item["OFWeiche_center_line_height_mm"], 3)
|
||||
print(f"Objekte_height_mm 计算更新: {old_height} → {item['Objekte_height_mm']}")
|
||||
print(f"Objekte_height_mm calculated update: {old_height} → {item['Objekte_height_mm']}")
|
||||
|
||||
# 计算并打印CP点坐标
|
||||
# Calculate and print CP point coordinates
|
||||
old_cp1x = item.get("OFWeiche_CP1_x_mm")
|
||||
item["OFWeiche_CP1_x_mm"] = round(
|
||||
(BogenProfileWidth/2 * math.sin(angle_rad)) +
|
||||
item["OFWeiche_center_line_width_mm"], 3)
|
||||
print(f"OFWeiche_CP1_x_mm 计算更新: {old_cp1x} → {item['OFWeiche_CP1_x_mm']}")
|
||||
print(f"OFWeiche_CP1_x_mm calculated update: {old_cp1x} → {item['OFWeiche_CP1_x_mm']}")
|
||||
|
||||
old_cp1y = item.get("OFWeiche_CP1_y_mm")
|
||||
item["OFWeiche_CP1_y_mm"] = round(
|
||||
item["Objekte_height_mm"] - WeichenGerade, 3)
|
||||
print(f"OFWeiche_CP1_y_mm 计算更新: {old_cp1y} → {item['OFWeiche_CP1_y_mm']}")
|
||||
print(f"OFWeiche_CP1_y_mm calculated update: {old_cp1y} → {item['OFWeiche_CP1_y_mm']}")
|
||||
|
||||
item["OFWeiche_CP2_x_mm"] = round(item["OFWeiche_CP1_x_mm"], 3)
|
||||
print(f"OFWeiche_CP2_x_mm 设置: {item['OFWeiche_CP2_x_mm']}")
|
||||
print(f"OFWeiche_CP2_x_mm set: {item['OFWeiche_CP2_x_mm']}")
|
||||
|
||||
item["OFWeiche_CP2_y_mm"] = round(item["Objekte_height_mm"], 3)
|
||||
print(f"OFWeiche_CP2_y_mm 设置: {item['OFWeiche_CP2_y_mm']}")
|
||||
print(f"OFWeiche_CP2_y_mm set: {item['OFWeiche_CP2_y_mm']}")
|
||||
|
||||
item["OFWeiche_CP3_x_mm"] = round(
|
||||
BogenProfileWidth/2 * math.cos(angle_rad), 3)
|
||||
print(f"OFWeiche_CP3_x_mm 计算更新: {item['OFWeiche_CP3_x_mm']}")
|
||||
print(f"OFWeiche_CP3_x_mm calculated update: {item['OFWeiche_CP3_x_mm']}")
|
||||
|
||||
item["OFWeiche_CP3_y_mm"] = round(
|
||||
BogenProfileWidth/2 * math.sin(angle_rad), 3)
|
||||
print(f"OFWeiche_CP3_y_mm 计算更新: {item['OFWeiche_CP3_y_mm']}")
|
||||
print(f"OFWeiche_CP3_y_mm calculated update: {item['OFWeiche_CP3_y_mm']}")
|
||||
|
||||
# 1. 查找Schaltungstyp为P的相似项(更新所有CP点)
|
||||
# 1. Find similar items with Schaltungstyp=P (update all CP points)
|
||||
current_profil = item["ProfilTyp"]
|
||||
if "S" in current_profil:
|
||||
prefix = current_profil.rsplit(" ", 1)[0]
|
||||
@@ -136,12 +136,12 @@ def process_einzelweiche_items(data, WeichenkProfileWidth,BogenProfileWidth, Wei
|
||||
x.get("Schaltungstyp") == "P"]
|
||||
|
||||
if similar_items_p:
|
||||
print(f"\n找到 {len(similar_items_p)} 个Schaltungstyp=P的相似项")
|
||||
print(f"\nFound {len(similar_items_p)} similar items with Schaltungstyp=P")
|
||||
for similar in similar_items_p:
|
||||
print(f"正在更新相似项: {similar['ProfilTyp']} (Sivasnr: {similar['Sivasnr']})")
|
||||
print(f"Updating similar item: {similar['ProfilTyp']} (Sivasnr: {similar['Sivasnr']})")
|
||||
|
||||
|
||||
# 更新所有字段包括CP点
|
||||
# Update all fields including CP points
|
||||
fields_to_copy = [
|
||||
"OFWeiche_center_line_width_mm",
|
||||
"OFWeiche_center_line_height_mm",
|
||||
@@ -161,9 +161,9 @@ def process_einzelweiche_items(data, WeichenkProfileWidth,BogenProfileWidth, Wei
|
||||
print(f" {field}: {old_val} → {similar[field]}")
|
||||
|
||||
else:
|
||||
print("没有找到Schaltungstyp=P的相似项")
|
||||
print("No similar items with Schaltungstyp=P found")
|
||||
|
||||
# 2. 查找L→R且KurvenRichtung=2的相似项
|
||||
# 2. Find L→R similar items with KurvenRichtung=2
|
||||
if "S" in current_profil and "-L-" in current_profil:
|
||||
r_profil = current_profil.replace("-L-", "-R-")
|
||||
|
||||
@@ -174,11 +174,11 @@ def process_einzelweiche_items(data, WeichenkProfileWidth,BogenProfileWidth, Wei
|
||||
x.get("Schaltungstyp") == "M"]
|
||||
|
||||
if similar_items_r:
|
||||
print(f"\n找到 {len(similar_items_r)} 个L→R的相似项(KurvenRichtung=2)")
|
||||
print(f"\nFound {len(similar_items_r)} L→R similar items (KurvenRichtung=2)")
|
||||
for similar in similar_items_r:
|
||||
print(f"正在更新R型相似项: {similar['ProfilTyp']} (Sivasnr: {similar['Sivasnr']})")
|
||||
print(f"Updating R-type similar item: {similar['ProfilTyp']} (Sivasnr: {similar['Sivasnr']})")
|
||||
|
||||
# 复制基础值
|
||||
# Copy basic values
|
||||
base_fields = [
|
||||
"OFWeiche_center_line_width_mm",
|
||||
"OFWeiche_center_line_height_mm",
|
||||
@@ -191,33 +191,33 @@ def process_einzelweiche_items(data, WeichenkProfileWidth,BogenProfileWidth, Wei
|
||||
similar[field] = item[field]
|
||||
print(f" {field}: {old_val} → {similar[field]}")
|
||||
|
||||
# 计算并打印R型特有的CP点
|
||||
# Calculate and print R-type specific CP points
|
||||
old_cp1x = similar.get("OFWeiche_CP1_x_mm")
|
||||
similar["OFWeiche_CP1_x_mm"] = round(WeichenkProfileWidth/2, 3)
|
||||
print(f" OFWeiche_CP1_x_mm (R型): {old_cp1x} → {similar['OFWeiche_CP1_x_mm']}")
|
||||
similar["OFWeiche_CP1_x_mm"] = round(WeichenKoerperWidth+WeichenkProfileWidth/2, 3)
|
||||
print(f" OFWeiche_CP1_x_mm (R-type): {old_cp1x} → {similar['OFWeiche_CP1_x_mm']}")
|
||||
|
||||
old_cp1y = similar.get("OFWeiche_CP1_y_mm")
|
||||
similar["OFWeiche_CP1_y_mm"] = round(item["Objekte_height_mm"] - WeichenGerade, 3)
|
||||
print(f" OFWeiche_CP1_y_mm (R型): {old_cp1y} → {similar['OFWeiche_CP1_y_mm']}")
|
||||
print(f" OFWeiche_CP1_y_mm (R-type): {old_cp1y} → {similar['OFWeiche_CP1_y_mm']}")
|
||||
|
||||
similar["OFWeiche_CP2_x_mm"] = similar["OFWeiche_CP1_x_mm"]
|
||||
print(f" OFWeiche_CP2_x_mm (R型): 设置为 {similar['OFWeiche_CP2_x_mm']}")
|
||||
print(f" OFWeiche_CP2_x_mm (R-type): Set to {similar['OFWeiche_CP2_x_mm']}")
|
||||
|
||||
old_cp2y = similar.get("OFWeiche_CP2_y_mm")
|
||||
similar["OFWeiche_CP2_y_mm"] = round(item["Objekte_height_mm"], 3)
|
||||
print(f" OFWeiche_CP2_y_mm (R型): {old_cp2y} → {similar['OFWeiche_CP2_y_mm']}")
|
||||
print(f" OFWeiche_CP2_y_mm (R-type): {old_cp2y} → {similar['OFWeiche_CP2_y_mm']}")
|
||||
|
||||
old_cp3x = similar.get("OFWeiche_CP3_x_mm")
|
||||
similar["OFWeiche_CP3_x_mm"] = round(
|
||||
similar["OFWeiche_CP1_x_mm"] + item["OFWeiche_center_line_width_mm"], 3)
|
||||
print(f" OFWeiche_CP3_x_mm (R型): {old_cp3x} → {similar['OFWeiche_CP3_x_mm']}")
|
||||
print(f" OFWeiche_CP3_x_mm (R-type): {old_cp3x} → {similar['OFWeiche_CP3_x_mm']}")
|
||||
|
||||
old_cp3y = similar.get("OFWeiche_CP3_y_mm")
|
||||
similar["OFWeiche_CP3_y_mm"] = round(
|
||||
BogenProfileWidth/2 * math.sin(angle_rad), 3)
|
||||
print(f" OFWeiche_CP3_y_mm (R型): {old_cp3y} → {similar['OFWeiche_CP3_y_mm']}")
|
||||
print(f" OFWeiche_CP3_y_mm (R-type): {old_cp3y} → {similar['OFWeiche_CP3_y_mm']}")
|
||||
|
||||
# 3. 查找该R型项的P型对应项
|
||||
# 3. Find P-type counterparts for this R-type item
|
||||
r_p_profil = r_profil.replace("MIT M", "MIT P")
|
||||
|
||||
similar_items_r_p = [x for x in data
|
||||
@@ -226,9 +226,9 @@ def process_einzelweiche_items(data, WeichenkProfileWidth,BogenProfileWidth, Wei
|
||||
x.get("Schaltungstyp") == "P"]
|
||||
|
||||
if similar_items_r_p:
|
||||
print(f"\n找到 {len(similar_items_r_p)} 个R型P型对应项")
|
||||
print(f"\nFound {len(similar_items_r_p)} R-type P-type counterparts")
|
||||
for similar_r_p in similar_items_r_p:
|
||||
print(f"正在更新R型P型对应项: {similar_r_p['ProfilTyp']} (Sivasnr: {similar_r_p['Sivasnr']})")
|
||||
print(f"Updating R-type P-type counterpart: {similar_r_p['ProfilTyp']} (Sivasnr: {similar_r_p['Sivasnr']})")
|
||||
|
||||
fields_to_copy_r_p = [
|
||||
"OFWeiche_center_line_width_mm",
|
||||
@@ -248,112 +248,110 @@ def process_einzelweiche_items(data, WeichenkProfileWidth,BogenProfileWidth, Wei
|
||||
similar_r_p[field] = similar[field]
|
||||
print(f" {field}: {old_val} → {similar_r_p[field]}")
|
||||
|
||||
save_choice = input(f"是否确认更新此项? (直接回车确认,输入n取消): ").lower()
|
||||
save_choice = input(f"Confirm update for this item? (Enter to confirm, 'n' to cancel): ").lower()
|
||||
if save_choice == 'n':
|
||||
print("此项更新已取消")
|
||||
# 恢复原值
|
||||
print("Update for this item cancelled")
|
||||
# Restore original values
|
||||
for field in fields_to_copy_r_p:
|
||||
if field in similar_r_p:
|
||||
similar_r_p[field] = old_val
|
||||
else:
|
||||
print("没有找到R型P型对应项")
|
||||
print("No R-type P-type counterparts found")
|
||||
else:
|
||||
|
||||
print("没有找到L→R的相似项")
|
||||
print("No L→R similar items found")
|
||||
|
||||
def process_doppelweiche_items(data,BogenProfileWidth, WeichenGerade):
|
||||
# 筛选Doppelweiche类型的项
|
||||
# Filter Doppelweiche type items
|
||||
filtered_items = [
|
||||
|
||||
item for item in data
|
||||
if (item.get("WeichenTyp") == "Doppelweiche" and
|
||||
item.get("Schaltungstyp") == "M" and
|
||||
item.get("SivasnrTEF") is None)
|
||||
]
|
||||
|
||||
print(f"\n\n共找到 {len(filtered_items)} 项Doppelweiche类型记录")
|
||||
print(f"\n\nFound {len(filtered_items)} Doppelweiche type records")
|
||||
print("="*50)
|
||||
|
||||
# 遍历每一项Doppelweiche
|
||||
# Process each Doppelweiche item
|
||||
for idx, item in enumerate(filtered_items, 1):
|
||||
print(f"\n第 {idx} 项Doppelweiche:")
|
||||
print(f"\nDoppelweiche item {idx}:")
|
||||
print(f"Sivasnr: {item['Sivasnr']}")
|
||||
print(f"ProfilTyp: {item['ProfilTyp']}")
|
||||
print(f"Schaltungstyp: {item['Schaltungstyp']}")
|
||||
print(f"KurvenWinkel: {item['KurvenWinkel']}")
|
||||
|
||||
# 处理 OFWeiche_center_line_width_mm
|
||||
# Process OFWeiche_center_line_width_mm
|
||||
current_value = item.get("OFWeiche_center_line_width_mm")
|
||||
print(f"\n当前 OFWeiche_center_line_width_mm: {current_value}")
|
||||
choice = input("是否修改? (y修改,直接回车跳过): ").lower()
|
||||
print(f"\nCurrent OFWeiche_center_line_width_mm: {current_value}")
|
||||
choice = input("Modify? (y to modify, Enter to skip): ").lower()
|
||||
if choice == 'y':
|
||||
new_value = input(f"请输入新值 (当前: {current_value}): ")
|
||||
new_value = input(f"Enter new value (current: {current_value}): ")
|
||||
try:
|
||||
old_value = item["OFWeiche_center_line_width_mm"]
|
||||
item["OFWeiche_center_line_width_mm"] = round(float(new_value), 3) if new_value.lower() != 'null' else None
|
||||
print(f"值已更新: {old_value} → {item['OFWeiche_center_line_width_mm']}")
|
||||
print(f"Value updated: {old_value} → {item['OFWeiche_center_line_width_mm']}")
|
||||
except ValueError:
|
||||
print("输入无效,保持原值")
|
||||
print("Invalid input, keeping original value")
|
||||
else:
|
||||
print("跳过修改")
|
||||
print("Skipping modification")
|
||||
|
||||
# 处理 OFWeiche_center_line_height_mm
|
||||
# Process OFWeiche_center_line_height_mm
|
||||
current_value = item.get("OFWeiche_center_line_height_mm")
|
||||
print(f"\n当前 OFWeiche_center_line_height_mm: {current_value}")
|
||||
choice = input("是否修改? (y修改,直接回车跳过): ").lower()
|
||||
print(f"\nCurrent OFWeiche_center_line_height_mm: {current_value}")
|
||||
choice = input("Modify? (y to modify, Enter to skip): ").lower()
|
||||
if choice == 'y':
|
||||
new_value = input(f"请输入新值 (当前: {current_value}): ")
|
||||
new_value = input(f"Enter new value (current: {current_value}): ")
|
||||
try:
|
||||
old_value = item["OFWeiche_center_line_height_mm"]
|
||||
item["OFWeiche_center_line_height_mm"] = round(float(new_value), 3) if new_value.lower() != 'null' else None
|
||||
print(f"值已更新: {old_value} → {item['OFWeiche_center_line_height_mm']}")
|
||||
print(f"Value updated: {old_value} → {item['OFWeiche_center_line_height_mm']}")
|
||||
except ValueError:
|
||||
print("输入无效,保持原值")
|
||||
print("Invalid input, keeping original value")
|
||||
else:
|
||||
print("跳过修改")
|
||||
print("Skipping modification")
|
||||
|
||||
# 计算相关值
|
||||
# Calculate related values
|
||||
if (item["OFWeiche_center_line_width_mm"] is not None and
|
||||
item["OFWeiche_center_line_height_mm"] is not None):
|
||||
|
||||
angle_rad = math.radians(item["KurvenWinkel"])
|
||||
|
||||
# 计算并打印基本值(Doppelweiche特有公式)
|
||||
# Calculate and print basic values (Doppelweiche specific formula)
|
||||
old_width = item.get("Objekte_width_mm")
|
||||
item["Objekte_width_mm"] = round(
|
||||
(BogenProfileWidth/2 * math.cos(angle_rad)) +
|
||||
item["OFWeiche_center_line_width_mm"] +
|
||||
BogenProfileWidth/2 * math.cos(angle_rad), 3)
|
||||
print(f"\nObjekte_width_mm 计算更新: {old_width} → {item['Objekte_width_mm']}")
|
||||
print(f"\nObjekte_width_mm calculated update: {old_width} → {item['Objekte_width_mm']}")
|
||||
|
||||
old_height = item.get("Objekte_height_mm")
|
||||
item["Objekte_height_mm"] = round(
|
||||
(BogenProfileWidth/2 * math.sin(angle_rad)) +
|
||||
item["OFWeiche_center_line_height_mm"], 3)
|
||||
print(f"Objekte_height_mm 计算更新: {old_height} → {item['Objekte_height_mm']}")
|
||||
print(f"Objekte_height_mm calculated update: {old_height} → {item['Objekte_height_mm']}")
|
||||
|
||||
# 计算并打印CP点坐标(Doppelweiche特有公式)
|
||||
# Calculate and print CP point coordinates (Doppelweiche specific formula)
|
||||
item["OFWeiche_CP1_x_mm"] = round(item["Objekte_width_mm"]/2, 3)
|
||||
print(f"OFWeiche_CP1_x_mm 计算更新: {item['OFWeiche_CP1_x_mm']}")
|
||||
print(f"OFWeiche_CP1_x_mm calculated update: {item['OFWeiche_CP1_x_mm']}")
|
||||
|
||||
item["OFWeiche_CP1_y_mm"] = round(item["Objekte_height_mm"], 3)
|
||||
print(f"OFWeiche_CP1_y_mm 计算更新: {item['OFWeiche_CP1_y_mm']}")
|
||||
print(f"OFWeiche_CP1_y_mm calculated update: {item['OFWeiche_CP1_y_mm']}")
|
||||
|
||||
item["OFWeiche_CP2_x_mm"] = round(BogenProfileWidth/2 * math.cos(angle_rad), 3)
|
||||
print(f"OFWeiche_CP2_x_mm 计算更新: {item['OFWeiche_CP2_x_mm']}")
|
||||
print(f"OFWeiche_CP2_x_mm calculated update: {item['OFWeiche_CP2_x_mm']}")
|
||||
|
||||
item["OFWeiche_CP2_y_mm"] = round(BogenProfileWidth/2 * math.sin(angle_rad), 3)
|
||||
print(f"OFWeiche_CP2_y_mm 计算更新: {item['OFWeiche_CP2_y_mm']}")
|
||||
print(f"OFWeiche_CP2_y_mm calculated update: {item['OFWeiche_CP2_y_mm']}")
|
||||
|
||||
item["OFWeiche_CP3_x_mm"] = round(
|
||||
BogenProfileWidth/2 * math.cos(angle_rad) +
|
||||
item["OFWeiche_center_line_width_mm"], 3)
|
||||
print(f"OFWeiche_CP3_x_mm 计算更新: {item['OFWeiche_CP3_x_mm']}")
|
||||
print(f"OFWeiche_CP3_x_mm calculated update: {item['OFWeiche_CP3_x_mm']}")
|
||||
|
||||
item["OFWeiche_CP3_y_mm"] = item["OFWeiche_CP2_y_mm"]
|
||||
print(f"OFWeiche_CP3_y_mm 设置: {item['OFWeiche_CP3_y_mm']}")
|
||||
print(f"OFWeiche_CP3_y_mm set: {item['OFWeiche_CP3_y_mm']}")
|
||||
|
||||
# 1. 查找类似项1(D型P型)
|
||||
# 1. Find similar items (D-type P-type)
|
||||
current_profil = item["ProfilTyp"]
|
||||
if "S D" in current_profil:
|
||||
d_p_profil = current_profil.replace("MIT M", "MIT P")
|
||||
@@ -363,11 +361,11 @@ def process_doppelweiche_items(data,BogenProfileWidth, WeichenGerade):
|
||||
x.get("SivasnrTEF") is None]
|
||||
|
||||
if similar_items_d_p:
|
||||
print(f"\n找到 {len(similar_items_d_p)} 个D型P型相似项")
|
||||
print(f"\nFound {len(similar_items_d_p)} D-type P-type similar items")
|
||||
for similar in similar_items_d_p:
|
||||
print(f"正在更新D型P型相似项: {similar['ProfilTyp']} (Sivasnr: {similar['Sivasnr']})")
|
||||
print(f"Updating D-type P-type similar item: {similar['ProfilTyp']} (Sivasnr: {similar['Sivasnr']})")
|
||||
|
||||
# 更新所有字段
|
||||
# Update all fields
|
||||
fields_to_copy = [
|
||||
"OFWeiche_center_line_width_mm",
|
||||
"OFWeiche_center_line_height_mm",
|
||||
@@ -386,9 +384,9 @@ def process_doppelweiche_items(data,BogenProfileWidth, WeichenGerade):
|
||||
similar[field] = item[field]
|
||||
print(f" {field}: {old_val} → {similar[field]}")
|
||||
else:
|
||||
print("没有找到D型P型相似项")
|
||||
print("No D-type P-type similar items found")
|
||||
|
||||
# 2. 查找类似项2(T型M型)
|
||||
# 2. Find similar items (T-type M-type)
|
||||
if "S D" in current_profil:
|
||||
t_m_profil = current_profil.replace("S D", "S T")
|
||||
|
||||
@@ -398,13 +396,13 @@ def process_doppelweiche_items(data,BogenProfileWidth, WeichenGerade):
|
||||
x.get("Schaltungstyp") == "M"]
|
||||
|
||||
if similar_items_t_m:
|
||||
print(f"\n找到 {len(similar_items_t_m)} 个T型M型相似项")
|
||||
print(f"\nFound {len(similar_items_t_m)} T-type M-type similar items")
|
||||
for similar in similar_items_t_m:
|
||||
print(f"正在更新T型M型相似项: {similar['ProfilTyp']} (Sivasnr: {similar['Sivasnr']})")
|
||||
print(f"Updating T-type M-type similar item: {similar['ProfilTyp']} (Sivasnr: {similar['Sivasnr']})")
|
||||
if similar["KurvenWinkel"] == 22.5:
|
||||
print("检测到KurvenWinkel=22.5,采用特殊处理方式")
|
||||
print("Detected KurvenWinkel=22.5, applying special handling")
|
||||
|
||||
# 特殊处理逻辑
|
||||
# Special handling logic
|
||||
similar["OFWeiche_center_line_width_mm"] = item["OFWeiche_center_line_width_mm"]
|
||||
print(f" OFWeiche_center_line_width_mm: → {similar['OFWeiche_center_line_width_mm']}")
|
||||
|
||||
@@ -436,7 +434,7 @@ def process_doppelweiche_items(data,BogenProfileWidth, WeichenGerade):
|
||||
print(f" OFWeiche_CP3_y_mm: → 20")
|
||||
|
||||
else:
|
||||
# 更新基本字段
|
||||
# Update basic fields
|
||||
base_fields = [
|
||||
"OFWeiche_center_line_width_mm",
|
||||
"OFWeiche_center_line_height_mm",
|
||||
@@ -455,14 +453,14 @@ def process_doppelweiche_items(data,BogenProfileWidth, WeichenGerade):
|
||||
similar[field] = item[field]
|
||||
print(f" {field}: {old_val} → {similar[field]}")
|
||||
|
||||
# 添加CP4点(T型特有)
|
||||
# Add CP4 point (T-type specific)
|
||||
similar["OFWeiche_CP4_x_mm"] = round(item["Objekte_width_mm"]/2, 3)
|
||||
print(f" OFWeiche_CP4_x_mm 添加: {similar['OFWeiche_CP4_x_mm']}")
|
||||
print(f" OFWeiche_CP4_x_mm added: {similar['OFWeiche_CP4_x_mm']}")
|
||||
|
||||
similar["OFWeiche_CP4_y_mm"] = round(item["Objekte_height_mm"] - WeichenGerade, 3)
|
||||
print(f" OFWeiche_CP4_y_mm 添加: {similar['OFWeiche_CP4_y_mm']}")
|
||||
print(f" OFWeiche_CP4_y_mm added: {similar['OFWeiche_CP4_y_mm']}")
|
||||
|
||||
# 3. 查找T型P型对应项
|
||||
# 3. Find T-type P-type counterparts
|
||||
t_p_profil = t_m_profil.replace("MIT M", "MIT P")
|
||||
|
||||
similar_items_t_p = [x for x in data
|
||||
@@ -471,11 +469,11 @@ def process_doppelweiche_items(data,BogenProfileWidth, WeichenGerade):
|
||||
x.get("Schaltungstyp") == "P"]
|
||||
|
||||
if similar_items_t_p:
|
||||
print(f"\n找到 {len(similar_items_t_p)} 个T型P型对应项")
|
||||
print(f"\nFound {len(similar_items_t_p)} T-type P-type counterparts")
|
||||
for similar_t_p in similar_items_t_p:
|
||||
print(f"正在更新T型P型对应项: {similar_t_p['ProfilTyp']} (Sivasnr: {similar_t_p['Sivasnr']})")
|
||||
print(f"Updating T-type P-type counterpart: {similar_t_p['ProfilTyp']} (Sivasnr: {similar_t_p['Sivasnr']})")
|
||||
|
||||
# 更新所有字段包括CP4点
|
||||
# Update all fields including CP4 point
|
||||
fields_to_copy_t_p = [
|
||||
"OFWeiche_center_line_width_mm",
|
||||
"OFWeiche_center_line_height_mm",
|
||||
@@ -496,19 +494,19 @@ def process_doppelweiche_items(data,BogenProfileWidth, WeichenGerade):
|
||||
similar_t_p[field] = similar[field]
|
||||
print(f" {field}: {old_val} → {similar_t_p[field]}")
|
||||
|
||||
# 添加保存确认提示
|
||||
save_choice = input(f"是否确认更新此项? (直接回车确认,输入n取消): ").lower()
|
||||
# Add save confirmation prompt
|
||||
save_choice = input(f"Confirm update for this item? (Enter to confirm, 'n' to cancel): ").lower()
|
||||
if save_choice == 'n':
|
||||
print("此项更新已取消")
|
||||
# 恢复原值
|
||||
print("Update for this item cancelled")
|
||||
# Restore original values
|
||||
for field in fields_to_copy_t_p:
|
||||
similar_t_p[field] = old_val
|
||||
else:
|
||||
print("没有找到T型P型对应项")
|
||||
print("No T-type P-type counterparts found")
|
||||
else:
|
||||
print("没有找到T型M型相似项")
|
||||
print("No T-type M-type similar items found")
|
||||
def process_dreifachweiche_items(data, WeichenkProfileWidth):
|
||||
# 筛选Dreifachweiche类型的项
|
||||
# Filter Dreifachweiche type items
|
||||
filtered_items = [
|
||||
item for item in data
|
||||
if (item.get("WeichenTyp") == "Dreifachweiche" and
|
||||
@@ -516,52 +514,52 @@ def process_dreifachweiche_items(data, WeichenkProfileWidth):
|
||||
item.get("SivasnrTEF") is None)
|
||||
]
|
||||
|
||||
print(f"\n\n共找到 {len(filtered_items)} 项Dreifachweiche类型记录")
|
||||
print(f"\n\nFound {len(filtered_items)} Dreifachweiche type records")
|
||||
print("="*50)
|
||||
|
||||
for idx, item in enumerate(filtered_items, 1):
|
||||
print(f"\n第 {idx} 项Dreifachweiche:")
|
||||
print(f"\nDreifachweiche item {idx}:")
|
||||
print(f"Sivasnr: {item['Sivasnr']}")
|
||||
print(f"ProfilTyp: {item['ProfilTyp']}")
|
||||
|
||||
# 交互修改OFWeiche_center_line_width_mm
|
||||
# Interactive modification of OFWeiche_center_line_width_mm
|
||||
current_value = item.get("OFWeiche_center_line_width_mm")
|
||||
print(f"\n当前 OFWeiche_center_line_width_mm: {current_value}")
|
||||
choice = input("是否修改? (y修改,直接回车跳过): ").lower()
|
||||
print(f"\nCurrent OFWeiche_center_line_width_mm: {current_value}")
|
||||
choice = input("Modify? (y to modify, Enter to skip): ").lower()
|
||||
if choice == 'y':
|
||||
new_value = input(f"请输入新值 (当前: {current_value}): ")
|
||||
new_value = input(f"Enter new value (current: {current_value}): ")
|
||||
try:
|
||||
old_value = item["OFWeiche_center_line_width_mm"]
|
||||
item["OFWeiche_center_line_width_mm"] = round(float(new_value), 3) if new_value.lower() != 'null' else None
|
||||
print(f"值已更新: {old_value} → {item['OFWeiche_center_line_width_mm']}")
|
||||
print(f"Value updated: {old_value} → {item['OFWeiche_center_line_width_mm']}")
|
||||
except ValueError:
|
||||
print("输入无效,保持原值")
|
||||
print("Invalid input, keeping original value")
|
||||
|
||||
# 交互修改OFWeiche_center_line_height_mm
|
||||
# Interactive modification of OFWeiche_center_line_height_mm
|
||||
current_value = item.get("OFWeiche_center_line_height_mm")
|
||||
print(f"\n当前 OFWeiche_center_line_height_mm: {current_value}")
|
||||
choice = input("是否修改? (y修改,直接回车跳过): ").lower()
|
||||
print(f"\nCurrent OFWeiche_center_line_height_mm: {current_value}")
|
||||
choice = input("Modify? (y to modify, Enter to skip): ").lower()
|
||||
if choice == 'y':
|
||||
new_value = input(f"请输入新值 (当前: {current_value}): ")
|
||||
new_value = input(f"Enter new value (current: {current_value}): ")
|
||||
try:
|
||||
old_value = item["OFWeiche_center_line_height_mm"]
|
||||
item["OFWeiche_center_line_height_mm"] = round(float(new_value), 3) if new_value.lower() != 'null' else None
|
||||
print(f"值已更新: {old_value} → {item['OFWeiche_center_line_height_mm']}")
|
||||
print(f"Value updated: {old_value} → {item['OFWeiche_center_line_height_mm']}")
|
||||
except ValueError:
|
||||
print("输入无效,保持原值")
|
||||
print("Invalid input, keeping original value")
|
||||
|
||||
# 计算相关值
|
||||
# Calculate related values
|
||||
if (item["OFWeiche_center_line_width_mm"] is not None and
|
||||
item["OFWeiche_center_line_height_mm"] is not None):
|
||||
|
||||
# 计算基本尺寸
|
||||
# Calculate basic dimensions
|
||||
item["Objekte_width_mm"] = round(item["OFWeiche_center_line_width_mm"], 3)
|
||||
print(f"\nObjekte_width_mm 计算更新: {item['Objekte_width_mm']}")
|
||||
print(f"\nObjekte_width_mm calculated update: {item['Objekte_width_mm']}")
|
||||
|
||||
item["Objekte_height_mm"] = round(WeichenkProfileWidth/2 + item["OFWeiche_center_line_height_mm"], 3)
|
||||
print(f"Objekte_height_mm 计算更新: {item['Objekte_height_mm']}")
|
||||
print(f"Objekte_height_mm calculated update: {item['Objekte_height_mm']}")
|
||||
|
||||
# 计算控制点
|
||||
# Calculate control points
|
||||
item["OFWeiche_CP1_x_mm"] = round(item["Objekte_width_mm"]/2, 3)
|
||||
item["OFWeiche_CP1_y_mm"] = 0
|
||||
item["OFWeiche_CP2_x_mm"] = 0
|
||||
@@ -575,7 +573,7 @@ def process_dreifachweiche_items(data, WeichenkProfileWidth):
|
||||
print(f"OFWeiche_CP3_x_mm: {item['OFWeiche_CP3_x_mm']}")
|
||||
print(f"OFWeiche_CP3_y_mm: {item['OFWeiche_CP3_y_mm']}")
|
||||
|
||||
# 查找相似项(P型)
|
||||
# Find similar items (P-type)
|
||||
if "WEICHE S C DELTA" in item["ProfilTyp"]:
|
||||
similar_profil = item["ProfilTyp"].replace("KPL. M", "KPL. P")
|
||||
|
||||
@@ -584,9 +582,9 @@ def process_dreifachweiche_items(data, WeichenkProfileWidth):
|
||||
x.get("SivasnrTEF") is None]
|
||||
|
||||
if similar_items:
|
||||
print(f"\n找到 {len(similar_items)} 个相似P型项")
|
||||
print(f"\nFound {len(similar_items)} similar P-type items")
|
||||
for similar in similar_items:
|
||||
print(f"\n正在更新: {similar['ProfilTyp']} (Sivasnr: {similar['Sivasnr']})")
|
||||
print(f"\nUpdating: {similar['ProfilTyp']} (Sivasnr: {similar['Sivasnr']})")
|
||||
|
||||
fields_to_copy = [
|
||||
"OFWeiche_center_line_width_mm",
|
||||
@@ -601,22 +599,22 @@ def process_dreifachweiche_items(data, WeichenkProfileWidth):
|
||||
"OFWeiche_CP3_y_mm"
|
||||
]
|
||||
|
||||
print("\n更新中:")
|
||||
print("\nUpdating:")
|
||||
for field in fields_to_copy:
|
||||
print(f" {field}: {similar.get(field)} → {item[field]}")
|
||||
similar[field] = item[field]# 实际更新相似项的值
|
||||
similar[field] = item[field] # Actually update the similar item's value
|
||||
|
||||
choice = input("\n确认更新此项? (回车确认/n取消): ").lower()
|
||||
choice = input("\nConfirm update for this item? (Enter to confirm/n to cancel): ").lower()
|
||||
if choice == 'n':
|
||||
print("取消此项更新")
|
||||
print("Update for this item cancelled")
|
||||
for field in fields_to_copy:
|
||||
similar[field] = similar[field]
|
||||
else:
|
||||
print("此项更新已确认")
|
||||
print("Update for this item confirmed")
|
||||
|
||||
else:
|
||||
print("没有找到相似P型项")
|
||||
print("No similar P-type items found")
|
||||
|
||||
if __name__ == "__main__":
|
||||
json_file_path = "omniflo_weichen.json" # 替换为你的JSON文件路径
|
||||
json_file_path = "omniflo_weichen.json" # Replace with your JSON file path
|
||||
modify_json_values(json_file_path)
|
||||
Reference in New Issue
Block a user