To be more precise, the question should be “Is Point3D on BRepFace?” :)
There is no direct function to determine that but you can get to the answer by using other functions like the isParameterOnFace function of SurfaceEvaluator.
In order to use that though we need to first get the parameters based on the point. Turns out the function we need to use, getParameterAtPoint, actually works like this: “If the point does not lie on the surface, the parameter of the nearest point on the surface will generally be returned.“
So we have to check for that too.
Here is the Python code we can use:
def isPointOnFace():
app = adsk.core.Application.get()
ui = app.userInterface
selections = app.userInterface.activeSelections
sketchPoint = selections.item(0).entity
face = selections.item(1).entity
evaluator = face.evaluator
point = sketchPoint.worldGeometry
ui.messageBox(
"point, x=" + str(point.x) +
"; y=" + str(point.y) +
"; z=" + str(point.z))
(returnValue, parameter) = evaluator.getParameterAtPoint(point)
ui.messageBox(
"parameter, u=" + str(parameter.x) +
"; v=" + str(parameter.y))
if not returnValue:
# could not get the parameter for it so
# it's probably not on the face
ui.messageBox("Point not on facen(Could not get parameter)")
return
(returnValue, projectedPoint) = evaluator.getPointAtParameter(parameter)
ui.messageBox(
"projectedPoint, x=" + str(projectedPoint.x) +
"; y=" + str(projectedPoint.y) +
"; z=" + str(projectedPoint.z))
if not projectedPoint.isEqualTo(point):
# the point has been projected in order to get
# a parameter so it's not on the face
ui.messageBox(
"Point not on facen(Point was projected in order to get parameter)")
return
returnValue = evaluator.isParameterOnFace(parameter)
if not returnValue:
ui.messageBox("Point not on facen(isParameterOnFace says so)")
return
ui.messageBox("Point on face")
You just have to select a SketchPoint and a BRepFace in the UI before running it:
-Adam


Leave a Reply