Incorrect results from ReferenceIntersector?!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I am building an application that needs to determine whether and when a room is not completely sealed off from the atmosphere (I’m intentionally avoiding the term “enclosed”). I decided to use Ray Projection for this purpose. I understand that there may be other, possibly simpler, approaches, but I already use the ray data for other calculations, so this method works for me.
I created a simple model to test how the ReferenceIntersector behaves with a curved wall and noticed that sometimes rays projected from inside the room escape without intersecting any wall.
I have attached the model along with the RevitPythonShell code that reproduces the issue. Any explanation of why this is happening and how it can be fixed would be greatly appreciated.
Revit version: 2024.3
import math
def mm_to_feet (x):
return (x / 304.8)
def unit_vector (theta):
return XYZ(math.cos(theta), math.sin(theta), 0.0)
def sample_directions ():
directions = []
for i in range(16):
theta = ((i * 1.0)/ 8.0) * (math.pi)
directions.append(unit_vector(theta))
return directions
doc = __revit__.ActiveUIDocument.Document
directions = sample_directions()
room = doc.GetElement("209346be-c3c8-4a2a-8f5c-c7cfe343a1ed-0004cb78")
view_3D = doc.GetElement("7b55fbaa-d1a2-4add-aef4-b46e80d4d03b-00017118")
location = room.Location.Point
raised_location = location + XYZ(0.0, 0.0, mm_to_feet(100.0))
reference_intersector = ReferenceIntersector(view_3D)
def find_everything_from_towards (origin, direction):
return reference_intersector.Find(origin, direction)
intersector_results = []
for direction in directions:
intersector_results.append(find_everything_from_towards(raised_location, direction))
empty_results = []
non_empty_results = []
for result in intersector_results:
print(len(result))