Getting XYZ from ceiling location


#1

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?

image

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
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference("System")
from System.Collections.Generic import List

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

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

clr.AddReference("RevitServices")
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
            test.append(ceilingPoint)
            
OUT = test

Thanks in advance!


#2

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

XYZ pt= lp.Point;

#3

This worked for me in dynamo python:

location = element.Location
locationPoint = None

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

#4

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


#5

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


#6

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.


#7

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.

Mark


#8

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

#9

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!


#10

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

Thanks!

PS: you solution is more clean :slight_smile:


#11

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…