How to get intersection between point and line?

How to get intersection between point and line?

Revit_API
Contributor Contributor
1,209 Views
7 Replies
Message 1 of 8

How to get intersection between point and line?

Revit_API
Contributor
Contributor

Hi Guy,

I have a problem about get intersections between point and line. Please see the below screenshot.

Revit_API_0-1643112044839.png

 

How to get XYZ of point C? Please help me and advise.

Thank you very much.

 

0 Likes
Accepted solutions (1)
1,210 Views
7 Replies
Replies (7)
Message 2 of 8

VanQuyet.Doan
Enthusiast
Enthusiast

.

0 Likes
Message 3 of 8

VanQuyet.Doan
Enthusiast
Enthusiast

public static XYZ Intersection(this Autodesk.Revit.DB.Line line1, Autodesk.Revit.DB.Line line2)
{
IntersectionResultArray iResult = new IntersectionResultArray();
SetComparisonResult setComparisonResult = line1.Intersect(line2, out iResult);
if (setComparisonResult != SetComparisonResult.Disjoint)
return iResult.get_Item(0).XYZPoint;
return null;
}

0 Likes
Message 4 of 8

Revit_API
Contributor
Contributor
Thank you for your reply.
But I want to get an intersection of C between AC and BC.

Thank you.
0 Likes
Message 5 of 8

RPTHOMAS108
Mentor
Mentor

It is not clear from that diagram nor the object language you've used what you are aiming for i.e. I could say:

 

The intersection C of line AC with line BC is AC.GetEndPoint(1) but I know that is probably not what you want.

 

Does Point C have any relationship to the picked line or the other point and what is it? You are not drawing a perpendicular projection of the picked point onto the picked line etc.

 

220125a.PNG

0 Likes
Message 6 of 8

Revit_API
Contributor
Contributor

Hi  RPTHOMAS108

Thank you for your reply.

Basically, I have only information XYZ point Pt1, XYZ Pt2, and PickObject Line by the user. AC // DB

I want to get XYZ point C from PickObjec Line of point B extended to AC.

 

Revit_API_0-1643156849926.png

Please advise.

Thank you very much.

 

 

0 Likes
Message 7 of 8

RPTHOMAS108
Mentor
Mentor
Accepted solution

That is a bit clearer but Pt1 & Pt2 are not distinguished on image.

 

If the user picks Point A and you have line BD then:

Create an unbound line with origin at Point 'A' and direction the same as BD. Then clone line picked by user ending at 'B', make it unbound and find the intersection between this and the previously created unbound line parallel to BD. This will result in an intersection at point C.

0 Likes
Message 8 of 8

Revit_API
Contributor
Contributor

Thank you very much.

0 Likes