Distance calculation by projection method

milindnalgirkar
Enthusiast
Enthusiast

Distance calculation by projection method

milindnalgirkar
Enthusiast
Enthusiast

Hello,

 

I wanted to find out the distance between the point on a horizontal line and the ceiling( having slope) so i used following code-

IList<Reference> ceilreferences = HostObjectUtils.GetBottomFaces(ceil);
Face lface=null;
  foreach (Reference myRef in ceilreferences)
  {                                    
       lface = ceil.GetGeometryObjectFromReference(myRef) as Face;
  }    

IntersectionResult faceIntersectResult = lface.Project(point);

double distanceFromPointToCeil = faceIntersectResult .Distance;

 

But this code is not giving me exact distance between point and ceiling (having slope). At starting of slope this difference between distance is very less and as you proceed along X direction difference increases.

 

Please find attached image.

 

Please let me know if there is any other method to find this.

 

 

Thanks.

 

 

0 Likes
Reply
1,468 Views
4 Replies
Replies (4)

jeremytammik
Autodesk
Autodesk

So, basically, you are looking for the 

Distance Between Two Points in a Specific Direction

I discussed that here:

 

http://thebuildingcoder.typepad.com/blog/2017/01/distances-switches-kiss-ing-and-a-dino.html#2

 point_dist_along_vector.png

  

 

Here are some more related discussions on projecting points:

 

http://thebuildingcoder.typepad.com/blog/2014/09/planes-projections-and-picking-points.html

 

Cheers,

 

Jeremy

 

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes

milindnalgirkar
Enthusiast
Enthusiast

Hello jeremy,

 

Thanks for the reply.

 

We have horizontal line and slopped ceiling on it. We wanted to find out the distance - Distance between- the point on horizontal line and projected point ( in vertical direction )on slopped ceiling bottom face.

 

You can refer the attached screenshot.

 

Thanks.

0 Likes

jeremytammik
Autodesk
Autodesk

Thank you for the improved explanation.

 

Probably the easiest way to go, especially if you want to avoid using any trigonometry, is to use the ReferenceIntersector class to project a vertical ray upward from A into the ceiling:

 

http://www.revitapidocs.com/2018/36f82b40-1065-2305-e260-18fc618e756f.htm

 

Here is a sample that uses that and points to some further related reading:

 

http://thebuildingcoder.typepad.com/blog/2017/03/rvtfader-avf-ray-tracing-and-signal-attenuation.htm...

  

Personally, I would prefer a trigonometrical approach.

  

That is probably also pretty easy to implement and more efficient to execute.

 

If you provide a minimal reproducible sample with a model containing just one ceiling and a model line or two defining the point A plus code to extract the relevant ceiling face, I will see whether I can suggest anything for you.

 

Thank you!

 

Cheers,

 

Jeremy

 

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes

jeremytammik
Autodesk
Autodesk

Another approach would be to use the Face.Intersect(Curve) method:

 

http://www.revitapidocs.com/2018/9a487e3d-bbb4-34b9-307d-2e4f63fddab6.htm

 

Create a vertical line from A upwards, and intersect that with the ceiling face.

 

Cheers,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes