Lock Inference to a face's normal vector

I want to use the #lock_inference(inputpoint, inputpoint2)
method to lock the cursor perpendicular to a face, similar to the native Push/Pull tool.
image
The lock method works well for axial inferencing but not when the face normal vector is not on a axis.
I would really appreciate some help.

lock_inference is sadly not very clear or well documented. We are working on getting out better code examples for this.

I’m not sure what exact behavior you want.

To lock to a plane, you can pass a single InputPoint being on that plane to lock_inference. Typically this is done when you press down Shift and can be seen e.g. in Line tool. This also covers locking to edges.

Push Pull doesn’t really lock the InputPoint to a plane, but it does project the InputPoint position to a line starting where you clicked the face and following the face’s normal. This isn’t built in to the API as a single method, but can be replicated with a few different method calls. You can do something like this inside your draw method.

# Assuming @face_point is the point where the face was clicked, @face the face
# and @ip the currently used `InputPoint`.

normal_line = [@face_point, face.normal]
projected = @ip.position.project_to_line(normal_line)
preview_line = [projected, @ip.position]

view.line_stipple = "-"
view.draw(GL_LINES, preview_line)
2 Likes

Thank you a lot.

That was exactly what I was looking for!
Your code example will work just fine for me.

That’s good to hear!

It’s fun to see native tools being examined and be used as inspiration for custom tools. Good luck with your development!