Room and Area Location Point

Hello,
i’m trying to check if an Area element in one revit file is corresponding to a Room element in another revit file linked to the first one.
For that I have to check if the location point of the Area is within some distance (margin) from the Room Location point.
On pyRevit, after collecting both elements, i have never succeed to get or to access the point :

point = area.get_Parameter(BuiltInParameter.ROOM_CALCULATION_POINT)

point is always None. But Name or area parameters are okay
What is wrong?

room_calculation_point is a Family parameter. not a room one, nor an area one

What you are after is the Location of the element



https://apidocs.co/apps/revit/2022/3dbe57e5-fdea-5bf9-c715-52653f56073f.htm#
you can get it jsut by passing the element like so: loc_point = element.Location.Point
also, there is a method in the Query module of pyrevit get_location(element)

1 Like

@Jean-Marc
thank you. I’ve already tried this syntax and don’t want to work.
Suddenly it worked, and don’t won’t again. I’m a little bit disappointed because I changed nothing.
I also tried the get_location(element) and i had the same message again:

here after my partial listing:

# Initialisation pour la Creation des collections 
from Autodesk.Revit.DB import (
    FilteredElementCollector,
    BuiltInCategory,
    BuiltInParameter,
    XYZ,
    Location,
    LocationPoint
)

from pyrevit.revit.db.query import get_location

# Creation instance collecteur et collection des de tous les Areas depuis le model du doc srcAreasDB_Doc

areas_collector = (
    FilteredElementCollector(srcAreasDB_Doc)
    .OfCategory(BuiltInCategory.OST_Areas)
    .WhereElementIsNotElementType()
    .ToElements()
    )

i = 0
objList = []
areasDB_Table = []

# Iteration sur la collection Areas et collecte des Datas

for area in areas_collector:
    if area.LookupParameter('IDP_B20_Category').AsString() == "L":          # Filtrage sur Lease uniquement
        i = i + 1

        objList.append(i)
        obj_Level = area.LookupParameter('IDP_A24_Level-Code').AsString()
        obj_Zone = area.LookupParameter('IDP_B12_Ident-Zone').AsString()
        obj_Num = area.LookupParameter('IDP_B14_Ident-Num').AsString()
        obj_Id = str(obj_Level) + '-' + str(obj_Zone) + str(obj_Num)
        objList.append(obj_Id)
        objList.append(obj_Level)
        objList.append(obj_Zone)
        objList.append(obj_Num)
        objList.append( area.Area * 0.09290304)                 # conversion de ft² to m²

        #point1=XYZ()
        #point1=area.Location
        point1=area.Location.Point
        #point1=get_location(area)
        #point1="tst à terminer" #area.Location.Point**

        objList.append(point1)
        areasDB_Table.append(objList)                           # ajout de la ligne obj_* dans la table
        objList = []                                            # reset de objList pour l'itération suivante

areasDB_TableTri = sorted(areasDB_Table, key=lambda x: x[1])    # Tri du tableau suivant obj_Id (2eme colonne)

print("Phase Une : Traitement AreasDB\n\n")
output = script.get_output()                                    # instance output depuis module pyrevit.script
output.print_table(areasDB_TableTri,                            # impression du tableau formaté
                   columns=[
                       "No   ", "Id    ", "Niv ", "Zone", "Num  ",
                       "Surf ", "Centre  "
                   ],
                   formats=None,
                   title='Tableau des GLA depuis AreasDB - Lease Only',
                   last_line_style='')

Can you please take a look? Thanks in advance

Finally I found the error.
In fact when an Area or Room element are not closed/placed or with zero area the element don’t have a Location.point attribute. In this case the Location type is none and there is no Point attribute.
I resolved the issue by adding a try except to manage this kind of error.

By the way @Jean-Marc, the get_location(element) function and any of the query functions are not documented in the pyrevit.Revit module. Thank to you, I discovered these kind of helpful tools by searching into sources on git site.
It will be more convenient for newbies like me to have an Index pointing to all this stuff. Does it exist somewhere?

1 Like

glad you found your way.
The try except is always a good trick to bypass None returned, but I tend to use the print function to get to see what every step of my scripts return in order to catch the edge cases properly.

as for the documentation of the pyrevit modules… nothing I can do about it… actually not true, you can add documentation to .py module file the same way it is already done in some section and then PR to pyRevit github like so, (right, @eirannejad ? added to PR Pattern legend maker adjustments by jmcouffin · Pull Request #1259 · eirannejad/pyRevit · GitHub)

I also tend to use the ‘go to definition’ tool of vscode to get to know more the content of pyrevit modules.

1 Like

@Jean-Marc I will be glad to help commenting. But I have to understand how GitHub work before. I’m afraid to make some inconsistency in the thing huge good work.
But I can also help translating to French as I’m confortable with.