News for hackers. Stuff that matters.
Re:Libfive: Solid modeling (CAD) library/tools with Scheme/P... by mkeeter on Monday April 26, 2021 @10:38AM (#26942961)
I'm the main author of libfive, happy to answer any questions.

The site isn't totally up to date – the Python bindings + API are brand new, and need some examples, but they work great if you know how to use them!

Re:Libfive: Solid modeling (CAD) library/tools with Scheme/P... by leokeba on Monday April 26, 2021 @11:23AM (#26943486)
Hello, thanks for your work, this seems very promising and I am very eager to push it a bit to see if it addresses the shortcomings of OpenSCAD, which I am using right now. However, when downloading the MacOS release of the Studio app and running it on my intel MBP, it seems that it cannot open the examples correctly. When opening the files with a text editor, I get the full content, but when opening them with Studio, only the last three lines (set-bounds, set-quality and set-resolution) are loaded into the text editor. I can copy and paste from my text editor and then it works like expected, but it's a bit tedious. Am I missing something or is this a bug ? I can open a ticket on github and provide more information if necessary. :)
Re:Libfive: Solid modeling (CAD) library/tools with Scheme/P... by mkeeter on Monday April 26, 2021 @11:32AM (#26943627)
I appreciate you downloading it and testing it out!

This sounds like a bug, please open a Github issue and I'll investigate.

Re:Libfive: Solid modeling (CAD) library/tools with Scheme/P... by traverseda on Monday April 26, 2021 @10:49AM (#26943078)
Are the python bindings part of core, or are they third party?

Either way I should probably close https://github.com/libfive/libfive/issues/206 ?

Surprised to be hearing about this here instead of via that issue closing :p

Re:Libfive: Solid modeling (CAD) library/tools with Scheme/P... by mkeeter on Monday April 26, 2021 @10:57AM (#26943176)
Surprise! :D

Yes, these are now part of libfive's core – Python is an important-enough language that having canonical, first-party bindings seems important.

There was a bunch of infrastructure work to get to this point: the standard library was ported from Scheme to C++, so the shape bindings are now autogenerated for both target languages and use FFI to call into a dynamic library (with a C API).

Re:Libfive: Solid modeling (CAD) library/tools with Scheme/P... by zyang on Monday April 26, 2021 @01:05PM (#26944984)
I found it's really cool how you can prefix any variable with # and makes it interactivee. How do you map variables to draggable surface in studio?
Re:Libfive: Solid modeling (CAD) library/tools with Scheme/P... by mkeeter on Monday April 26, 2021 @02:01PM (#26945747)
Guile supports custom readers through read-hash-extend [1]: this lets you associate specific syntax with a custom reader, triggered by a '#' character. For example, this is how comments are implemented with #! ...multiline comment... !#: the first "#!" triggers a custom reader which reads until the termination.

libfive installs custom readers for #0, #1, #2, and so on, which all do the same thing: store the syntax position (row/column/span), then create a free variable with a particular id that's associated with that syntax position.

When pushing and pulling on the surface, it's solving for free variables values that put the surface at your mouse cursor's position. Then, it can splice those values back into the original script using the row/column/span data from before.

Python does the same thing with a magic `var(...)` function, which is used as the target for an AST transform here:

https://github.com/libfive/libfive/blob/master/libfive/bind/...

[1] http://www.gnu.org/software/guile/manual/guile.html#Reader-E...