Hi everyone,
I just start with point in Revit API and quite confuse of how to find a perpendicular point (H point) from a known point A to line CB (have 2 points C & B that already have XYZ information) :
Thank you so much for your great help.
Best Regards,
Cherry Truong
Solved! Go to Solution.
Hi everyone,
I just start with point in Revit API and quite confuse of how to find a perpendicular point (H point) from a known point A to line CB (have 2 points C & B that already have XYZ information) :
Thank you so much for your great help.
Best Regards,
Cherry Truong
Solved! Go to Solution.
Solved by BenoitE&A. Go to Solution.
Solved by jlpgy. Go to Solution.
Solved by BenoitE&A. Go to Solution.
Hey,
Use:
Line lineBC;
XYZ pointA;
XYZ pointH = lineBC.Project(pointA).XYZPoint;
Bye
Benoit
Hey,
Use:
Line lineBC;
XYZ pointA;
XYZ pointH = lineBC.Project(pointA).XYZPoint;
Bye
Benoit
Thank you so much for your great simple solution .
Thank you so much for your great simple solution .
Hi @Anonymous:
Notice if your are dealing with the following situation:
Your codes should be little bit more complicated then.
// Suppose you have already got these points XYZ pointA, pointB, pointC;
Line unboundLine = Line.CreateBound(pointB, pointC);
unboundLine.MakeUnbound();
XYZ pointH = unboundLine.Project(pointA).XYZPoint;
There is another method: Line.CreateUnbound(XYZ, XYZ), which is easier for creating unbound line. Remember to immediately dispose the Line if you are sensitive with performance.
In my projects, we have wrapped them into several methods:
public static XYZ UnboundProject(this Line line, XYZ point) { using (Line unboundLine = line.GetUnbound()) { IntersectionResult result = unboundLine.Project(point); Debug.Assert(result != null); return result.XYZPoint; } }
public static Line GetUnbound(this Line line) { if (line.IsBound) { Line cloned = line.Clone() as Line; cloned.MakeUnbound(); return cloned; } else { return line.Clone() as Line; } }
Hi @Anonymous:
Notice if your are dealing with the following situation:
Your codes should be little bit more complicated then.
// Suppose you have already got these points XYZ pointA, pointB, pointC;
Line unboundLine = Line.CreateBound(pointB, pointC);
unboundLine.MakeUnbound();
XYZ pointH = unboundLine.Project(pointA).XYZPoint;
There is another method: Line.CreateUnbound(XYZ, XYZ), which is easier for creating unbound line. Remember to immediately dispose the Line if you are sensitive with performance.
In my projects, we have wrapped them into several methods:
public static XYZ UnboundProject(this Line line, XYZ point) { using (Line unboundLine = line.GetUnbound()) { IntersectionResult result = unboundLine.Project(point); Debug.Assert(result != null); return result.XYZPoint; } }
public static Line GetUnbound(this Line line) { if (line.IsBound) { Line cloned = line.Clone() as Line; cloned.MakeUnbound(); return cloned; } else { return line.Clone() as Line; } }
Hi @jlpgy,
Thank you so much for the great solution. I just implemented your suggestion into my code and it worked great.
Million likes
Best Regards,
Cherry Truong
Hi @jlpgy,
Thank you so much for the great solution. I just implemented your suggestion into my code and it worked great.
Million likes
Best Regards,
Cherry Truong
Hi @jlpgy,
Regarding to your last answer of the perpendicular point, I faced another problem as following image:
Suppose I already have 3 point (A, B , C) are know point (with XYZ information). So if I want to create a line CD that has angle to AB with value X (radian or degree), how should I do that?
Thank you so much for your help :).
Best Regards,
Cherry Truong
Hi @jlpgy,
Regarding to your last answer of the perpendicular point, I faced another problem as following image:
Suppose I already have 3 point (A, B , C) are know point (with XYZ information). So if I want to create a line CD that has angle to AB with value X (radian or degree), how should I do that?
Thank you so much for your help :).
Best Regards,
Cherry Truong
Hey,
It looks like you have some Maths for me. All you have to do is find the intersection, right?
Here it goes :
XYZ A, B, C;
double x;
// Determine a vector making angle x to AB
// Get direction of AB (normalized)
XYZ base1 = Line.CreateBound(A, B).Direction;
// Get direction perpendicular to base1 (normalized)
XYZ base2 = -base1.CrossProduct(XYZ.BasisZ);
// Get the direction of your line CD
XYZ directionCD = Math.Cos(x) * base1 + Math.Sin(x) * base2;
This way is similar to changing the coordinates to the base attached to AB and computing the transformation of a point in a rotation of angle x.
You can compute D with :
Line CD = Line.CreateUnbound(C, direction CD);
SetComparisonResult scr = courbe.Intersect(dicoLocMur[i], out IntersectionResultArray ira);
if (scr == SetComparisonResult.Overlap)
{
XYZ D = ira.get_Item(0).XYZPoint;
}
Have fun !
Benoit
Hey,
It looks like you have some Maths for me. All you have to do is find the intersection, right?
Here it goes :
XYZ A, B, C;
double x;
// Determine a vector making angle x to AB
// Get direction of AB (normalized)
XYZ base1 = Line.CreateBound(A, B).Direction;
// Get direction perpendicular to base1 (normalized)
XYZ base2 = -base1.CrossProduct(XYZ.BasisZ);
// Get the direction of your line CD
XYZ directionCD = Math.Cos(x) * base1 + Math.Sin(x) * base2;
This way is similar to changing the coordinates to the base attached to AB and computing the transformation of a point in a rotation of angle x.
You can compute D with :
Line CD = Line.CreateUnbound(C, direction CD);
SetComparisonResult scr = courbe.Intersect(dicoLocMur[i], out IntersectionResultArray ira);
if (scr == SetComparisonResult.Overlap)
{
XYZ D = ira.get_Item(0).XYZPoint;
}
Have fun !
Benoit
Hi @BenoitE&A,
Once again thank you so much for the great suggestion. This remind me of high school math .
Have a great day.
Best Regards,
Cherry Truong
Hi @BenoitE&A,
Once again thank you so much for the great suggestion. This remind me of high school math .
Have a great day.
Best Regards,
Cherry Truong
Can't find what you're looking for? Ask the community or share your knowledge.