Get Points, how?

Hello,

i have a script that works fine. i get Location"Points" but only the coordinates how to get a real point! i need this for RayBounce.

# 1️⃣ Get All Doors
doors = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Doors).WhereElementIsNotElementType().ToElements()
filter_tuerOeffnung = [i for i in doors if i.get_Parameter(BuiltInParameter.ELEM_FAMILY_PARAM)
.AsValueString() == "Tuer_Oeffnung"]

print('Es gibt {} Türöffnungen'.format(len(filter_tuerOeffnung)))

# 2️⃣ Get ElementLocationPoints
locationPoints =[i.Location.Point for i in filter_tuerOeffnung]

for p in locationPoints:
    new_point = XYZ(p.X,p.Y,p.Z)
    print(new_point)


grafik

Your new_point variable is already a point object as per Revit API
Can you elaborate on the end goal and the thought process?

@Jean-Marc ,

the issue is when i have no geometry can i even use rayBounce to hit any surface ?

in Dynamo i have ProtoGeometry but what do i have in PyRevit?

KR

Andreas

I think the source of the raybounce does not neeed to be a ‘physical’ point but just a starting point.
Care to share more code?

@Jean-Marc ,

i have only the dynamo code, but ii still not investigate to adaped it.

doc = DocumentManager.Instance.CurrentDBDocument

#Document UI Units

try:
    UIunit = Document.GetUnits(doc).GetFormatOptions(UnitType.UT_Length).DisplayUnits
except:
    UIunit = Document.GetUnits(doc).GetFormatOptions(SpecTypeId.Length).GetUnitTypeId()

if isinstance(IN[0],list):
    points = [XYZ(UnitUtils.ConvertToInternalUnits(i.X,UIunit),UnitUtils.ConvertToInternalUnits(i.Y,UIunit),UnitUtils.ConvertToInternalUnits(i.Z,UIunit)) for i in IN[0]]
else:
    points = [XYZ(UnitUtils.ConvertToInternalUnits(IN[0].X,UIunit),UnitUtils.ConvertToInternalUnits(IN[0].Y,UIunit),UnitUtils.ConvertToInternalUnits(IN[0].Z,UIunit))]

direction = XYZ(IN[1].X,IN[1].Y,IN[1].Z)
view = UnwrapElement(IN[2])

ex = []
pts = []
elems = []

ri = ReferenceIntersector(view)
ri.FindReferencesInRevitLinks = True

for p in points:
    ref = ri.FindNearest(p,direction)
    if ref == None:
        pts.append(None)
        elems.append(None)
    else:
        refel = ref.GetReference()
        linkinstance = doc.GetElement(refel.ElementId)
        try:
            elem = linkinstance.GetLinkDocument().GetElement(refel.LinkedElementId)
            elems.append(elem)
            refp = ref.GetReference().GlobalPoint
            pts.append(Point.ByCoordinates(UnitUtils.ConvertFromInternalUnits(refp.X,UIunit),UnitUtils.ConvertFromInternalUnits(refp.Y,UIunit),UnitUtils.ConvertFromInternalUnits(refp.Z,UIunit)))
        except:
            if not IN[3]:
                elems.append(linkinstance)
                refp = ref.GetReference().GlobalPoint
             pts.append(Point.ByCoordinates(UnitUtils.ConvertFromInternalUnits(refp.X,UIunit),UnitUtils.ConvertFromInternalUnits(refp.Y,UIunit),UnitUtils.ConvertFromInternalUnits(refp.Z,UIunit)))
            else:
                pass

OUT = pts , elems

KR

Andreas

This should work almost as is
top right, click the <> sign
you will see code sample related to this method, everything seems in line with what you have

1 Like

@Jean-Marc ,

i got this

i have to modify it

@Jean-Marc ,

a other idea is bounding box, i have a similar issue

boxes =[]

for e in filter_tuerOeffnung:
    bb = e.get_BoundingBox(None)
    mi = bb.Min()
    ma = bb.Max()
    boxes.append(bb)

print(boxes)

i can not access any value of the box, f.e. delta of min and max point


KR

Andreas

Min and Max are properties, not methods, therefore the error being not callable:

for e in filter_tuerOeffnung:
    bb = e.get_BoundingBox(None)
    mi = bb.Min
    ma = bb.Max
1 Like

BoundingBox Class

1 Like

@Jean-Marc ,

i can follow :white_check_mark:

grafik

@Jean-Marc ,

thats way thank you, for the print statement i will create a new topic


for e in filter_tuerOeffnung:
    bb = e.get_BoundingBox(None)
    mi = bb.Min
    ma = bb.Max
    delta = ma.Z - mi.Z
    unitMetric = UnitUtils.Convert(delta, UnitTypeId.Feet, UnitTypeId.Centimeters)
    print(round(unitMetric,1))

KR

Andreas