Named args in OpenSCAD builtin functions

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Named args in OpenSCAD builtin functions

RevarBat
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
Reply | Threaded
Open this post in threaded view
|

Re: Named args in OpenSCAD builtin functions

RevarBat
Okay, I got the boolean paths built-ins all working in a couple afternoons of
work.  Most of my time was trying to get OpenSCAD to compile on my OS X
system.  I gave up, created a Linux VM, and set up a build environment
there.  That was far, far easier.

Anyways, I made a PR for it at
https://github.com/openscad/openscad/pull/3288

- Revar




--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org