Does anyone have an example of how the View#lock_inference functions? When I need to constrain a tool to an axis or plane I’ve so far made my own code that projects the position of the input point but maybe that is to reinvent the wheel. The documentation doesn’t provide much help.
If you pass no arguments it removes all inferences.
With one input point it inferences that one point.
With two input points it inferences those two.
Note how it needs inputpoint objects NOT point3d objects
Wouldn’t it be nice if some method accepted a parallel plane, or a perpendicular vector (ie,
Z_AXIS, or some other supplied vector.)
Sketchup::InputPoint#degrees_of_freedom() play nicely with the new inferences rolled out in SU2016 ?
How would you know if a purple parallel inference was active ?
been playing around with this today, using ‘translations’ - i found no way to lock an axis using the arrow keys. perhaps the wheel needed reinventing.
I’ve figured it out! This is probably really basic but since I couldn’t make any sense of the documentation for nthis I didn’t know this until now.
Since the InputPoint not only contains the position but also information about what it has snapped to it can define a line or a plane. Providing an input point that has snapped to a face or edge makes calls to InputPoint#pick pick points on the face’s plane or the edge’s line. It even draws the inference lines with the correct color and line stipple. I’ve always done this myself without knowing it was already in the API.
I also made a small example tool showing how locking the inference works. The script activate’s it tools immidietely when loaded so don’t place it in the plugin folder - only load it manually from thee console.
lock inference example.rb (1.1 KB)
If only the InputPoint constructor allowed adding custom planes or vectors…
If the InpotPoint constructor took the arguments vector, and degrees_of_freedom in addition to a point you could quite easily lock to an axis.
You would only need to create a new custom InputPoint with the relevant axis (typically acquired from model#axes) as it’s vector and degrees_of_freedom set to 1 (to not lock to the perpendicular plane) and the position copied from the previously picked InputPoint.
I think I might write a feature request for this. What’s your thoughts of this @thomthom?
If it is technically feasible (based on how the inference engine is programmed, which I don’t know) I think this would be a useful addition for many extension developers.
I’ve tested in SU2016 and perpendicular inference (from an other InputPoint placed on a Face) sets the degrees_of_freedom to 1 as expected.
However, hovering an edge while finding inference to an endpoint (displayed as a black circle) does not set the degrees_of_freedom to 0 even if you technically snap to a specific point on the edge and not just the edge in general. Instead this value is 1.
(EDIT: Had a brain fart and wrote the wrong numbers here)
(reference mouse cursor added manually since it was captured in the screenshot)
Here’s the small script I’ve used to investigate the inference:
inference inspector.rb (2.3 KB)
Another question is how to get the correct color for the inference line between two InputPoints, e.g. a start point and end point. When using InputPoint#pick with another InputPoint passed as an argument the inference lines between these don’t automatically draw.
If the inference is along an axis you can simple use View#color_from_line but I don’t know how to detect any of the magenta inferences. The only thing I can think of is to check the string from InputPoint#tooltip but that is of course language dependent. Also you would have to define the magenta color yourself since the API so far doesn’t provide a way to get user defined inference colors.