Hi Everybody.
In regards to the same situation, i have the img nodes script programmed. The goal of this script, is to create elevation views aligned to some selected walls.
However, the final nodo (a pythonscript one), creates the elevation views, on the middle point of the walls, but not aligned to the wall.
Can anybody help me to understand why this is happening? Thanks in advance.
Python script:
import clr
import sys
clr.AddReference(‘RevitAPI’)
clr.AddReference(‘RevitServices’)
clr.AddReference(‘RevitNodes’)
from Autodesk.Revit.DB import *
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from Revit.GeometryConversion import *
Entradas
walls = UnwrapElement(IN[0])
model_lines = UnwrapElement(IN[1]) # Las líneas de modelo asociadas a cada muro
Depuración: Verificar tipo de center_points
print(“Tipo de IN[2]:”, type(IN[2]))
print(“Contenido de IN[2]:”, IN[2])
Asegurarse de que los puntos se convierten correctamente
center_points =
for p in IN[2]:
print(“Tipo de punto:”, type(p))
if hasattr(p, ‘ToXyz’):
center_points.append(p.ToXyz())
else:
center_points.append(XYZ(p.X, p.Y, p.Z))
view_names = IN[3] # Lista de strings
view_type = UnwrapElement(IN[4])
Documento de Revit
doc = DocumentManager.Instance.CurrentDBDocument
Depuración: Imprimir los tipos de entradas y su longitud
print(“walls:”, type(walls), len(walls))
print(“model_lines:”, type(model_lines), len(model_lines))
print(“center_points:”, type(center_points), len(center_points))
print(“view_names:”, type(view_names), len(view_names))
print(“view_type:”, type(view_type))
Función para crear una vista de elevación ortogonal al muro
def create_elevation_view(wall, model_line, center, name, type_id):
try:
location_curve = wall.Location.Curve
mid_point = location_curve.Evaluate(0.5, True)
# Crear un marcador de elevación
elevation_marker = ElevationMarker.CreateElevationMarker(doc, type_id, mid_point, 100)
# Crear la vista de elevación
view = elevation_marker.CreateElevation(doc, doc.ActiveView.Id, 0)
view.Name = name
# Calcular la dirección de la vista a partir de la línea de modelo
start_point = model_line.GeometryCurve.GetEndPoint(0)
end_point = model_line.GeometryCurve.GetEndPoint(1)
direction = (end_point - start_point).Normalize()
# Ajustar la dirección de la vista
transform = Transform.Identity
transform.Origin = center
transform.BasisZ = direction
# Posicionar la vista en el marcador
elevation_marker.Location.Point = transform.Origin
# Activar el recorte de la vista
view.CropBoxActive = True
return view
except Exception as e:
print("Error en create_elevation_view:", e)
return None
Iniciar transacción
TransactionManager.Instance.EnsureInTransaction(doc)
Crear vistas para cada muro
views =
for i, wall in enumerate(walls):
try:
model_line = model_lines[i]
center = center_points[i]
name = view_names[i]
view = create_elevation_view(wall, model_line, center, name, view_type.Id)
if view:
views.append(view)
except Exception as e:
print(“Error en bucle principal:”, e)
Finalizar transacción
TransactionManager.Instance.TransactionTaskDone()
Salida
OUT = views
Elevation Views Creation.dyn (80.4 KB)
Also, i attached the dyn file. It have to work with any file with walls selected. Take into account the IN4 imput of the pythonscript, is a type of elevation that you need to have created on the RVT file for test.
Thanks