r/OpenPythonSCAD • • Mar 05 '26

Defining world view camera parameters.

3 Upvotes

After I create a bunch of objects, is it possible to to define camera location, orientation and field of view in order to see these objects through this camera, i.e. capture an image of rendered scene as seen by that camera?

I found that it can be done using Viewport-Control in PythonSCAD IDE. Can it be done programmatically? Can FOV have different horizontal and vertical values?


r/OpenPythonSCAD • • Mar 04 '26

How to make a pyramid with linear_extrude?

3 Upvotes

Google tells me that this should work:

pyr = linear_extrude(square(10, center=True), height=10, scale=0) 
show(pyr)

but it produces a cube? What is the solution?

BTW, I can't find the documentation of linear_extrude parameters. Is there a better documentation source than https://old.reddit.com/r/openpythonscad/wiki/index ?


r/OpenPythonSCAD • • Feb 26 '26

Added DXF layer support to Gcodepreview

3 Upvotes

Yeah, I should use ezdxf or something... anyway, it's in, and it works, and it's colour-coded.

https://github.com/WillAdams/gcodepreview

for the curious.


r/OpenPythonSCAD • • Jan 31 '26

More Lasercut progress

3 Upvotes

In the meantime I was working on my lasercutter library. Now it does not only support edge2edge joints but also edge2face and face2face joints.

A new Class constructor can accept a whole solid and creates a mesh from it like this:

The code is as simpe as:

'''

from openscad import *

from pylaser import *

obj=sphere(r=30)

lc = LaserCutter(obj,rows=4,cols=4)

lc.preview()

#c.finalize().show()

'''

But of course you are not limited by spheres, but could add a custom STL instead.

The Library can create the correct lasercutting shapes and finally it becomes real life:


r/OpenPythonSCAD • • Dec 19 '25

How to use functions from OpenSCAD files?

3 Upvotes

Simple and short question:

How do I do this?

// func.scad
function foo() = 10;

# test.py
func = osuse("func.scad")
cube(func.foo())

Looks straight forward, but I'm getting this error:

AttributeError: 'openscad.PyOpenSCAD' object has no attribute 'foo'

Does anyone have an idea?Simple and short question:How do I do this?// func.scad
function foo() = 10;

# test.py
func = osuse("func.scad")
cube(func.foo())Looks straight forward, but I'm getting this error:AttributeError: 'openscad.PyOpenSCAD' object has no attribute 'foo'Does anyone have an idea?


r/OpenPythonSCAD • • Dec 14 '25

Understanding where modules are loaded from and how to update

3 Upvotes

I am trying to load fullcontrolgcode: https://github.com/FullControlXYZ/fullcontrol

and found it necessary to manually load it into:

C:\Users\willa\OneDrive\Documents\OpenSCAD\libraries

along w/ pydantic and pydantic_core, which were successful.

Trying to load typing_extensions.py so as to avoid the error:

ImportError: cannot import name 'Sentinel' from 'typing_extensions' (unknown location)

which is being loaded from:

File "C:\Users\willa\OneDrive\Documents\OpenSCAD\libraries\pydantic_core_init_.py", line 6, in <module> from typing_extensions import Sentinel

but despite replacing every copy of typing_extensions.py, it hasn't worked. There are two associated files:

  • test_typing_extensions.py

  • _typed_dict_test_helper.py

do they also need to be replaced?

There is an "extensions.pyc" file in C:\Program Files\PythonSCAD\python312.zip --- does it need to be replaced?


r/OpenPythonSCAD • • Nov 29 '25

Initial 3D workflow (by way of gcodepreview)

Thumbnail
imgur.com
3 Upvotes

r/OpenPythonSCAD • • Nov 29 '25

Improved 2D Workflow

3 Upvotes

One important missing key feature is in place now and it works great:

Align is now also supported r 2D Objects:

Why not starting with a soccer ball ?

And PythonSCAD's access to the points enables easy conversion to PostScript of Gcode for your laser cutter.

Juist today I have uploaded an updated windows Version.

Enjoy!


r/OpenPythonSCAD • • Nov 05 '25

Auto unwind transformation scopes (using "with" statements in Python)

3 Upvotes

I’m excited to share something I’ve been building!

TL;DR: By combining monads, Python context managers (with statements), and incremental transform matrices, I can now auto-unwind transforms (translate/rotate/scale) within a scoped block. This eliminates the manual, error-prone process of restoring positions in CSG-style modeling.

Problem: In OpenSCAD/PythonSCAD, many operations (like rotate_extrude()) are origin-centric. When working with solids away from the origin, I’d manually translate, operate, then “undo” transforms. This has been a tedious and brittle process.

Solution: Using a monadic abstraction with Python’s context manager, I record each transform matrix on a stack. When the with block exits, transforms automatically unwind. The system tracks incremental matrices per operation and even allows manual overrides when needed.

Challenges: Calculating correct incremental matrices wasn’t always straightforward. Some operations (like unions) don’t yield predictable transforms. I added an “escape hatch” for manual overrides.

Demo:


r/OpenPythonSCAD • • Oct 25 '25

Are older versions accessible?

3 Upvotes

I ran into a bug that crashes on newer versions. I want to install an older version to see which version the crash started.

Is there a place to view and download older versions?


r/OpenPythonSCAD • • Sep 22 '25

noob has a some questions and a correction

3 Upvotes

I just started working with openpythnscad. I feel like a dinosaur, haven't done cad in too many years. I got what I wanted and wrote an stl file with the results. The reason for this is that there are on the order of 700 holes per plywood sheet to be drilled, and I am not the person to do that well, jig or not.

Things that confused/annoyed me. I assume all are pilot errors of some fashion. guidance would be greatly appreciated.

  • On the screen doing preview, the display is tiny and the console is large. I couldn't find any way to flip that.

  • I am used to IDE's where the update to a file is automatic when I edit. It took me a while to figure out I needed to save explicitly and ended up with vim rather that the display editor. It was so small (150 lines) that I didn't bother with pycharm.

  • I couldn't find a clean way to get top view rotated so y was the long axis or easily translate the view.

In the wiki, the rot(x,y,z) have the args as list of floats rather than single float. I used single float and it worked as expected.

Now comes the real question. I need to take this and turn it into gcode with feed speeds, etc. This is for a CNC router. What do people use for a simple cam tool that can deal with looking at the holes and slots that got removed and turning those into reasonable gcode.

thanks in advance,

jerry


r/OpenPythonSCAD • • Sep 07 '25

How am I suppose to import python file relative

3 Upvotes

I've been trying to set up a new project, it has a utilities file named "ALib" at the first level, and then all the other files will be going into folders at least one level lower. The SCAD equivalent is include <../ALib.scad>, but I'm having trouble figuring out the python equivalent. I thought it should be from ..ALib import *, but I'm getting an ImportError: attempted relative import with no known parent package error. I've tried from ALib import *, but this is importing the file from a whole different repo.

I'm working on a Windows system with version 2025.08.28 and 2025.07.23 running

Edit: ALib is a file not folder

Edit: Figured out a solution, I put it in the comments.


r/OpenPythonSCAD • • Jul 31 '25

How are masks applied to fillets?

3 Upvotes

I'm an openscad user who's using pythonscad more now. I switched to the precompiled Windows-binary 2025.07.23. I'm trying to understand how masks are applied to fillets.

I found this example:

    c=cube(1.5);
    
    
    mask=cube([30,1,1],center=True).color([0,0,50,0.1])
    
    
    demo = [
        #c.fillet(0.1), # really round, but just with masked edges(which are front)
        c.fillet(0.1,mask,fn=20), # really round, but just with masked edges(which are front)
    ]
    show([demo[0], mask])

Without the mask it seems to work the way I think it should. However the version (uncommented) with the mask seems to have an entirely different radius.

If someone could explain how the mask is applied to the fillet and if the above example is the expected behavior that would be great. Currently it seems like the edges/faces need to be within the masked volume?


r/OpenPythonSCAD • • Jul 22 '25

Using textures to create a flower

3 Upvotes

This small sketch uses quite some new features of PythonSCAD.

A new paramter to polyhedron is colors where you can speciffy individual colors for each face. Result is a single tile only and its not manifold, but who hinders us to place these tiles in a matrix using python list comprehension. The "concat" function happily combines them to one polyhedon only and wrap can wrap them around a virtual circle. The result mainly describing the perimeter of the flower is not watertight at all, but who cares. The module "repair" makes a perfectly watertright solid from it using gray color.

(the gap is intentionally big, but of course you can make it way smaller and unnoticable)

We are not dependent on watertight solids anymore!

Top orange cone and the trunk ist just decoration. Source code is here: https://bpa.st/LTTQ with a total of 11 lines.

But all these new features makes it super easy to make own textures. I envision a walls of a house made from brick ...


r/OpenPythonSCAD • • Jul 12 '25

Updated to Python 3.12

3 Upvotes

The new Windows version is updated to this, but to get it to load libraries the *._pth files must be deleted from the installation directory if present (see discussion on the Google Group).


r/OpenPythonSCAD • • May 22 '25

Sphere Art

3 Upvotes

You can create nice art from spheres when you dont keep its radius constant,

Instead you can make it dependent from the direction vector. Here is one example

"""
from openscad import *

from math import *

def r_func(vec):

radial = sqrt(vec[0]*vec[0]+vec[1]*vec[1])

axial = abs(vec[2])

hang=atan2(vec[1], vec[0])

vang=atan2(vec[2], radial)

r = 20 /max(radial, axial)

c=abs(hang-2*vang)

if c < 0.3:

r=r -1*cos(c*1.57/0.3)

return r

sphere(r_func,fn=40).show()

"""


r/OpenPythonSCAD • • May 05 '25

Keep your workplace tidy with PythonSCAD

3 Upvotes

Look at my latest design at:

https://www.thingiverse.com/thing:7029416/files

Its basically just a Metal rod where you can easily stack and access all your tools in with Ease.


r/OpenPythonSCAD • • Apr 15 '25

Using OpenPythonSCAD to cut dovetails

Post image
3 Upvotes

r/OpenPythonSCAD • • Apr 12 '25

Significance of Edit | Preferences | Python | Network Import List?

3 Upvotes

Is it now necessary to list files there so as to indicate that they are allowed to be imported?

Apparently:

nimport("https://raw.githubusercontent.com/WillAdams/gcodepreview/refs/heads/main/gcodepreview.py")

doesn't work anymore:

ERROR: Traceback (most recent call last): File "<string>", line 1, in <module> ModuleNotFoundError: No module named 'gcodepreview'


r/OpenPythonSCAD • • Apr 04 '25

Did loading libraries change in the new version? (2025-04-02)

3 Upvotes

I think this happened in 2025-03-31 as well...

Trying to load:

from openscad import *

from gcodepreview import *

gc_file = "vcarvetest.nc"

gcp = gcodepreview(True, False, False)

gcp.previewgcodefile(gc_file)

and am getting:

Running Python 3.11.5 in venv ''. ERROR: Traceback (most recent call last): File "<string>", line 3, in <module> ModuleNotFoundError: No module named 'gcodepreview'

Execution aborted

where File | Show Library Folder opens: C:\Users\willa\OneDrive\Documents\OpenSCAD\libraries

which contains:

"C:\Users\willa\OneDrive\Documents\OpenSCAD\libraries\gcodepreview.py" and "C:\Users\willa\OneDrive\Documents\OpenSCAD\libraries\gcodepreview.scad"


r/OpenPythonSCAD • • Apr 01 '25

Thoughts on updating the wiki (or some other document?) to include missing(all) commands?

Thumbnail old.reddit.com
3 Upvotes

r/OpenPythonSCAD • • Mar 23 '25

Using OpenPythonSCAD to created Helixes

3 Upvotes

Using v paramter(vertical displacement) makes its easy to create a Helix.

(yes its an undocumented feature even though it already exists for a year now)

Alternatively you can also linear_extrude/rotate_extrude a python function which returns the x-section as a polygon like this:

def profile(i)

return [[0,0],[10,0],[10,10+3*i],[0,10-3*i]

]


r/OpenPythonSCAD • • Feb 23 '25

cmake texts mangled

3 Upvotes

Today (2/23/2025) I attempted to compile the latest sources from github and found that a couple of files are somewhat mangled: CmakeLists.txt (lines 484, 621 and others) and cmake/Modules/FindNettle.cmake (lines 1-26) have kept rests of what looks like a markup.


r/OpenPythonSCAD • • Feb 18 '25

Status of import os?

3 Upvotes

Was this brought up before? I couldn't find that a note had been made on the wiki...

Obviously:

import os

# Get the current filename
current_filename = os.path.basename(__file__)

print(f"The current filename is: {current_filename}")

saved as "fntest.py" and then run yields:

The current filename is: fntest.py

when run in "normal" Python.

However, trying to run it in PythonSCAD yields:

ERROR: Traceback (most recent call last): File "<string>", line 4, in <module> NameError: name 'file' is not defined. Did you mean: 'name'?

Should "import os" work? If not, why not? (I promise to make a note in the wiki this time)

The question is:

How does one get the name of the current script so that it may be used as the name of a file (with a different extension) which one then loads and processes?


r/OpenPythonSCAD • • Feb 14 '25

Is it possible for solids to have a bounding box property?

3 Upvotes

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/