Calculate distance from point to Face

I want to measure the distance from a point to the Face along the model Z-axis.
The red Face is in a CCW rotated component.

With the distance_to_plane method I get the value from point1 perpendicular to the Face (pink line).

point1 =,0,0)
plane = [,0,0), [-0.8682431421244594, 0.0, -0.4961389383568334]]
distance = point1.distance_to_plane(plane).to_mm
# 664.2060037252114

I prefer not to use raytest because there may be objects in the model that can cause incorrect raytests.

What is the easiest way to measure the distance between point1 and the Face along the model Z-axis?
Is there a way to determine the distance_to_plane direction that the method should measure?

I guess you mean perpendicular to the face, a typo.

And here the local (component’s) Z-axis?

Fixed the typos @Wo3Dan.

I want to measure the distance from a point to the Face along the model Z-axis.
Not the local component’s Z-axis.

Probably this would be to use: Geom::intersect_line_plane()

… where the 1st argument is: line1 = [point1, Z_AXIS] …
and the 2nd plane argument would be the face.plane converted to the same coordinate system as point1 is expressed in (likely in the model’s coordinates.)

I would expect that face.plane would return values in the component’s local coordinates, unless the active_entities are the component instance, (in which case the API will return values in model coordinates.)

Anyway, once you have the intersection point use point1.distance(intersect_point).


From the top of my head: If you know the angle between the blue and the pink one, the blue distance is acos(angle) Ă— pink_length

Or was it pink_length / acos(angle) :thinking:

Anyhow some good old Pythagoras: Pythagorean theorem - Wikipedia