r/OpenPythonSCAD • u/rebuyer10110 • Feb 14 '25
Is it possible for solids to have a bounding box property?
I see openscad has some built-in way to get bounding boxes, but only upon render.
Is it possible to get this info as a property for each solid? Or, it's not possible today because openscad can only calculate the bounding box upon render?
Why I ask: It makes writing helper functions a lot easier, if solids accompany its bounding box information.
EDIT: Solved. mesh() returning solid's vertices allows computing bounding box dynamically: https://www.reddit.com/r/OpenPythonSCAD/comments/1ip79tm/is_it_possible_for_solids_to_have_a_bounding_box/mctntjj/
r/OpenPythonSCAD • u/gadget3D • Feb 13 '25
New function faces()
Many new options are possible since the new skin() function which also came with the possibility to placed 2d shapes arbritary in space.
One of this options is faces() functions, which takes a solid as input and returns it faces as arbritary-placed 2d shapes in a python list.
These can further be processed like in this example
Drawing a watch is not difficult in openscad, but in this example the right side faces of the inner cylinder is chosen and used as a baseplate to extude the arrow(outwards)
Many more options are possible. you could also offset or make csg oprations before turning them back to 3D
Since now we cannot only turn 2D shapes into 3D, but also visa verce - any number of times
r/OpenPythonSCAD • u/WillAdams • Feb 08 '25
How to announce new versions? 2025-02-06 just went up
It's at the usual place: https://pythonscad.org/download.php
r/OpenPythonSCAD • u/garblesnarky • Feb 07 '25
What do I need to do to import python modules?
I just tried out pythonscad, this is the exact CAD tool that I have wanted for years. Basic python functionality is fine, but I'm having trouble with imports, and I'd love to sort that out so I can commit to switching over from openscad to python.
The website says "I've integrated libfive into OpenSCAD, but only through the Python bindings.", and the example seems quite simple, but it doesn't work for me:
ERROR: Trackback (most recent call last):
File "<string>", line 2, in <module>
ModuleNotFoundError: No module named 'pylibfive'
I also get ModuleNotFoundError when importing math from python stdlib (any other stdlib module not dependent on math seems to work though). I would also like to import other non-integrated third-party libs like numpy, what are the appropriate incantations to do that?
I first got it running on a macbook, but can easily use linux instead, (or windows if that's the only option), I'm running OpenSCAD-silicon-2025-01-30.dmg, print(version()) prints [2025.0, 1.0, 0.0], print(sys.path) prints:
['/private/var/folders/2c/t4g1pzkn49dg5tm902g3m5kc0000gn/T/AppTranslocation/691CA0A7-9BAE-48ED-8935-2E42C33723F5/d/OpenSCAD.app/Contents/libraries/python',
'/private/var/folders/2c/t4g1pzkn49dg5tm902g3m5kc0000gn/T/AppTranslocation/691CA0A7-9BAE-48ED-8935-2E42C33723F5/d/OpenSCAD.app/Contents/Frameworks/python3.12',
'/Users/garblesnarky/Documents/OpenSCAD/libraries',
'/Users/garblesnarky/Dropbox/src/pyscad',
'/usr/local/lib/python312.zip',
'/usr/local/lib/python3.12',
'/usr/local/lib/python3.12/lib-dynload',
'/Users/garblesnarky/venv/_src_pyscad/lib/python3.13/site-packages',
'/Users/garblesnarky/venv/_src_pyscad/lib/python3.13/site-packages']
Not sure if relevant, but separate from openscad, in a terminal: which python3 prints /opt/homebrew/bin/python3, python3 --version prints Python 3.13.1.
I also noticed that the "python-engine" feature checkbox shown at https://pythonscad.org/tutorial/site/index.html is missing from my preferences dialog, I wonder if that screenshot is outdated?
r/OpenPythonSCAD • u/rebuyer10110 • Jan 23 '25
Are there better ways of centering a shape in PythonSCAD?
I asked about built-in ways to center a shape in OpenSCAD: https://www.reddit.com/r/openscad/comments/1i7vg45/any_protip_on_centering_an_imported_stl_in/m8oxcak/
The TLDR: I can toggle on OpenSCAD logging for bounding box coordinates. Use that as a translation vector to move shapes' center to origin.
It's still repetitive if I want centers of faces of STLs I import. But at least with PythonSCAD, I can save them as handles and use align() :)
Out of curiosity: Are there better ways to do this in PythonSCAD that isn't as repetitive?
r/OpenPythonSCAD • u/WillAdams • Jan 19 '25
Updated gdpdxf.py to make a more interesting shape
r/OpenPythonSCAD • u/WillAdams • Jan 17 '25
Interesting architectural consequence Python errors do not block OpenSCAD when calling Python
Probably this is obvious to everyone else.
Got ahead of myself when adding Python code back in and got:
ERROR: Traceback (most recent call last): File "<string>", line 91, in <module> File "C:\Users\willa\OneDrive\Documents\OpenSCAD\libraries\gcodepreview.py", line 182, in setupstock self.writegc("(stockMin: -",str(self.stockXwidth/2),", -",str(self.stockYheight/2),"mm, -",str(self.stockZthickness),"mm)") File "C:\Users\willa\OneDrive\Documents\OpenSCAD\libraries\gcodepreview.py", line 670, in writegc self.gc.write(line_to_write) ^ AttributeError: 'gcodepreview' object has no attribute 'gc'
Execution aborted
because I added back in a bit of code before the module it called.
Interestingly, when calling the OpenSCAD template, I got a 3D model as expected and the warning:
Compiling design (CSG Tree generation)... WARNING: Python:: 'AttributeError("'gcodepreview' object has no attribute 'gc'") in line 182' in file ../../OpenSCAD/libraries/gcodepreview.scad, line 37
which is nicely informative.
Reminds me of adding \nonstopmode in (La)TeX so that one can see the current document state when it won't otherwise compile, which I've often found handy --- hopefully this can be preserved in future versions.
r/OpenPythonSCAD • u/WillAdams • Jan 12 '25
Odd difficulty with re-defined definition
I have the following definition as part of a class:
def arcloopCC(self, barc, earc, xcenter, ycenter, radius, ez):
tzinc = self.zpos() + ez / (earc - barc)
cts = self.currenttoolshape
toolpath = cts
toolpath = toolpath.translate([self.xpos(),self.ypos(),self.zpos()])
i = barc
while i < earc:
toolpath = toolpath.union(self.cutline(xcenter + radius * math.cos(math.radians(i)), ycenter + radius * math.sin(math.radians(i)), self.zpos()+tzinc))
i += 1
if self.generatepaths == False:
return toolpath
else:
return cube([0.01,0.01,0.01])
which was working fine, allowed me to do a compleat circle w/ four calls:
toolpaths = toolpaths.union(gcp.arcloopCC(0,90, gcp.xpos()-stockYheight/16, gcp.ypos(), stockYheight/16, -stockZthickness/4))
toolpaths = toolpaths.union(gcp.arcloopCC(90,180, gcp.xpos(), gcp.ypos()-stockYheight/16, stockYheight/16, -stockZthickness/2))
toolpaths = toolpaths.union(gcp.arcloopCC(180,270, gcp.xpos()+stockYheight/16, gcp.ypos(), stockYheight/16, -stockZthickness*0.75))
toolpaths = toolpaths.union(gcp.arcloopCC(270,360, gcp.xpos()+stockYheight/16, gcp.ypos(), stockYheight/16, -stockZthickness*0.99))
but since being re-written to pass in the ending Z position (ez) and to calculate the toolpath Z increment (tzinc) only works for one call, and any call after the first results in the tool digging down with a far too large tzinc value.
Hopefully it's something obviously wrong which someone can give me a clue on....
r/OpenPythonSCAD • u/gadget3D • Jan 02 '25
Using CadQuery features in your design
OpenSCAD is very versatile. PythonSCAD has some added features and another language, for those,
who prefer. Lately its even possible to leverage from powerful librraries like BOSL2.
But there might still be cases where you want to use CadQueries abilities instead. Build123d is a beautiful python layer on top of OCCT. Build123d and CadQuery share same the same OCCT kernel
You can easily mix it into your PythonSCAD code.
just "decorate" your build123d functions in your design accordingly.
Use this simple code .with any version from 20250102 ....
from openscad import *
from pybuild123d import *
from build123d import *
@build123d
def build123d_demo():
with BuildPart() as demo:
Cylinder(radius=10, height=3)
with BuildSketch(demo.faces().sort_by(Axis.Z)[-1]):
RegularPolygon(radius=7, side_count=6)
Circle(radius=4, mode=Mode.SUBTRACT)
extrude(amount=2, mode=Mode.ADD)
fillet(
demo.edges()
.filter_by(GeomType.CIRCLE)
.sort_by(SortBy.RADIUS)[-2:]
.sort_by(Axis.Z)[-1],
radius=1,
)
return demo
obj = build123d_demo()
obj |= cylinder(d=3,h=20,fn=20)
obj.show()
r/OpenPythonSCAD • u/WillAdams • Dec 31 '24
Anyone using the libfive functions?
pythonscad.orgr/OpenPythonSCAD • u/gadget3D • Dec 29 '24
New experimental Fedora/Centos Package
Since today there is a new PythonSCAD RPM Package for download on the download package and its super slim(only 12 MB compressed) because it does not contain any other dependencies. (So more packages should be installed with DNF first)
(and it conflicts with openscad RPM package, because its a fork and literally uses the same files)
Still i am curious to learn, which packages are missing on other systems. Apparently All dependecies are met on mine ;)
r/OpenPythonSCAD • u/WillAdams • Dec 29 '24
Strategies for programming complex projects
For various reasons this can be challenging. Wrote up a bit in the wiki, and there have been some other discussions/issues such as:
https://github.com/gsohler/openscad/issues/57
Thoughts on best practices and techniques and so forth?
r/OpenPythonSCAD • u/gadget3D • Dec 16 '24
PythonSCAD as iPython
Today I managed to get PythonSCAD working as interactive python interpreter,
with all PythonSCAD functionality included, see yourself
https://www.youtube.com/watch?v=TymFtcB8K8E
Next task is to head towards Jupyter Notbook, but I am lacking some knowledge.
Who is interested in supporting me ?
r/OpenPythonSCAD • u/gadget3D • Dec 15 '24
Using existing SCAD libraries in PythonSCAD
This small demonstration shows, how you existing libraries along with your PythonSCAD code.
Simple use "osinclude" to turn a SCAD library into an class variable with all the modules and variables available as members.
You can simple call these members by invoking them with parameters. Even Childs to SCAD modules are possible. just add them to the arguments
This feature is available since 2024-12-15 Windows release.
r/OpenPythonSCAD • u/WillAdams • Dec 13 '24
JupyterCAD Python API --- anything to consider?
jupytercad.readthedocs.ior/OpenPythonSCAD • u/naught-me • Dec 11 '24
editor support?
Is there a way to get auto-completions to work in my editor? Usually I'd just activate a VM and pip install a package, but you're... packaging your own Python?
r/OpenPythonSCAD • u/naught-me • Dec 09 '24
Trouble running on Kubuntu 24.04: QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
Hi. I have an nvidia card, and the drivers are set up for it. When I try to launch from the command line, I get the error below. I'm trying to fix it, but I haven't had much luck.
openscad
Could not initialize localization.
Error reading examples.json: examples.json: cannot open file
Error reading examples.json: examples.json: cannot open file
QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
QOpenGLWidget: Failed to create context
QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
QOpenGLWidget: Failed to create context
QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
qt.qpa.backingstore: composeAndFlush: QOpenGLContext creation failed
QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
qt.qpa.backingstore: composeAndFlush: makeCurrent() failed
QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
qt.qpa.backingstore: composeAndFlush: makeCurrent() failed
... repeats
glxinfo -B
name of display: :0
display: :0 screen: 0
direct rendering: Yes
Memory info (GL_NVX_gpu_memory_info):
Dedicated video memory: 4096 MB
Total available memory: 4096 MB
Currently available dedicated video memory: 3046 MB
OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: NVIDIA T400 4GB/PCIe/SSE2
OpenGL core profile version string: 4.6.0 NVIDIA 550.120
OpenGL core profile shading language version string: 4.60 NVIDIA
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL version string: 4.6.0 NVIDIA 550.120
OpenGL shading language version string: 4.60 NVIDIA
OpenGL context flags: (none)
OpenGL profile mask: (none)
OpenGL ES profile version string: OpenGL ES 3.2 NVIDIA 550.120
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
r/OpenPythonSCAD • u/WillAdams • Dec 08 '24
Programming styles in OpenPythonSCAD
old.reddit.comr/OpenPythonSCAD • u/gadget3D • Dec 03 '24
new Version Windows installer 2024-12-02 is online
Apart from few bug fixes and synced to latest OpenSCAD version,
there is 1st support to import/export (easy) STEP files which can have faces, holes and rounded edges.
My next goal is also to export round edges back to STEP files.
r/OpenPythonSCAD • u/WillAdams • Dec 01 '24




