discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Python Equality

CN
Csaba Nagy
Tue, Dec 14, 2021 6:09 PM

My framework can be turned into a PyCharm plugin with code
completion/viewing/refactoring of the parameter hierarchy and Part
library management. It can be extended to document parameters visually
as annotations over renderings of each Part. It can already generate
complex extrusions, can handle Bezier paths and some more - but none of
that will be published soon if I don't get help. I'm still working out
the details of how to handle aliases (happens a lot that different
parts with similar shape want to name their parameters differently),
orientation/alignment/attaching parts in an assembly. I contemplate
getting rid of the openscad translate/rotate functions and replace them
with versions which are stored on each part, that would allow automated
kinematic chain calculations. There's a lot of work which would
radically change what I currently have, and I don't have the motivation
to do all that alone in a short term... I will eventually do it for my
own sake, but gradually as I need it for my own modeling.

Cheers,
Csaba

On Tue, 2021-12-14 at 18:48 +0100, edmund ronald wrote:

Here is a Medium post where John Clark Craig describes his wrapper.
He seems to have a userbase of sorts, and to be a smart cookie so
there is probably a need for something like this, and I expect sooner
or later  someone will make an integrated 3D system of their own
similar to this as the openScad crowd don't like the idea.

Edmund

Edmund

On Tuesday, December 14, 2021, Csaba Nagy ncsaba@javampire.com
wrote:

Hi David,

at first I thought I was looking for the same, a python 3D
programming
language. So I started using SolidPython:

https://github.com/SolidCode/SolidPython

It is a fairly straightforward wrapper around OpenSCAD, allowing
you to
write your 3D model in python, which is then translated to
OpenSCAD.
But soon I realized that what I needed is a better way to express
parameters of a complex model.

So I wrote my own python framework to process JSON descriptors,
with
meta-class magic that merges the parameters across the inheritance
hierarchy. That way I can define sub-classes which basically
inherit
the parameters of their base class, and can override just that
single
one they actually change. The framework messes with the
setters/getters
too so parameters defined in that decriptor are available with the
attribute access syntax as well as dictionary entries (the "Part"
class
extends an ordered dictionary). Class instantiation can override
any of
the parameters, the ones not set are left at the default value.
That
overall makes for a hierarchical access of all parameters - in
simple
cases simplifies the code a lot, in complex ones makes for
spaghetti-
like names, but I think it is still the better way to handle 100+
variables.

Working with PyCharm I also have some magic built in the Part class
which allows me to render the current file and open it in OpenSCAD
view
with the press of a key-combination. Same can be done for any file
in
the project view, or for a class highlighted in the editor. That
makes
for fairly streamlined work-flow where coding and preview
alternate.

The catch with all this is that at the moment it is tailored for
exactly what I needed to model and it is less then pre-alpha
quality
for public release. I also can't find the motivation to spend the
time
necessary to improve it for the sake of publishing, real life and
my
own modeling tasks are what finally win.

I will include an OpenSCAD file and the top level python class
which
generated it for a sample of what can be done. I will not publish
the
code as I'm not satisfied with it and will surely radically change
it
still in the future - but if somebody is interested enough in it to
help preparing a publishable version, I'm ready to do a few on-line
sessions to explain what I have and discuss what and how to
publish.
Without help, it will take me a few more years with the speed I'm
progressing now.

The project is hosted on gitlab.com, at the moment private and it
seems
gitlab will not allow me to change that (bug I assume). Anybody
wanting
to check the code, ask me and I will give you access.

Cheers,
Csaba

P.S. the scad file is a table-tennis ball machine I'm working on
right
now. All elements you see are fully configurable, almost no hard-
coded
number outside the CONFIG_DESCRIPTOR of each used Part/Assembly.
The
iter_components method in the python file will generate a list of
3D-
printable components, processing is bound to a PyCharm key
combination
too. Any class name extending Part/Assembly in the python file can
be
highlighted and previewed using a key-press too (of course only in
my
local setup, I would need to package the key shortcuts in a PyCharm
plugin).

On Tue, 2021-12-14 at 10:14 -0600, David Schooley wrote:

Thank you everyone for the comments up to the point. Even the

“no,

that’s not going to happen” type of feedback is useful.

To put things in context: I was a contributor to gnuplot years

ago.

(I did a really nice Mac version.) I’ve made a lot of 2D plots

using

Perl-generated gnuplot scripts. After playing with flex and bison

a

bit, I started thinking about a new plotting program using a more
modern interpreter. Python was still relatively new, I hadn’t

used

Python at all at the time, but the syntax for this never-written
plotting software would have been very Python-like. I started

using

Python a short time later, abandoned by software project, and now
things that would have been Perl+gnuplot are Python with

matplotlib.

Life is good.

When I started 3D printing, I started with FreeCAD (which has a
Python workbench) and then moved to OpenSCAD. I have a large

number

of OpenSCAD scripts laying around.

OpenSCAD meets my needs for almost everything I do. (It does fall
down when it comes to things such as fillets around complex

shapes.)

There are times when I need real variables and there are times

when

the design needs to change depending on the size or something

else,

i.e., the hole pattern changes depending on the size of the

object.

The next step would be data-driven designs, which I can visualize

but

can’t really do at this point without using Python to create

OpenSCAD

scripts.

An example might be a 3D printed map using GIS data. You could
perhaps do this with the OpenSCAD language by extruding a bitmap
generated using Python. It would be cleaner, and you would have

more

control, if you did the whole thing in Python.

Thinking of OpenSCAD (the software) as a wrapper for OpenSCAD

(the

language) is perfectly reasonable. It’s not the answer I wanted,

but

it’s the answer I got.

So that’s where I am at. I’ll take a look at the book that Harm
suggested. I think I can get the Kindle version for free.

On Dec 14, 2021, at 1:44 AM, edmund ronald <

wrote:

Everybody and their dog seems to have done Python covers of
OpenSCAD.
Which seems to indicate that there is a perceived need in the

3d

Print userbase.

My guess is sooner or later another project will mature enough

to

serve that population, at which point the question will go

away.

Edmund

On Mon, Dec 13, 2021 at 11:34 AM info@hjcreations.nl wrote:

Hi David,

Do you know this book :
Python for 3D Printing openSCAD by Craig, John Clark

I got it and seems interesting, but had no time read it at

all.

If you'reinterested I can give you more info.

Regards,

Harm Jeurink

David Schooley schreef op 2021-12-12 10:43:

I have a feeling this has come up before…

I’m curious about any thoughts/previous discussions have

happened

regarding incorporating Python as an embedded scripting

language to

OpenSCAD. Some work has been done with Python and CSG, so

this

isn’t

entirely impossible, but it could be a lot of work; I get

that.

The OpenSCAD language isn’t bad, but it’s no great shakes

either. It’s

interesting to see work happening to make structures a

reality,

but

maybe it would be better to incorporate a language that has

real

variables and objects. There was a recent discussion around
calculating parameters on the fly, which is easy with

Python

but is

more difficult or impossible using the OpenSCAD language.

I’m not at all interested in generating OpenSCAD code from

Python that

just adds another layer of “Why doesn’t this work?” I think

being able

to write some Python code that generates an object that

OpenSCAD can

display and turn into something I can 3D print or cut using

a

laser

would be amazing.


OpenSCAD mailing list
To unsubscribe send an email to

discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to


OpenSCAD mailing list
To unsubscribe send an email to


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

My framework can be turned into a PyCharm plugin with code completion/viewing/refactoring of the parameter hierarchy and Part library management. It can be extended to document parameters visually as annotations over renderings of each Part. It can already generate complex extrusions, can handle Bezier paths and some more - but none of that will be published soon if I don't get help. I'm still working out the details of how to handle aliases (happens a lot that different parts with similar shape want to name their parameters differently), orientation/alignment/attaching parts in an assembly. I contemplate getting rid of the openscad translate/rotate functions and replace them with versions which are stored on each part, that would allow automated kinematic chain calculations. There's a lot of work which would radically change what I currently have, and I don't have the motivation to do all that alone in a short term... I will eventually do it for my own sake, but gradually as I need it for my own modeling. Cheers, Csaba On Tue, 2021-12-14 at 18:48 +0100, edmund ronald wrote: > Here is a Medium post where John Clark Craig describes his wrapper. > He seems to have a userbase of sorts, and to be a smart cookie so > there is probably a need for something like this, and I expect sooner > or later someone will make an integrated 3D system of their own > similar to this as the openScad crowd don't like the idea. > > Edmund > > https://jccraig.medium.com/yes-you-can-use-python-for-3d-design-and-printing-508b1791c863 > > > Edmund > > > On Tuesday, December 14, 2021, Csaba Nagy <ncsaba@javampire.com> > wrote: > > Hi David, > > > > at first I thought I was looking for the same, a python 3D > > programming > > language. So I started using SolidPython: > > > > https://github.com/SolidCode/SolidPython > > > > It is a fairly straightforward wrapper around OpenSCAD, allowing > > you to > > write your 3D model in python, which is then translated to > > OpenSCAD. > > But soon I realized that what I needed is a better way to express > > parameters of a complex model. > > > > So I wrote my own python framework to process JSON descriptors, > > with > > meta-class magic that merges the parameters across the inheritance > > hierarchy. That way I can define sub-classes which basically > > inherit > > the parameters of their base class, and can override just that > > single > > one they actually change. The framework messes with the > > setters/getters > > too so parameters defined in that decriptor are available with the > > attribute access syntax as well as dictionary entries (the "Part" > > class > > extends an ordered dictionary). Class instantiation can override > > any of > > the parameters, the ones not set are left at the default value. > > That > > overall makes for a hierarchical access of all parameters - in > > simple > > cases simplifies the code a lot, in complex ones makes for > > spaghetti- > > like names, but I think it is still the better way to handle 100+ > > variables. > > > > Working with PyCharm I also have some magic built in the Part class > > which allows me to render the current file and open it in OpenSCAD > > view > > with the press of a key-combination. Same can be done for any file > > in > > the project view, or for a class highlighted in the editor. That > > makes > > for fairly streamlined work-flow where coding and preview > > alternate. > > > > The catch with all this is that at the moment it is tailored for > > exactly what I needed to model and it is less then pre-alpha > > quality > > for public release. I also can't find the motivation to spend the > > time > > necessary to improve it for the sake of publishing, real life and > > my > > own modeling tasks are what finally win. > > > > I will include an OpenSCAD file and the top level python class > > which > > generated it for a sample of what can be done. I will not publish > > the > > code as I'm not satisfied with it and will surely radically change > > it > > still in the future - but if somebody is interested enough in it to > > help preparing a publishable version, I'm ready to do a few on-line > > sessions to explain what I have and discuss what and how to > > publish. > > Without help, it will take me a few more years with the speed I'm > > progressing now. > > > > The project is hosted on gitlab.com, at the moment private and it > > seems > > gitlab will not allow me to change that (bug I assume). Anybody > > wanting > > to check the code, ask me and I will give you access. > > > > Cheers, > > Csaba > > > > P.S. the scad file is a table-tennis ball machine I'm working on > > right > > now. All elements you see are fully configurable, almost no hard- > > coded > > number outside the CONFIG_DESCRIPTOR of each used Part/Assembly. > > The > > iter_components method in the python file will generate a list of > > 3D- > > printable components, processing is bound to a PyCharm key > > combination > > too. Any class name extending Part/Assembly in the python file can > > be > > highlighted and previewed using a key-press too (of course only in > > my > > local setup, I would need to package the key shortcuts in a PyCharm > > plugin). > > > > On Tue, 2021-12-14 at 10:14 -0600, David Schooley wrote: > > > Thank you everyone for the comments up to the point. Even the > > “no, > > > that’s not going to happen” type of feedback is useful. > > > > > > To put things in context: I was a contributor to gnuplot years > > ago. > > > (I did a really nice Mac version.) I’ve made a lot of 2D plots > > using > > > Perl-generated gnuplot scripts. After playing with flex and bison > > a > > > bit, I started thinking about a new plotting program using a more > > > modern interpreter. Python was still relatively new, I hadn’t > > used > > > Python at all at the time, but the syntax for this never-written > > > plotting software would have been very Python-like. I started > > using > > > Python a short time later, abandoned by software project, and now > > > things that would have been Perl+gnuplot are Python with > > matplotlib. > > > Life is good. > > > > > > When I started 3D printing, I started with FreeCAD (which has a > > > Python workbench) and then moved to OpenSCAD. I have a large > > number > > > of OpenSCAD scripts laying around. > > > > > > OpenSCAD meets my needs for almost everything I do. (It does fall > > > down when it comes to things such as fillets around complex > > shapes.) > > > There are times when I need real variables and there are times > > when > > > the design needs to change depending on the size or something > > else, > > > i.e., the hole pattern changes depending on the size of the > > object. > > > The next step would be data-driven designs, which I can visualize > > but > > > can’t really do at this point without using Python to create > > OpenSCAD > > > scripts. > > > > > > An example might be a 3D printed map using GIS data. You could > > > perhaps do this with the OpenSCAD language by extruding a bitmap > > > generated using Python. It would be cleaner, and you would have > > more > > > control, if you did the whole thing in Python. > > > > > > Thinking of OpenSCAD (the software) as a wrapper for OpenSCAD > > (the > > > language) is perfectly reasonable. It’s not the answer I wanted, > > but > > > it’s the answer I got. > > > > > > So that’s where I am at. I’ll take a look at the book that Harm > > > suggested. I think I can get the Kindle version for free. > > > > > > > On Dec 14, 2021, at 1:44 AM, edmund ronald < > > edmundronald@gmail.com> > > > > wrote: > > > > > > > > Everybody and their dog seems to have done Python covers of > > > > OpenSCAD. > > > > Which seems to indicate that there is a perceived need in the > > 3d > > > > Print userbase. > > > > > > > > My guess is sooner or later another project will mature enough > > to > > > > serve that population, at which point the question will go > > away. > > > > > > > > Edmund > > > > > > > > > > > > > > > > On Mon, Dec 13, 2021 at 11:34 AM <info@hjcreations.nl> wrote: > > > > > Hi David, > > > > > > > > > > Do you know this book : > > > > > Python for 3D Printing openSCAD by Craig, John Clark > > > > > > > > > > I got it and seems interesting, but had no time read it at > > all. > > > > > If you'reinterested I can give you more info. > > > > > > > > > > Regards, > > > > > > > > > > Harm Jeurink > > > > > > > > > > David Schooley schreef op 2021-12-12 10:43: > > > > > > I have a feeling this has come up before… > > > > > > > > > > > > I’m curious about any thoughts/previous discussions have > > > > > > > > > > happened > > > > > > regarding incorporating Python as an embedded scripting > > > > > > > > > > language to > > > > > > OpenSCAD. Some work has been done with Python and CSG, so > > this > > > > > > > > > > isn’t > > > > > > entirely impossible, but it could be a lot of work; I get > > that. > > > > > > > > > > > > The OpenSCAD language isn’t bad, but it’s no great shakes > > > > > > > > > > either. It’s > > > > > > interesting to see work happening to make structures a > > reality, > > > > > > > > > > but > > > > > > maybe it would be better to incorporate a language that has > > > > > > > > > > real > > > > > > variables and objects. There was a recent discussion around > > > > > > calculating parameters on the fly, which is easy with > > Python > > > > > > > > > > but is > > > > > > more difficult or impossible using the OpenSCAD language. > > > > > > > > > > > > I’m not at all interested in generating OpenSCAD code from > > > > > > > > > > Python that > > > > > > just adds another layer of “Why doesn’t this work?” I think > > > > > > > > > > being able > > > > > > to write some Python code that generates an object that > > > > > > > > > > OpenSCAD can > > > > > > display and turn into something I can 3D print or cut using > > a > > > > > > > > > > laser > > > > > > would be amazing. > > > > > > > > > > > > _______________________________________________ > > > > > > OpenSCAD mailing list > > > > > > To unsubscribe send an email to > > > > > > > > > > discuss-leave@lists.openscad.org > > > > > _______________________________________________ > > > > > OpenSCAD mailing list > > > > > To unsubscribe send an email to > > discuss-leave@lists.openscad.org > > > > > > > > _______________________________________________ > > > > OpenSCAD mailing list > > > > To unsubscribe send an email to > > discuss-leave@lists.openscad.org > > > > > > _______________________________________________ > > > OpenSCAD mailing list > > > To unsubscribe send an email to discuss-leave@lists.openscad.org > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
JB
Jordan Brown
Tue, Dec 14, 2021 6:44 PM

I looked into this a bit a year or two ago, more from the perspective of
wanting to reduce the number of languages that I keep in my head, and to
make it easier for newcomers, than from any specific problem with
OpenSCAD functionality.  Why reinvent the wheel, but a little differently?

I got far enough to have a toolchain based on Carsten's AngelCAD
environment.  You could type a Python program like

cu = Cube(size=45,center=True);
sp = Sphere(r=30)
cusp = cu.intersect(sp)

## union of 3 cylinders
cy = Cylinder(r=17,h=50,center=True)
cy2 = cy.union(cy.rotatex(90))
cy3 = cy2.union(cy.rotatey(90))

## difference of the 2 above
cusp.subtract(cy3).add()

into the IDE and my toolchain would turn that into xcsg that could then
be viewed using Carsten's xcsg viewer - basically the same flow as
Carsten's AngelScript flow.  No OpenSCAD in the process - not
specifically to avoid it, but to directly emit a lower-level result.

I stopped working on it for a couple of reasons:

  • I was offended by the need to explicitly add objects to the model
    (the .add() method above), and couldn't figure out how to get rid of
    it.  The minimum OpenSCAD program is "cube();" and I wanted to get
    down to that level of simplicity.
  • Python is not sandboxable.  Python programs can do anything.  You
    could not take somebody's Python-based SCAD program and run it,
    without risking that it would trash your system.

Note also that designing in a "real language" doesn't automatically
solve some of the OpenSCAD complaints.  In particular, just because
you've got a real language and real objects doesn't mean that you've got
access to the geometry.  My toolchain operated by generating an xcsg
https://github.com/arnholm/xcsg file to be fed into a geometry
engine.  It has no idea what, for instance, a sphere is; it just knows
that it's a geometric object that can be generated and operated on by
the geometry engine.

It was really pretty easy to write - it's only about 300 lines of Python
plus a one line batch file to glue it together.  I'd be happy to forward
it to anybody who wants to play with it.

I looked into this a bit a year or two ago, more from the perspective of wanting to reduce the number of languages that I keep in my head, and to make it easier for newcomers, than from any specific problem with OpenSCAD functionality.  Why reinvent the wheel, but a little differently? I got far enough to have a toolchain based on Carsten's AngelCAD environment.  You could type a Python program like cu = Cube(size=45,center=True); sp = Sphere(r=30) cusp = cu.intersect(sp) ## union of 3 cylinders cy = Cylinder(r=17,h=50,center=True) cy2 = cy.union(cy.rotatex(90)) cy3 = cy2.union(cy.rotatey(90)) ## difference of the 2 above cusp.subtract(cy3).add() into the IDE and my toolchain would turn that into xcsg that could then be viewed using Carsten's xcsg viewer - basically the same flow as Carsten's AngelScript flow.  No OpenSCAD in the process - not specifically to avoid it, but to directly emit a lower-level result. I stopped working on it for a couple of reasons: * I was offended by the need to explicitly add objects to the model (the .add() method above), and couldn't figure out how to get rid of it.  The minimum OpenSCAD program is "cube();" and I wanted to get down to that level of simplicity. * Python is not sandboxable.  Python programs can do anything.  You could not take somebody's Python-based SCAD program and run it, without risking that it would trash your system. Note also that designing in a "real language" doesn't automatically solve some of the OpenSCAD complaints.  In particular, just because you've got a real language and real objects doesn't mean that you've got access to the geometry.  My toolchain operated by generating an xcsg <https://github.com/arnholm/xcsg> file to be fed into a geometry engine.  It has no idea what, for instance, a sphere is; it just knows that it's a geometric object that can be generated and operated on by the geometry engine. It was really pretty easy to write - it's only about 300 lines of Python plus a one line batch file to glue it together.  I'd be happy to forward it to anybody who wants to play with it.
CA
Carsten Arnholm
Thu, Dec 16, 2021 4:17 PM

On 14.12.2021 19:44, Jordan Brown wrote:

I stopped working on it for a couple of reasons:

  • I was offended by the need to explicitly add objects to the model
    (the .add() method above), and couldn't figure out how to get rid of
    it.  The minimum OpenSCAD program is "cube();" and I wanted to get
    down to that level of simplicity.

You could probably use Python operator overloading
https://www.pythontutorial.net/python-oop/python-operator-overloading/

 solid  = Cube(100) + Sphere(50);

My toolchain operated by generating an xcsg
https://github.com/arnholm/xcsg file to be fed into a geometry
engine.  It has no idea what, for instance, a sphere is; it just knows
that it's a geometric object that can be generated and operated on by
the geometry engine.

Correct. This implies one could reimplement the engine to use CGAL or
OpenCascade instead of Carve,

Carsten Arnholm

On 14.12.2021 19:44, Jordan Brown wrote: > I stopped working on it for a couple of reasons: > > * I was offended by the need to explicitly add objects to the model > (the .add() method above), and couldn't figure out how to get rid of > it.  The minimum OpenSCAD program is "cube();" and I wanted to get > down to that level of simplicity. You could probably use Python operator overloading https://www.pythontutorial.net/python-oop/python-operator-overloading/ solid = Cube(100) + Sphere(50); > My toolchain operated by generating an xcsg > <https://github.com/arnholm/xcsg> file to be fed into a geometry > engine.  It has no idea what, for instance, a sphere is; it just knows > that it's a geometric object that can be generated and operated on by > the geometry engine. Correct. This implies one could reimplement the engine to use CGAL or OpenCascade instead of Carve, Carsten Arnholm
JB
Jordan Brown
Thu, Dec 16, 2021 5:05 PM

On 12/16/2021 8:17 AM, Carsten Arnholm wrote:

On 14.12.2021 19:44, Jordan Brown wrote:

I stopped working on it for a couple of reasons:

  * I was offended by the need to explicitly add objects to the model
    (the .add() method above), and couldn't figure out how to get rid of
    it.  The minimum OpenSCAD program is "cube();" and I wanted to get
    down to that level of simplicity.

You could probably use Python operator overloading
https://www.pythontutorial.net/python-oop/python-operator-overloading/

    solid  = Cube(100) + Sphere(50);

Yes, I could do that, but that's not what I was offended by.

In OpenSCAD, you can say

cube();

and that's a complete and valid program that yields a model of a cube.

In Python, if cube() is a function that returns a cube, saying

cube()

will create a geometric object that's a cube... and then will drop it on
the floor, because nothing consumes it.

You have to have a method or function that consumes the cube and adds it
to the model.  In my library, that's the .add() method, but it could
equally well be an add(obj) function.  Or maybe the program is required
to return the object (which also requires you to explicitly union the
various components of the model, another thing that OpenSCAD doesn't
require you to do explicitly).  In any event, the required minimum
program is more than just c u b e ( ).

I was hoping that I could find a hook akin to what the REPL
https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop
does, so that if the result of a statement was a geometric object that
would otherwise be dropped on the floor, it would instead be added to
the model, in the same way that the REPL would print it, but I couldn't
find such a hook.

I also looked at JavaScript as the base for a 3D modeling environment,
and ran into similar issues.  I think there was something else that I
didn't like about JavaScript for the purpose, but I don't remember
what.  Perhaps it was simply that command-line JavaScript interpreters
are not as ubiquitous as command-line Python interpreters.  (Yes, I know
about Node.js and use it extensively, but it's not ubiquitous.  Yes,
every browser has a JavaScript interpreter, but you can't hook them into
a toolchain, at least not without also creating an xscg processor that
runs in a browser.)

On 12/16/2021 8:17 AM, Carsten Arnholm wrote: > On 14.12.2021 19:44, Jordan Brown wrote: >> I stopped working on it for a couple of reasons: >> >>   * I was offended by the need to explicitly add objects to the model >>     (the .add() method above), and couldn't figure out how to get rid of >>     it.  The minimum OpenSCAD program is "cube();" and I wanted to get >>     down to that level of simplicity. > > You could probably use Python operator overloading > https://www.pythontutorial.net/python-oop/python-operator-overloading/ > >     solid  = Cube(100) + Sphere(50); Yes, I could do that, but that's not what I was offended by. In OpenSCAD, you can say cube(); and that's a complete and valid program that yields a model of a cube. In Python, if cube() is a function that returns a cube, saying cube() will create a geometric object that's a cube... and then will drop it on the floor, because nothing consumes it. You have to have a method or function that consumes the cube and adds it to the model.  In my library, that's the .add() method, but it could equally well be an add(obj) function.  Or maybe the program is required to return the object (which also requires you to explicitly union the various components of the model, another thing that OpenSCAD doesn't require you to do explicitly).  In any event, the required minimum program is more than just c u b e ( ). I was hoping that I could find a hook akin to what the REPL <https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop> does, so that if the result of a statement was a geometric object that would otherwise be dropped on the floor, it would instead be added to the model, in the same way that the REPL would print it, but I couldn't find such a hook. I also looked at JavaScript as the base for a 3D modeling environment, and ran into similar issues.  I think there was something else that I didn't like about JavaScript for the purpose, but I don't remember what.  Perhaps it was simply that command-line JavaScript interpreters are not as ubiquitous as command-line Python interpreters.  (Yes, I know about Node.js and use it extensively, but it's not ubiquitous.  Yes, every browser has a JavaScript interpreter, but you can't hook them into a toolchain, at least not without *also* creating an xscg processor that runs in a browser.)