updates
This commit is contained in:
@@ -141,29 +141,31 @@ def groupTrackersToTransformers(transformer_power, max_distance):
|
||||
|
||||
for i, group in enumerate(transformer_groups):
|
||||
# Crear la esfera que representará el CT
|
||||
ct_sphere = FreeCAD.ActiveDocument.addObject("Part::Sphere", f"CT_{i + 1}")
|
||||
ct_sphere.Radius = 5000 # 2m de radio
|
||||
ct_sphere.Placement.Base = FreeCAD.Vector(group['center'][0], group['center'][1], 0)
|
||||
ct_shape = FreeCAD.ActiveDocument.addObject("Part::Box", f"CT_{i + 1}")
|
||||
ct_shape.Length = 6058
|
||||
ct_shape.Width = 2438
|
||||
ct_shape.Height = 2591
|
||||
ct_shape.Placement.Base = FreeCAD.Vector(group['center'][0], group['center'][1], 0)
|
||||
|
||||
# Añadir propiedades personalizadas
|
||||
ct_sphere.addProperty("App::PropertyLinkList", "Trackers", "CT",
|
||||
ct_shape.addProperty("App::PropertyLinkList", "Trackers", "CT",
|
||||
"Lista de trackers asociados a este CT")
|
||||
ct_sphere.addProperty("App::PropertyFloat", "TotalPower", "CT",
|
||||
ct_shape.addProperty("App::PropertyFloat", "TotalPower", "CT",
|
||||
"Potencia total del grupo (W)")
|
||||
ct_sphere.addProperty("App::PropertyFloat", "NominalPower", "CT",
|
||||
ct_shape.addProperty("App::PropertyFloat", "NominalPower", "CT",
|
||||
"Potencia nominal del transformador (W)")
|
||||
ct_sphere.addProperty("App::PropertyFloat", "Utilization", "CT",
|
||||
ct_shape.addProperty("App::PropertyFloat", "Utilization", "CT",
|
||||
"Porcentaje de utilización (Total/Nominal)")
|
||||
|
||||
# Establecer valores de las propiedades
|
||||
ct_sphere.Trackers = group['trackers']
|
||||
ct_sphere.TotalPower = group['total_power'].Value
|
||||
ct_sphere.NominalPower = transformer_power
|
||||
ct_sphere.Utilization = (group['total_power'].Value / transformer_power) * 100
|
||||
ct_shape.Trackers = group['trackers']
|
||||
ct_shape.TotalPower = group['total_power'].Value
|
||||
ct_shape.NominalPower = transformer_power
|
||||
ct_shape.Utilization = (group['total_power'].Value / transformer_power) * 100
|
||||
|
||||
# Configurar visualización
|
||||
# Calcular color basado en utilización (verde < 100%, amarillo < 110%, rojo > 110%)
|
||||
utilization = ct_sphere.Utilization
|
||||
utilization = ct_shape.Utilization
|
||||
if utilization <= 100:
|
||||
color = (0.0, 1.0, 0.0) # Verde
|
||||
elif utilization <= 110:
|
||||
@@ -171,15 +173,15 @@ def groupTrackersToTransformers(transformer_power, max_distance):
|
||||
else:
|
||||
color = (1.0, 0.0, 0.0) # Rojo
|
||||
|
||||
ct_sphere.ViewObject.ShapeColor = color
|
||||
ct_sphere.ViewObject.Transparency = 40 # 40% de transparencia
|
||||
ct_shape.ViewObject.ShapeColor = color
|
||||
ct_shape.ViewObject.Transparency = 40 # 40% de transparencia
|
||||
|
||||
# Añadir etiqueta con información
|
||||
ct_sphere.ViewObject.DisplayMode = "Shaded"
|
||||
ct_sphere.Label = f"CT {i + 1} ({ct_sphere.TotalPower / 1000:.1f}kW/{ct_sphere.NominalPower / 1000:.1f}kW)"
|
||||
ct_shape.ViewObject.DisplayMode = "Shaded"
|
||||
ct_shape.Label = f"CT {i + 1} ({ct_shape.TotalPower / 1000:.1f}kW/{ct_shape.NominalPower / 1000:.1f}kW)"
|
||||
|
||||
# Añadir al grupo principal
|
||||
transformer_group.addObject(ct_sphere)
|
||||
transformer_group.addObject(ct_shape)
|
||||
|
||||
FreeCAD.Console.PrintMessage(f"Se crearon {len(transformer_groups)} centros de transformación\n")
|
||||
onSelectGatePoint()
|
||||
@@ -195,7 +197,7 @@ class InternalPathCreator:
|
||||
self.gate_point = gate_point
|
||||
self.strategy = strategy
|
||||
self.path_width = path_width
|
||||
self.ct_spheres = []
|
||||
self.ct_shapes = []
|
||||
self.ct_positions = []
|
||||
|
||||
def get_transformers(self):
|
||||
@@ -204,13 +206,13 @@ class InternalPathCreator:
|
||||
FreeCAD.Console.PrintError("No se encontró el grupo 'Transformers'\n")
|
||||
return False
|
||||
|
||||
self.ct_spheres = transformers_group.Group
|
||||
if not self.ct_spheres:
|
||||
self.ct_shapes = transformers_group.Group
|
||||
if not self.ct_shapes:
|
||||
FreeCAD.Console.PrintWarning("No hay Centros de Transformación en el grupo\n")
|
||||
return False
|
||||
|
||||
# Obtener las posiciones de los CTs
|
||||
for sphere in self.ct_spheres:
|
||||
for sphere in self.ct_shapes:
|
||||
base = sphere.Placement.Base
|
||||
self.ct_positions.append(FreeCAD.Vector(base.x, base.y, 0))
|
||||
return True
|
||||
@@ -263,6 +265,8 @@ class InternalPathCreator:
|
||||
y_proj = slope * x_proj + intercept
|
||||
return FreeCAD.Vector(x_proj, y_proj, 0)
|
||||
|
||||
# return slope * x + intercept --> desde placement
|
||||
|
||||
projected_points = [project_point(p) for p in all_points]
|
||||
|
||||
# Calcular distancias a lo largo de la línea
|
||||
|
||||
Reference in New Issue
Block a user