|
|
@@ -7,12 +7,13 @@ import os
|
|
|
import tkinter as tk
|
|
|
from tkinter.filedialog import asksaveasfilename
|
|
|
from openpyxl import Workbook
|
|
|
-from openpyxl.styles import Font, PatternFill, Alignment
|
|
|
+from openpyxl.styles import Font, PatternFill, Alignment, Border, Side
|
|
|
from openpyxl.utils import get_column_letter
|
|
|
|
|
|
# Colores exactos de SAP2000
|
|
|
-AZUL_SAP = "000080" # Azul marino cabecera
|
|
|
-AMARILLO_SAP = "FFFF00" # Amarillo fila de tipos
|
|
|
+AZUL_TITULO = "33CCCC" # Azul oscurito título
|
|
|
+AZUL_SAP = "CCFFFF" # Azul marino cabecera
|
|
|
+
|
|
|
|
|
|
# Barra de progreso (la misma que usas en el script principal)
|
|
|
def printProgressBar(iteration, total, prefix='', suffix='', decimals=1, length=50, fill='█'):
|
|
|
@@ -42,7 +43,7 @@ def extraer_combinaciones_a_excel(SapModel, ruta_excel_origen=None):
|
|
|
carpeta = os.path.dirname(ruta_excel_origen)
|
|
|
nombre_base = os.path.splitext(os.path.basename(ruta_excel_origen))[0]
|
|
|
nombre_sugerido = f"{nombre_base}_COMBINACIONES_SAP2000.xlsx"
|
|
|
- initialfile = os.path.join(carpeta, nombre_sugerido)
|
|
|
+ initialfile = nombre_sugerido
|
|
|
else:
|
|
|
initialfile = "COMBINACIONES_SAP2000.xlsx"
|
|
|
|
|
|
@@ -92,15 +93,16 @@ def extraer_combinaciones_a_excel(SapModel, ruta_excel_origen=None):
|
|
|
|
|
|
# 1. Título
|
|
|
ws['A1'] = "TABLE: Combination Definitions"
|
|
|
- ws['A1'].font = Font(name="Arial Narrow", size=12, bold=True)
|
|
|
+ ws['A1'].font = Font(name="Arial Narrow", size=11, bold=True)
|
|
|
ws['A1'].alignment = Alignment(horizontal="center")
|
|
|
+ ws['A1'].fill = PatternFill(start_color=AZUL_TITULO, end_color=AZUL_TITULO, fill_type="solid")
|
|
|
ws.merge_cells('A1:D1')
|
|
|
|
|
|
# 2. Cabeceras (azul marino SAP2000)
|
|
|
cabeceras = ["ComboName", "ComboType", "CaseName", "ScaleFactor"]
|
|
|
for c, texto in enumerate(cabeceras, 1):
|
|
|
cell = ws.cell(row=2, column=c, value=texto)
|
|
|
- cell.font = Font(name="Arial Narrow", bold=True, color="FFFFFF")
|
|
|
+ cell.font = Font(name="Arial Narrow", bold=True, color="000000", size=10)
|
|
|
cell.fill = PatternFill(start_color=AZUL_SAP, end_color=AZUL_SAP, fill_type="solid")
|
|
|
cell.alignment = Alignment(horizontal="center")
|
|
|
|
|
|
@@ -108,15 +110,21 @@ def extraer_combinaciones_a_excel(SapModel, ruta_excel_origen=None):
|
|
|
tipos = ["Text", "Text", "Text", "Unitless"]
|
|
|
for c, texto in enumerate(tipos, 1):
|
|
|
cell = ws.cell(row=3, column=c, value=texto)
|
|
|
- cell.font = Font(name="Arial Narrow", color="000000")
|
|
|
- cell.fill = PatternFill(start_color=AMARILLO_SAP, end_color=AMARILLO_SAP, fill_type="solid")
|
|
|
+ cell.font = Font(name="Arial Narrow", color="000000", size=10)
|
|
|
+ cell.fill = PatternFill(start_color=AZUL_SAP, end_color=AZUL_SAP, fill_type="solid")
|
|
|
cell.alignment = Alignment(horizontal="center")
|
|
|
|
|
|
# 4. Datos
|
|
|
for r, fila in enumerate(datos, start=4):
|
|
|
for c, valor in enumerate(fila, 1):
|
|
|
cell = ws.cell(row=r, column=c, value=valor)
|
|
|
- cell.font = Font(name="Arial Narrow")
|
|
|
+ cell.font = Font(name="Arial Narrow", size=10)
|
|
|
+
|
|
|
+ # Aplicar borde fino a todas las celdas
|
|
|
+ thin_border = Border(left=Side(style='thin'), right=Side(style='thin'), top=Side(style='thin'), bottom=Side(style='thin'))
|
|
|
+ for row in ws.iter_rows():
|
|
|
+ for cell in row:
|
|
|
+ cell.border = thin_border
|
|
|
|
|
|
# Autoajustar columnas según el contenido (excluyendo la primera fila que está fusionada)
|
|
|
column_widths = {1: 18, 2: 12, 3: 25, 4: 12} # Anchos por defecto
|
|
|
@@ -133,5 +141,4 @@ def extraer_combinaciones_a_excel(SapModel, ruta_excel_origen=None):
|
|
|
# Guardar
|
|
|
wb.save(archivo_salida)
|
|
|
print(f"\nCOMBINACIONES EXTRAÍDAS CORRECTAMENTE")
|
|
|
- print(f"Archivo: {archivo_salida}")
|
|
|
- print("Formato 100% idéntico al reporte oficial de SAP2000\n")
|
|
|
+ print(f"Archivo: {archivo_salida}")
|