Snapping feature


#1

Hi, Everyone. I’m new to making Tools, and I need some help with realisation of feature, that using practically in any tool of SketchUp.
When you trying to create or place something in model, that snaps to any surface like below.

How can I make a feature like that?


#2

Use the InputPoint class for this.


#3

In the Tool’s onMouseMove method http://ruby.sketchup.com/Sketchup/Tool.html#onMouseMove-instance_method check for the best picked face for each input-point it generates: http://ruby.sketchup.com/Sketchup/PickHelper.html#do_pick-instance_method and http://ruby.sketchup.com/Sketchup/PickHelper.html#picked_face-instance_method
Get its normal face.normal.
Use that to transform your object [view drawn-graphics?] at the cursor to be on the faces plane.
http://ruby.sketchup.com/Sketchup/View.html
The color of the object can be changed using the normal.parallel? X_/Y_/Z_Axis and coloring it Red/Green/Blue accordingly.
Or Black if not axial…


#4

I really wouldn’t recommend that since the user may have changed the axis colors. View#set_color_from_line should be used instead.


#5

This topic was automatically closed after 91 days. New replies are no longer allowed.