BOSL2 icon indicating copy to clipboard operation
BOSL2 copied to clipboard

A way to reset the current transform

Open lijon opened this issue 4 months ago • 33 comments

See https://github.com/openscad/openscad/issues/4975

It was suggested that I add an issue also here.

In short, I'd like to have a way to reset the current transform:

translate(A) {
  reset_transform() translate(B) cube(C); // translated by B only, because A is "undone" by the reset
  cube(D); // translated by A as usual
}

The use case is that in my box enclosure library I'd like to add support for auxillary parts (such as button extenders, battery hatches, etc), that can be viewed in place in an assembly but also laid out and oriented separatedly for 3d printing.

The question is if this is something that could be implemented in BOSL2? One idea would be to have a $no_transform flag that if set, makes all the BOSL2 transform wrappers do nothing. But that wouldn't work, and the above example can't be implemented, since the script is parsed top-down while the transforms are made bottom-up. The no-transform would have to block all transforms further up the tree.

lijon avatar Feb 08 '24 09:02 lijon