r/OpenPythonSCAD • • Nov 18 '25

Colored render in 2D

5 Upvotes

It took quite some time to mature, but now its there:

PythonSCAD can render in color since today like this:

The Options appear limitless . The colors in an SVG are not determined by export options, but

really from the script. This opens yet more options for people who work wirh laser cutters.

Also it can become way more tasty to combine SVG with rotate_extrude like here:

All that is available since todays 2025-11-18 Version.

What will *you* do next ?


r/OpenPythonSCAD • • Aug 28 '25

Adding customized member functions

5 Upvotes

One of the problems with PythonSCAD so far was, that python does not allow to extend builtin data types.

People which decided to go with PythonSCAD soon wanted to add their own member functions to solids and failed. They put hard efford to subclass openscad to circumvent this restriction.

With latest release this is not needed anymore . Define a custom function and just register it. (see exmple)

This is a simple example but it can be easily extended


r/OpenPythonSCAD • • Jul 30 '25

Single continuous line print (inspirational)

5 Upvotes

r/OpenPythonSCAD • • Jul 14 '25

Objects are now iteratable

5 Upvotes

In latest Commit. Objects are iteratable.

When iterating over an object, you get its childs one by one.

Below shown example does an union, because the difference is never actually executed.


r/OpenPythonSCAD • • Jun 25 '25

wrap function more versatile

5 Upvotes

Always wrapping around a cylinder is quite boring.

Why dont wrap around an arbritary shape ?

'''

from openscad import *

perim=circle(r=5,fn=30)

perim |= square([8,4])+([0,-2])

wall=cube([38.1,0.5,6])

wall -= [ cylinder(r=0.3,h=3,fn=6).rotx(-90)+ [1+2*x+( y & 1),-1,1+1.8*y]

for x in range(19) for y in range(3) ]

wall.wrap(perim).show()

'''

ITs already available in the latest repo. Installers will flollow later

Creating Litopanes becomes super-easy.

Next step is probably bending towards z axis


r/OpenPythonSCAD • • Jun 22 '25

How to generate a transformation matrix quickly

5 Upvotes

I thought I had seen that I could output a series of applied transforms as a compost matrix for use with multmatrix, but I can't find it again in the documentation. I don't particularly need it, but it's bugging me that I so vividly remember having seen it somewhere.

Edit: I think I've got it. object.origin will return the transformation matrix. None of the documentations I could find mentioned this. Align just looks to just use matrixes as its inputs, and performs a composite of two multmatrix moves for the two inputs. Additionally for a given transformation matrix of TRANS, the following code works, TRANS=rotx(TRANS,45) and similar code will work. But TRANS.rotx(45) is not supported.


r/OpenPythonSCAD • • Jun 17 '25

New Symbols True and False in CSG Operators

5 Upvotes

PythonSCAD was missing a symbol for and empty(void) object and a full filled object with unlimited size.

Why not using True and False for that ? It enables new algorithms easily

Interesting fact Even when shape is spinning wildly, result would never be a sphere ....


r/OpenPythonSCAD • • Jun 13 '25

Geometric shapes vs. variables and Union vs. lists

Thumbnail old.reddit.com
5 Upvotes

r/OpenPythonSCAD • • May 26 '25

Google Group for OpenPythonSCAD discussions (not suited to OpenSCAD e-mail list)

Thumbnail groups.google.com
5 Upvotes

r/OpenPythonSCAD • • May 01 '25

Hungry for new features ?

5 Upvotes

PythonSCAD is constantly adding new features.

Right now enhancing 2D world and expanding to 3D

Note that the imported 2D shape is fully colored and just converted to 3D in the end


r/OpenPythonSCAD • • Mar 27 '25

Dragging and moving Objects in PythonSCAD

5 Upvotes

These days PythonSCAD starts to become even more interactive.

Now you can drag edges and move them around with your mouse tip like so:

https://www.youtube.com/watch?v=9xBtzE5hhR4

In your code you have to mark values, which are enabled to be "draggable".

Right now this only works for cube() and rotate(), but many more to follow. my next goal is will be also update the source code after drag has finished.


r/OpenPythonSCAD • • Mar 16 '25

Elaborate on "PythonSCAD will be still available to provide those features, which OpenSCAD will never merge. "

5 Upvotes

I've been following this project and read the update about OpenSCAD merging python support. Great news!

I also saw this comment about features that PythonSCAD provides, which OpenSCAD doesn't and might never do. Where can I find this list? I suppose "fillet" is one of the things that greatly interests me, and I dunno if that's getting integrated into OpenSCAD.


r/OpenPythonSCAD • • Mar 15 '25

This raises PythonSCAD into a new Dimension

5 Upvotes

So far, OpenSCAD was only dealing with 2D and 3D objects and it was always towards 3D objects.

Since Today (2025-03-15) PythonSCAD is improved. You can turn a solid into its faces, turn a face into its edges

and of course you can extrude back edges to faces and faces back to prisms, so you can freely walk between 1D and 3D to create your designs

Here is a small example which briefly demonstrates the new Abilities.

'''

from openscad import *

c=cube(10)

faces = c.faces()

f=min(faces, key = lambda f : f.matrix[0][3]) # lowest x

edges=f.edges()

e=min(edges, key = lambda f : f.matrix[1][3]) # lowest y

c2=e.linear_extrude(height=1).linear_extrude(height=1)

show(c|c2)

# create a cube by extrudeing an edge

cube3=edge(4).linear_extrude(height=4).linear_extrude(height=2)

'''

Of course it would make sense to extrude an edge into an cylinder, too, but I am not yet sure about the details,

happy to receive ideas


r/OpenPythonSCAD • • Feb 07 '25

What do I need to do to import python modules?

5 Upvotes

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 • • Dec 11 '24

Importing SCAD libraries into PythonSCAD

5 Upvotes

osimport is the funnction which does the job

this is acutally BOSL2 creating the Cuboid. Next adding support for named parameters


r/OpenPythonSCAD • • 1d ago

Tutorial: Turn your PythonSCAD design into a class and get a real GUI form for its parameters

4 Upvotes

Most parametric designs end up as a function with a list of arguments, and after a while you can't remember what box(80, 50, 30, 2, True, False) actually means.

PythonSCAD has a small protocol for this. If you turn your design function into a class with three conventional methods, the editor shows a clickable calltip for it. Clicking the calltip opens your own PyQt6 dialog. When you press OK, the call in your script is rewritten with the new values.

We'll build this for a very simple box: length, width, height, wall thickness, and two checkboxes, hollow and notch (a finger notch in the front wall).

You need a Qt6 build of PythonSCAD. It ships PyQt6, so there's nothing extra to install.


Step 1: The design as a class

Normally you'd write def box(...). Instead we put the same code into __new__ of a class:

class box:
    def __new__(cls, length=80, width=50, height=30, wall=2,
                hollow=True, notch=False):
        body = cube([length, width, height])
        if hollow:
            cavity = cube([length - 2*wall, width - 2*wall, height])
            body -= cavity.translate([wall, wall, wall])
            if notch:
                cut = cylinder(r=height/4, h=wall*3, center=True, fn=48)
                body -= cut.rotate([90, 0, 0]).translate([length/2, wall/2, height])
        return body

Because __new__ can return any object, box(...) returns the geometry itself, not a box instance. For your scripts nothing changes: box(length=120).show() works just like a function call.

Step 2: get_calltip()

@staticmethod
def get_calltip():
    return "box(length, width, height, wall, hollow, notch)"

This is the text in the popup that appears when you type box(. Because the class also has on_editor_trigger, the popup is clickable and gets a ▶ marker.

Step 3: on_editor_trigger(pos) builds the dialog

This method runs when you click the calltip. pos marks the call in the editor, and you pass it on unchanged to two helper functions:

  • editor_get_call_args(pos) returns the current argument text

  • editor_replace_call_args(pos, text) replaces it

parse_arguments() from pyscadforms turns the argument text into a dict. That is how the form gets pre-filled with the values already in your code:

known, unknown = parse_arguments(box, editor_get_call_args(pos))

Two tiny helper functions create the fields:

def spin(name, default):
    w = QtWidgets.QDoubleSpinBox()
    w.setRange(0.5, 500)
    w.setValue(known.get(name, default))
    form.addRow(name, w)
    return w

length = spin("length", 80)
...
hollow = check("hollow", True)
notch  = check("notch", False)

Step 4: Things a plain parameter list can't do

Because this is a real Qt dialog, fields can react to each other. A notch only makes sense in a hollow box, and CubePreview (also from pyscadforms) draws a small 3D outline that follows the dimensions as you type:

def update():
    notch.setEnabled(hollow.isChecked())
    preview.set_size(length.value(), width.value(), height.value())

Step 5: Write the result back

if dialog.exec() == QtWidgets.QDialog.DialogCode.Accepted:
    parts = [f"length={length.value():g}", ..., f"notch={notch.isChecked()}"]
    parts += [f"{k}={v!r}" for k, v in unknown.items()]
    editor_replace_call_args(pos, ", ".join(parts))

:g turns 80.0 into 80. unknown holds arguments that aren't in the signature. They are written back instead of being silently dropped.

Step 6: Where the class has to live

The class must be loaded at startup and stay around for the whole session, which means .pythonscadrc or a library it imports. Save the code as boxform.py, for example in ~/pythonscad-lib/, and add this to .pythonscadrc (~/.config/PythonSCAD/ on Linux, ~/Library/Application Support/PythonSCAD on macOS, %LOCALAPPDATA%\PythonSCAD on Windows):

import sys, os
sys.path.insert(0, os.path.expanduser("~/pythonscad-lib"))

from pythonscad import *
from boxform import box

Then restart PythonSCAD, because .pythonscadrc is only read at startup.

Using it

New call: type box(, the calltip appears, click it, fill in the form, press OK. The line becomes

box(length=120, width=60, height=40, wall=2, hollow=True, notch=True).show()

Editing an existing line later: put the cursor anywhere between the parentheses of the box(...) call and press Ctrl+Shift+Space (on macOS Control+Shift+Space). The calltip comes back, and clicking it opens the form pre-filled with the current values.

If no calltip appears at all, check that autocompletion is switched on in the editor preferences. Calltips are tied to it.

Pitfalls

  • Don't define the class only in your script. That works only some of the time, depending on render order. Use .pythonscadrc.

  • Shadowing a built-in (e.g. your own cube class): save the original first (_native_cube = cube) and call _native_cube inside __new__, or it recurses into itself.

  • Qt5 builds have no PyQt. There you get the normal calltip, and box(...) still works as a plain function.

Full listing: boxform.py

"""boxform.py - a parametric box with an interactive PyQt6 form."""
from PyQt6 import QtWidgets, sip
from pythonscad import *
from pyscadforms import parse_arguments, CubePreview


class box:
    @staticmethod
    def get_calltip():
        return "box(length, width, height, wall, hollow, notch)"

    def __new__(cls, length=80, width=50, height=30, wall=2,
                hollow=True, notch=False):
        body = cube([length, width, height])
        if hollow:
            cavity = cube([length - 2*wall, width - 2*wall, height])
            body -= cavity.translate([wall, wall, wall])
            if notch:
                cut = cylinder(r=height/4, h=wall*3, center=True, fn=48)
                body -= cut.rotate([90, 0, 0]).translate([length/2, wall/2, height])
        return body

    @staticmethod
    def on_editor_trigger(pos):
        mw = sip.wrapinstance(mainwindow_ptr(), QtWidgets.QMainWindow)
        known, unknown = parse_arguments(box, editor_get_call_args(pos))

        dialog = QtWidgets.QDialog(mw)
        dialog.setWindowTitle("box")
        layout = QtWidgets.QHBoxLayout(dialog)
        form = QtWidgets.QFormLayout()
        layout.addLayout(form)
        preview = CubePreview(dialog)
        layout.addWidget(preview)

        def spin(name, default):
            w = QtWidgets.QDoubleSpinBox()
            w.setRange(0.5, 500)
            w.setValue(known.get(name, default))
            form.addRow(name, w)
            return w

        def check(name, default):
            w = QtWidgets.QCheckBox()
            w.setChecked(known.get(name, default))
            form.addRow(name, w)
            return w

        length = spin("length", 80)
        width = spin("width", 50)
        height = spin("height", 30)
        wall = spin("wall", 2)
        hollow = check("hollow", True)
        notch = check("notch", False)

        def update():
            notch.setEnabled(hollow.isChecked())   # a notch needs a hollow box
            preview.set_size(length.value(), width.value(), height.value())

        for w in (length, width, height):
            w.valueChanged.connect(update)
        hollow.toggled.connect(update)
        update()

        buttons = QtWidgets.QDialogButtonBox(
            QtWidgets.QDialogButtonBox.StandardButton.Ok
            | QtWidgets.QDialogButtonBox.StandardButton.Cancel
        )
        buttons.accepted.connect(dialog.accept)
        buttons.rejected.connect(dialog.reject)
        form.addRow(buttons)

        if dialog.exec() == QtWidgets.QDialog.DialogCode.Accepted:
            parts = [f"length={length.value():g}", f"width={width.value():g}",
                     f"height={height.value():g}", f"wall={wall.value():g}",
                     f"hollow={hollow.isChecked()}", f"notch={notch.isChecked()}"]
            parts += [f"{k}={v!r}" for k, v in unknown.items()]
            editor_replace_call_args(pos, ", ".join(parts))

Going further

The same pattern works for any design: a gear with module and tooth count, a hinge, or a polygon with a drawing canvas. That last one ships with PythonSCAD in pyscadforms.py and is a great place to look for more ideas. Docs: pythonscad.org → Development → "Extend Your Design with an Interactive Form".

See a demo at: https://www.youtube.com/watch?v=t5pk9XBUL_I

I'd love to see the forms you build. Post screenshots!


r/OpenPythonSCAD • • Mar 31 '26

New Release v0.19.1

4 Upvotes

Hi everyone,

Quite some time has passed , many things happened and time is ready to publish a new release v0.19.1.

New nice GUI icons for Export to File

The Formats STEP, Postscript and GCODE did not have any symbols and appeared

as boring text. This is fixed now. William Adams has volunteered to create nice symbols

and made PythonSCAD use them

Formats:

CDR: Yes, there is a new format: PythonSCAD can read CorelDraw (.cdr) now. CDR is closed source, so it's not public but there is libcdr which can do the task and it works

pretty good. Everything which you could do to SVG before, also applies to CDR

SVG: There is better support for reading in SVG Files. Style and Class attribute are parsed and evaluated

Better GCODE Quality

Already in the last Release PythonSCAD was able to create GCODE. Especially in my

Laser cutter, I experience, that cut quality becomes weaker in the right front corner,

probably because it's more distant to the laser tube and the focus becomes more blur ?

However, the solution is to reduce speed and this can be automated with the feedAddX and feedAddY property. When both are configured with -1, the feed rate reduces with the

manhattan distance to the origin.

Other improvements are better arrangements of the cuts within the file. engrave goes before the cut and cuts are from inner to outer, outer cuts are arranged according to the "travelling salesman problem" to minimize traveling between the cuts.

Improved 2D CSG engine

For some special 2D shapes with lots of holes, PythonSCAD got it wrong or added

way too many edges between 2D Union results. This  especially bad, if the edges 

are sent to a laser cutter. Anyway, its fixed

New Primitive polyline

PythonSCAD got a new primitive 'polyline'  which is basically concatenated lines and can have color. They are not only "nice to have" but are actually very meaningful. There are many situations in lasercut where you just want stripes instead of closed polygons. Polylines come in 2 variants:

2D : Very useful to create laser cut temples. Their color can encode  laser power.

3D: Can be used to visualize the toolpath of a 3D printer or any other 3D machine.(William, that's for you!)

Many small fixes in the GUI:

These are mainly small fixes during usage which might be disturbing, internal refactoring, trust handling,  fix crashes, making things smooth. Thanks nomike!

Backward compatibility

As always, we strive to stay in sync with the latest versions of OpenSCAD. All new features and bugfixes of OpenSCAD are included here in addition

Documentation:

All details about new polyline, machineconfig can be found within the tutorial

Downloads

Pre-built packages are available for Linux (AppImage, .deb, .rpm), macOS (DMG), and Windows (installer and zip):

https://pythonscad.org/downloads/

As always, we'd love to hear from you — feedback and bug reports are welcome!

PS: here's a small application of polyline to make a plywood bend test(and it bends greatly)


r/OpenPythonSCAD • • Mar 24 '26

Creating Gears in PythonSCAD

4 Upvotes

PythonSCAD cannot yet create gears, so I coded some functions together with AI.

The Result is a small code snippet which can be used to create 2D gears with quite some parameters(Modus, Teeth, Spokes, HoleDiameter)

You could immeately make use of them by exporting that to GCode and send to your laser cutter. Alternatively, linear_extrude them and use in your 3D design

BTW Code is here: https://bpa.st/OHEA


r/OpenPythonSCAD • • Feb 10 '26

Triangular Shelf for Laser cutting

4 Upvotes

Today I plan to create something for my daughter , a wooden shelf where she

can put her collected stones and dinosaurs.

This is made from interlocking plywood sheets in 3 different directions.

The opening gap is enlarged by Tan(60) to support the acute angle where the single pieces

cross. Look forward to realizing that in real life.


r/OpenPythonSCAD • • Jan 22 '26

OpenPythonSCAD vs. PythonSCAD

4 Upvotes

Is OpenPythonSCAD a legacy name? The repository https://github.com/pythonscad uses PythonSCAD name.


r/OpenPythonSCAD • • Jan 03 '26

path_extrude issue

4 Upvotes

Did path_extrude stop accepting a rounding parameter?

This:

from openscad import *
p = path_extrude(square(1), [[0, 0, 0], [0, 0, 10, 3], [10, 0, 10, 3], [10, 10, 10]])

Does no longer produce this:

Ubuntu 25.10, PythonSCAD v. 0.8.1 (appimage).


r/OpenPythonSCAD • • Jan 01 '26

New: Automated release builds and semantic versioning

4 Upvotes

Happy new year to y'all!

I've started contributing to PythonSCAD a couple of months ago when I was trying to package it for GNU Guix.

In the past few months I was focusing on the build system and recently was able to finalize a few major things:

In order to simplify releases, we've abandoned the date based version numbers we inherited from OpenSCAD and switched to semantic versioning. We also introduced Release Please, to help with change-log- and release-management.

PythonSCAD now also has fully automated release builds for Linux (AppImage), Windows (MXE cross compiled) and macOS (universal binaries).

For now, new releases can be found on the GitHub Releases page, but I'm working on publishing them to < https://pythonscad.org> as well soon.

And if any of you spot any issues or crashes, please create an issue on GitHub. It helps us tremendously.

So, what's your opinion on all of this?


r/OpenPythonSCAD • • Nov 16 '25

Having some fun with this software!

Post image
4 Upvotes

Learned about OpenSCAD recently for a 3D print project - AI helped me design a part that I'm currently printing, and while that goes, I'm having fun with SCAD coding.

The OpenRouter model Sherlock Think is performing well in writing OpenSCAD. Also, Gemini 2.5 Pro and Claude.


r/OpenPythonSCAD • • Oct 17 '25

New Version 2025-10-17 available

4 Upvotes

Finally after almost one month there is a new windows installer available.

Improvements since last time are

* the ability to specify command line options with -D

* rotate got a "ref" paramter to change the center of rotation (rotate can also performed by % operator now)

* improve acceptance of STEP export

* improved bbox function (Thank you NoMike)

* internal cleanup/fixes .

But as usual., also the innovations from OpenSCAD like improved measurement are inherited.


r/OpenPythonSCAD • • Sep 12 '25

Do we have a full list of operators and their functionalities?

4 Upvotes

I'm aware of these and what they do:

| union

- difference

& intersection

* scale

+ translate

Just today though I learned that ^ has some sort of loop functionality for placing grids. I learned this halfway through my process of assigning it to hull. What other's are in use, I'm currently got @ assigned to rotation so no idea if that overriding anything, and I'd been think on how best to use the other operators but if they're already in use I'd like to know about that before I start giving them vital roles in my code.