Skip to content

Instantly share code, notes, and snippets.

@chuongmep
Created October 7, 2020 16:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chuongmep/83b5a8fcb250e571b69254abc35d9ec9 to your computer and use it in GitHub Desktop.
Save chuongmep/83b5a8fcb250e571b69254abc35d9ec9 to your computer and use it in GitHub Desktop.
public static XYZ Intersection(this Autodesk.Revit.DB.Plane plane, Autodesk.Revit.DB.Line line)
{
UV uv1, uv2;
plane.Project(line.Origin, out uv1, out double d);
plane.Project(line.Origin + line.Direction, out uv2, out double b);
XYZ xyz1 = plane.Origin + (uv1.U * plane.XVec) + (uv1.V * plane.YVec);
XYZ xyz2 = plane.Origin + (uv2.U * plane.XVec) + (uv2.V * plane.YVec);
Line projectedLine = Line.CreateUnbound(xyz1, xyz2 - xyz1);
IntersectionResultArray iResult = new IntersectionResultArray();
SetComparisonResult setComparisonResult = line.Intersect(projectedLine, out iResult);
if (setComparisonResult != SetComparisonResult.Disjoint)
return iResult.get_Item(0).XYZPoint;
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment