I've been experiementing with notebooklm for learning pythonscad. I think the results are amazing:. Here is what I did:
go to notebooklm.google.com
Create a new space/topic
Added the following resources:
openscadhelper5.pdf I would have liked to use the url but that did not work, so I got the helpfile converted it to pdf and uploaded it.
Give an example for a hull with creating 4 cylinders in a for loop
Answer
Here is the PythonSCAD code to create four cylinders in a for loop and then compute their convex hull:
# Import all OpenSCAD functions into the current namespaceExplanation of the Code:
•from openscad import *: This line is crucial for PythonSCAD scripts, as it makes all the OpenSCAD functions (like cube, cylinder, translate, hull, show) available for use in your Python code34.
•cylinders_to_hull = []: We initialize an empty Python list. This list will accumulate each individual cylinder object generated within the loop before they are passed to the hull() function.
•for i in range(4):: This is a standard Python for loop, which will execute the code block four times, with i taking values 0, 1, 2, and 3. PythonSCAD leverages Python's native language features, including its loops2.
•current_cylinder = cylinder(h=10, r=2): Inside the loop, a cylinder is created. The cylinder() function in PythonSCAD allows you to specify its height (h) and radius (r)78.
•translated_cylinder = translate(current_cylinder, [i 10, 0, 0]): The translate() function moves an object by a given vector910. By using i 10, each cylinder is placed at a distinct x-coordinate (0, 10, 20, 30), ensuring they are separated enough for the hull to clearly form around them.
•cylinders_to_hull.append(translated_cylinder): Each uniquely positioned cylinder is added to the cylinders_to_hull list.
•final_hulled_shape = hull(cylinders_to_hull): After the loop finishes, the hull() function is called, taking the list of four cylinder objects. It then calculates the convex hull that encloses all of them15.
•show(final_hulled_shape): Finally, the show() function is used to display the resulting 3D model in the OpenSCAD viewer3....
This script will generate a single 3D model that represents the combined convex hull of the four distinct cylinders, appearing as a smooth, enclosed shape that touches the outermost points of all the cylinders.
Looks interesting.
Currently, the other llm's do not seem able to differentiate between true information and bad. If you only feed an llm accurate info, then the results should be better. (In your example, the explanation has a few typo's, I wonder if they are in the documentation you supplied.)
--
You received this message because you are subscribed to the Google Groups "PythonSCAD" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pythonscad+...@googlegroups.com.
To view this discussion, visit https://groups.google.com/d/msgid/pythonscad/2562e502-1fec-4ceb-952a-005cb460cf97n%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I've tried notebooklm, (thanks for the info, Maththieu) but it is crippled wrt serious development, since it does not remember conversations I can't train it and let others use it, or even me a day later. It has the advantage that you can give it the documents to work with. For my simple test, I had to give it the correct 'translate' syntax, for example, since it used the syntax in https://raw.githubusercontent.com/pythonscad/pythonscad/refs/heads/master/libraries/python/openscad.pyi and it did not understand the meaning of v:list[float]
and I had to remind it that it seemed inebriated in the exuberance of its own verbosity - but nowhere near as bad as the stupid Microsoft AI - Copilot...
I think if it were provided with a selection of good example
scripts, then it would be useful, but then that is the same for
other ai's, and for them you can generally go back to previous
conversations. Still, early days.
Maybe, in a year or two, things will be different, but it depends
which of the many Ai's will be king.
To view this discussion, visit https://groups.google.com/d/msgid/pythonscad/62209768-e275-4b6a-aef2-c0674ed4cac3%40raywest.com.
To view this discussion, visit https://groups.google.com/d/msgid/pythonscad/eddc0ea5-c4f5-491d-8d86-09c564a6845an%40googlegroups.com.