I just spent the afternoon implementing OpenSCAD 2D path/pathlist function builtins for:
- union_paths(pathlist, pathlist, ...) -> pathlist
- union_paths(pathlists) -> pathlist
- difference_paths(pathlist, pathlist, ...) -> pathlist
- difference_paths(pathlists) -> pathlist
- intersect_paths(pathlist, pathlist, ...) -> pathlist
- intersect_paths(pathlists) -> pathlist
- minkowski_paths(pathlist, pathlist, ...) -> pathlist
- minkowski_paths(pathlists) -> pathlist
I have those done, and they are all implemented with ClipperUtils. They all can take a 2D path or a region made up of a list of 2D paths for any of the pathlist arguments. And they will all reject malformed paths/regions. I avoided naming them the same as their geometry equivalents to avoid confusion.
I'm currently working on `offset_paths()`, and I've run into an odd little quirk of functions in OpenSCAD:
Every single function builtin uses positional args instead of named args. Every Single One. This means that in `search()`, the `num_returns_per_match=` must always be the 3rd argument, and `index_col_num=` must always be the 4th.
For `offset_paths()`, I want to be able to specify `r=` *or* `delta=` and `chamfer=`. In builtin modules, it looks like it sets up a `ContextHandle<Context>` to use `lookup_variable()` to get named args, but it is unclear to me if this is allowed in a builtin function. IS that how it would be done?
- Revar
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org