4.5 trace open path weirdness

This whole thing started with a crashing path bug in 4.4.1 that I was looking at because 4.5 wasn’t giving me anything for this op. But then Stewart fixed 4.5 well enough to generate results. But then 4.5 has other problems. But the 4.5 problems are with output processing after slicing ok, and reported/acknowledged elsewhere. So this is several steps removed from what I had begun to write, and I’ve been lost a few times along the way. I’ll try to make it make sense anyhow.

This export includes four similar trace ops + one different:

trace-ends.kmz (139.2 KB)

I want a path offset from this edge:

But the slicing result crashes into uncut material at the ends:

Here’s one end of the path I want:

The difference is the first is an “outside” offset and the second is an “inside” offset. The “outside” offset doesn’t work for an inside corner.

Flipping outside to inside was done by adding an extra segment at the other end of the path, which has the seemingly arbitrary effect of changing the inside/outside orientation of the open path:

The extra segment is harmless in this instance, but the option of adding segments until in-/out-sides flip may not be always available.

The inside/outside orientation matters because K:M, as far as I can tell, adds a tool radius to the ends of “outside” open paths and subtracts a radius from the ends of “inside” open paths. I can see that being a practically useful heuristic for paths that end at rightish-angle corners. Some thoughts about that:

  • “outside” paths really don’t need to go any further than the end of the segment. I think.
    • maybe the end of an offset segment is tricky to pin down – I’m thinking of the point where the offset is intersected by the source path’s normal at it’s end i.e. the center of a tool of radius equal to offset when it is tangent to the source path at its end point.
  • “inside” paths ending at acute inside angles of uncut material need to be shortened by more than a radius. I haven’t thought of an easy answer. Maybe that’s just a limitation of the concept.
    • maybe with hypothetical future modeling of uncut material … nope, I still haven’t thought of an easy answer.
  • “inside” paths ending at obtuse inside angles of uncut material may be shortened by less than a radius.
  • So the “inside”/”outside” distinction matters for open paths, but the labels are arbitrary for an open path. I think the Onshape way would be to assign an arbitrary[1] orientation and offer a click-to-flip control
    • for open paths, the distinction matters for treatment of endpoints – but endpoint treatment is not well defined apart from the -radius heuristic
    • “none” not-offset paths still may need to stop short in some cases, like short by a radius if meeting a perpendicular surface
  • Open & closed paths are different animals
  • “inside” end shortening can be needed, or not, on either side of an open path, so in addition to choosing in/out offset (end treatment) also need to choose which sides are in & out
    • maybe separately for each end

So, some ideas:

  • The selection UI could show an explicit distinction between open & closed paths – like change color on detecting path closure – to cue the user to different semantics & behavior, whatever that may be
    • But instead of that, how about:
  • How hard/laggy would it be to show offset paths in the selection UI (e.g. translucent, desaturated, thin, other distinction)? If not too bad:
    • avoid the “inside”/”outside” concept entirely by showing (without word labels) where offsets would fall, and providing a “flip” widget. That seems to be the Onshape way.
    • per-object overrides could get all targets for the intent of an op flipped the intended way in one op, but maybe more sane to say that it might take two ops to get all of multiple objects
  • instead of trying to solve when and how much to shorten the ends of an open path, how about allow selection of edges or surfaces that the tool cutting the trace path can’t break (or ride over if co-planar with path)? Maybe different click-flavor and different selected color in the selection view.
    • the first example being the “other” wall of an inside corner – instead of expecting K:M to always get that right automagically.
    • other features near but not intersecting the trace path could be protected – or not – without expecting K:M to always get that right automagically.

[1]prolly deterministic but not obviously predictable

===========

other unexpected things

  • thing1/2

Either of the two paths above can be flipped to the opposite offset. That’s not useful, but an unexpected result might be worth a look.

In preview, all these offset paths have the extra segment across the top of the part (left in pic) which we’ve already discussed. The offset paths also have the break in the lower-right part of the pic. Because that’s closest to origin, I suppose. I’ve assumed that’s because the extra segment makes a closed loop which has to have a start/end break somewhere, so I’ve assumed that’s basically correct function.

The extra segment that closes the path happens after slicing, so the nominal “inside” and “outside” of the paths closed by the extra segment don’t relate to the inside or outside of the loop. Purely a side-effect of the extra segment bug, I assume.

For the ‘preview’ output loops that are offset inward from the trace path, the start/end gap looks like a radius distance (not shown). I assume that’s normal for output of a loop path. (although I think there’s an argument to be made for returning to the start point or having the option to do so)

For the ‘preview’ output loops that are offset outward from the trace path, like the example above, the gap is much larger. That doesn’t look like normal output. Evidence of something else awry?

  • thing 2/2

The “none” offset result for this path on the top of the part:

appears at the bottom of stock:

yes, this is confusing.

in reverse order, I had the min / max values on a Z clamp function reversed, so that’s fixed now.

open polylines, as you point out, have no inside or outside. maybe left / right, but that’s also dependent on the line start / end. in Kiri, when you select a bunch of line segments for trace, they’re not turned into a completed open or closed polyline until you slice. at that time it attempts to reconnect all open line segments into longer chains. this is not super deterministic from a user standpoint.

the right way to do this is to connect lines at the time of selection and put little arrows on each end of open polylines. clicking the arrow endpoints reverses the line. closed polylines have no direction. then inside/outside becomes left/right which is obvious from the arrows. and it allows you to tailor the path exactly to have or not have collisions as you see fit.

!.

:+1:

…and…

Just for discussion – not really part of sorting 4.5:

…and also on the, um, orientation of the hypothetical observer’s reference frame. In the K:M universe, will it be safe to say that path offsetting will always happen either entirely within the XY plane of a path that’s flat in a horizontal plane, or (for contour) in a surface which … ugh. Trying again: in the K:M universe will it be safe to say that all points along an offset path will be at the same Z elevation as the point on the source path from which they are offset? I’m thinking a) that’s not generally true, but b) maybe it makes sense to declare that constraint when the universe is a Cartesian 3-axis machine with a vertically oriented tool that moves along an axis parallel with it’s own axis (i.e. invariant tool orientation and Z axis parallel with tool axis). Where “indexed” operation is essentially a series of distinct Cartesian orientations, and “lathe” operation is … I don’t know yet how that works.

The question buried in there was: will it be safe to say that all points along an offset path will be at the same Z elevation as the point on the source path from which they are offset?

It seems safe to say that open paths have an intrinsic start and end because they represent the actual progression of a physical object at a finite speed.

Lets say a closed path is a path + a flag which implies a segment connecting end to start. The start and end become meaningless for offsetting because they could be changed to any two consecutive points of the path without changing the path.

I wanted to say closed paths have an intrinsic inside/outside, but I think that’s not true without some constraints. … I’ve spent some time today thinking about what constraints, and made a few false starts at thinking I could write up a simple scheme for simplifying paths to make inside/outside deterministic – or inside/outside/noside easier to determine. I give up. At least for now.

…which circles me back to yesterday’s idea of eliminating the concept of labeling sides by just saying there are two ways to offset[1] and providing a ‘flip’ action – casually assuming live preview of resulting offsets. ([1]which entails defining offset so that’s true… or so it’s easy to determine when it’s not true)

Ah… so not a low hanging fruit.

Oh. Right. I was self-constrained to a concept of edge/path that would be deterministic, without consciously considering the artificiality of that. Out of order: this is part of what got me thinking about stuff said above.

trace segments and boundaries in general are not constrained to planar Z. but offsetting is. when you offset, you flatten any non-planar points to the lowest Z in the polyline. at least, that’s the KM way.

iow, you can select and trace a line that wanders up and down and all around as long as you do not offset it. this is useful for things like following the center-line of a font with a taper mill, chamfers, etc.

side note: there are some interesting internals that support re-contouring of offset polylines that then conform to the shape of the part. it’s computationally expensive, but something that the new gpu code makes feasible. it will be introduced in one of the upcoming releases. as of now, trace does not test part intersection. that is left as an exercise to the human.

it’s a deep, deep rabbit hole, this.