nestor001 commited on
Commit
bd69142
路
verified 路
1 Parent(s): 3e80300

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -76
app.py CHANGED
@@ -482,82 +482,6 @@ if 'df' in locals():
482
  #st.write(resultado_dict)
483
 
484
 
485
- ifcfile = None # Definir ifcfile en el 谩mbito global
486
- ifc_path = None # Definir ifc_path en el 谩mbito global
487
- save_path = None # Definir save_path en el 谩mbito global
488
-
489
-
490
- # Funci贸n para cargar el archivo IFC
491
- def cargar_archivo_ifc(ifc_file):
492
- global ifcfile, ifc_path # Usar las variables ifcfile e ifc_path globales
493
- if ifc_file is not None:
494
- with tempfile.NamedTemporaryFile(delete=False, suffix=".ifc") as temp_file:
495
- temp_file.write(ifc_file.read())
496
- ifc_path = temp_file.name
497
- ifcfile = ifcopenshell.open(ifc_path)
498
- return ifcfile
499
-
500
-
501
- # Funci贸n para procesar los archivos cargados
502
- def procesar_archivos(ifcfile, json_data):
503
- if ifcfile is not None and json_data is not None:
504
- owner_history = ifcfile.by_type("IfcProduct")[0]
505
-
506
- for entity_type, entity_info in json_data.get(f"{tipo_modelo}", {}).get(f"{nivel_avance}", {}).items():
507
- for _, data in entity_info.items():
508
- propiedades = data.get("Propiedades", {})
509
-
510
- try:
511
- # Filtrar entidades por tipo
512
- entities = set([entity for entity in ifcfile.by_type(entity_type) if entity.is_a(entity_type)])
513
- for entity in entities:
514
- for pset_name, properties in propiedades.items():
515
- property_set = None
516
- existing_property_sets = entity.IsDefinedBy
517
- for existing_pset in existing_property_sets:
518
- if hasattr(existing_pset, "RelatingPropertyDefinition") and hasattr(existing_pset.RelatingPropertyDefinition, "HasProperties") and hasattr(existing_pset.RelatingPropertyDefinition, "Name"):
519
- if existing_pset.RelatingPropertyDefinition.Name == pset_name:
520
- property_set = existing_pset
521
- break
522
-
523
- if property_set is None:
524
- property_values = []
525
- for property_name in set(properties): # Utiliza un conjunto para obtener propiedades 煤nicas
526
- # Verificar si la propiedad ya existe por su nombre
527
- if not any(p.Name == property_name for p in property_values):
528
- property_values.append(
529
- ifcfile.createIfcPropertySingleValue(property_name, "Value", ifcfile.create_entity("IfcText", "0"), None)
530
- )
531
- #print(f"Propiedades a agregar al conjunto: {property_values}")
532
-
533
- # Crear un nuevo conjunto de propiedades y asignarlo a la entidad
534
- property_set = ifcfile.createIfcPropertySet(entity.GlobalId, owner_history, pset_name, None, property_values)
535
- ifcfile.createIfcRelDefinesByProperties(entity.GlobalId, owner_history, None, None, [entity], property_set)
536
- else:
537
- # Si se encontr贸 un conjunto de propiedades existente, verificar y crear propiedades que falten
538
- existing_properties = set(p.Name for p in property_set.RelatingPropertyDefinition.HasProperties)
539
- missing_properties = set(properties) - existing_properties
540
-
541
- if missing_properties:
542
- missing_property_values = []
543
- for property_name in missing_properties:
544
- if not any(p.Name == property_name for p in property_values):
545
- missing_property_values.append(
546
- ifcfile.createIfcPropertySingleValue(property_name, "Value", ifcfile.create_entity("IfcText", "0"), None)
547
- )
548
-
549
- # Actualizar el conjunto de propiedades existente con las propiedades faltantes
550
- property_set.RelatingPropertyDefinition.HasProperties = list(property_set.RelatingPropertyDefinition.HasProperties) + missing_property_values
551
- #print(f"Propiedades agregadas al conjunto existente: {missing_properties}")
552
-
553
- except Exception as e:
554
- print(f"Error al procesar entidad '{entity_type}': {str(e)}")
555
-
556
-
557
-
558
-
559
-
560
- # Funci贸n para obtener el enlace de descarga
561
  def get_binary_file_downloader_html(bin_file, label='Archivo'):
562
  if bin_file is not None:
563
  with open(bin_file, 'rb') as f:
 
482
  #st.write(resultado_dict)
483
 
484
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
485
  def get_binary_file_downloader_html(bin_file, label='Archivo'):
486
  if bin_file is not None:
487
  with open(bin_file, 'rb') as f: