Getting XYZ from ceiling location

Hi guys,

I’m trying to get the location point of ceilings, but all I have is Autodesk.Revit.DB.Location. Methods or attributes like Point, ToPoint, Toxyz, etc. don’t work. Any idea?


Kevin_Bell had a similar problem like me now, but he didn’t get a solution:

Here is an abstract of my code:

import clr
from Autodesk.DesignScript.Geometry import *

from System.Collections.Generic import List

from Autodesk.Revit.DB import *

import Revit

import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

def roomNumber(room):
    return room.Number
allRooms = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms).WhereElementIsNotElementType().ToElements()
rooms = sorted(allRooms, key = roomNumber)

test = []

for room in rooms:
    levelRoom = room.LevelId
    allCeilings = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Ceilings).WhereElementIsNotElementType().ToElements()
    for ceiling in allCeilings:
        levelCeiling = ceiling.LevelId
        if levelRoom == levelCeiling:
            ceilingPoint = ceiling.Location
OUT = test

Thanks in advance!

at C# its looks like
LocationPoint lp= location as LocationPoint;

XYZ pt= lp.Point;

This worked for me in dynamo python:

location = element.Location
locationPoint = None

if isinstance(location,LocationPoint):
	locationPoint = location.Point
1 Like

Thanks for the responses. It works with other families, but not in the case of ceilings (at least in my file…).

have you tried Collector.ElemenSketch node and get the points in the sketch?

Right, ceilings are actually not family instances.
Did not think about that before, but for some elements you will not get a location point.
Eg. for walls you get curve only. I think you can get outline/sketch as suggested above and calculate cetroid / average point perhaps?
Or maybe even easier get the bounding box of the object and take it’s centre.

1 Like

I confirm your result.

I get an error with your code and i get a null with Miciek’s.

Maybe this is a bug? We can obviously do a work around, but it’s worth reporting if we’re not getting a result we expect. The ceiling has a location, we should be able to get a point out of it.

Hope this is of interest.


1 Like

maybe check if this suits your needs

element = UnwrapElement(IN[0])

bb = element.get_BoundingBox(None)

max = bb.Max
min = bb.Min

centre = min + (max-min)/2

#Assign your output to the OUT variable.
OUT = centre
1 Like

No, I didn’t, becasue I want to do it only with python (like a challenge). In the meantime my solution has been getting the middle point of the BoundingBox. I don’t love it but It’s enough for me.

ceilingPointMax = ceiling.get_BoundingBox(view).Max
ceilingPointMin = ceiling.get_BoundingBox(view).Min
ceilingPointMid1 = ceilingPointMax.Subtract(ceilingPointMin)
ceilingPointMid2 = ceilingPointMid1.Divide(2)
ceilingPoint = ceilingPointMax.Subtract(ceilingPointMid2)

Thanks everybody!

I didn’t see this! Yes, I did the same.


PS: you solution is more clean :slight_smile:

1 Like

So it looks like the ‘location’ of a ceiling is returned as it’s boundary curves… Have a look in the Clockwork Location + node… That’s a bit weird isn’t it?!

It seems to be the same with roofs, so I guess all sketch based elements?! Ok well that’s what it is then…