How to get guardrail coordinates?

Hello guys!

I’ve created a schedule to get all coordinates of some categories on the project, I created a python routine to get all the coordinates (including curves elements). But it doesn´t work for Guardrail category.

As I’m new here I can´t atch more than one file, so I put everything else on this drive link. Dynamo - Google Drive

@Raphael ,

so you want Location(points) so you need one point at least, but you have also Curve Based Elements…

import clr
import math

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

items = UnwrapElement(IN[0])

def GetCurveMidpoint(curve):
    # Retorna o ponto médio de uma curva
    return curve.Evaluate(0.5, True).ToPoint()

def GetLocation(item):
    # Retorna o ponto ou o ponto médio de uma curva, dependendo do tipo do objeto
    
    if hasattr(item, "Location"):
        loc = item.Location
        
        # Verifica se é uma curva (e.g., parede, linha, etc.)
        if loc and isinstance(loc, LocationCurve):
            curve = loc.Curve
            return GetCurveMidpoint(curve)
        
        # Verifica se é um ponto (e.g., FamilyInstance, PointElement, etc.)
        elif isinstance(loc, LocationPoint):
            return loc.Point.ToPoint()
    
    return None

# Obtém os pontos ou pontos médios para cada item
locations = [GetLocation(x) for x in items]

# Filtra os valores nulos
OUT = [x for x in locations if x is not None]

You might work also with start and endpoint or getting a PointAtParameter.

KR

Andreas

Hi @Draxl_Andreas,

Thanks for the answer. But when I run this schedule for other curves elements, e.g. Wall and Pipes elements, its work perfectly. I’ve tried some ways to the code check if the element is guardrail and return the midpoint, but I didn’t have success.

Here it’s an example of the code work with wall elements.


OBS.: “Paredes” = “Wall”

KR,
Raphael

1 Like

What is in the Python nodes?

Hi @jacob.small ,

The fisrt take the location of the element and the second convert to shared coordinates.

As I’m new here I can´t atch more than one file, so I put everything else on this drive link.
https://drive.google.com/drive/folders/1TZNjPmNfc_wNkUTRD9LUkcEGRJ7Im-kz?usp=sharing