On 11/26/2020 5:42 PM, Alan Cox wrote:
Here's that same model (modulo that I don't have a trivial way to make
equilateral triangles) expressed in my Python-based prototype:
You are using python to encode the data structure in this exmple rather
than doing anything truely programmatic.
It's a sample. Samples need to be simple.
What it demonstrates is that you can have a Python-based environment
that doesn't have to be enormously more complex to use than OpenSCAD is.
What does "truly programmatic" mean? Conditionals? Loops? Functions?
Procedures? OpenSCAD has those, just in slightly unfamiliar forms.
Variables? Not exactly, but close enough that many people go a long
time before they notice the difference.
Here's something that demonstrates how you might integrate some
full-featured-language behavior into that program. It retrieves the
parameters from a JSON file.
# Curtain rod screw base
#
# |d4|
# |<d3>|
# |<-d2->|
#
# -- | |
# h3 | |
# -- || ||
# | || ||
# h2 || ||
# | || ||
# -- ================
# h1 ================
# -- ================
#
# |<----d1---->|
import json
params = json.load(open('CurtainRodScrewBase2.json'))
d1 = params['d1']
d2 = params['d2']
d3 = params['d3']
d4 = params['d4']
nub = params['nub']
h1 = params['h1']
h2 = params['h2']
h3 = params['h3']
h23 = h2 + h3
h123 = h1 + h2 + h3
h12 = h1 + h2
Difference(
Union(
Cylinder(d1/2, h1),
Cylinder(d2/2, h123)
# I don't have a trivial way to do a triangle yet
# cylinder(d2/2+nub, h123)
),
Cylinder(d4/2, h123*3, True),
Cylinder(d3/2, h3*3).translate([0,0,h2])
).add()
It still looks a lot like OpenSCAD, in terms of complexity.
The moment you add any input, output or other externally conditional
behaviour they diverge completely.
Sure doesn't look like it so far. The other thing that comes
immediately to mind would be, in a model that I recently did to design a
waste basket to be made out of wood, totaling up the weight of all of
the wood involved. That was one of the major reasons that I did the
model; in OpenSCAD I had to "echo" out the various weights and add them
by hand. BOM applications also come to mind. Again, that would be very
small additions to the basic modeling task.
The python one becomes a program not a data structure expression.
Um... who cares? I mean, I call OpenSCAD files "programs", and you
don't, but what difference does it make? They both generate geometry,
and they can be of comparable complexity to write.
That has enormous consequences for efficiency if parallelism was supported which in the OpenSCAD case it isn't but in other SCAD systems is.
That's true if you spend the majority of your "render" time deriving
your CSG tree. Except for the use/include problems in OpenSCAD, it
seems that few people do. They spend all of their time in turning the
CSG tree into a mesh.
If your alternative-language environment generates meshes immediately,
then yeah, it can't easily get parallelism and caching. But it doesn't
have to do that. My prototype generates a CSG tree. If it did mesh
generation internally, it would be able to do all sorts of good
parallelism and deduplication. Even as it is, farming the mesh
generation out to an external program, that external program could
easily be parallel and could, with a bit of difficulty, deduplicate.
It also becomes a completely different beast to work with using tools.
Why do you say that? I rigged up an IDE similar to OpenSCAD based on
Carsten's AngelCAD infrastructure, where I type Python and punch a
button and out comes a rendered model in a 3D viewer. There's no reason
why that couldn't be done in a UI that looks exactly like OpenSCAD's.
Well, we don't want that. At least, I don't. :)
On 11/27/20 11:12 AM, Alan Cox wrote:
Not sure what you mean. It's not iterative---it's a functional language,
using recursion instead of iteration. Still a programming language. It's
Turing complete. Every programming language is a fixed mapping between its
inputs and its outputs, unless you introduce a source of random bits. I
mean, only certain types of I/O are possible in OpenSCAD, but that doesn't
make it not a programming language.
That was sort fo the point I was trying to make - if you just plug
it into python it is not a functional language/data structure any more.
Everything in the way openscad works is built around that model. Try
adding random() to OpenSCAD and watch the world fall apart around you.
All the caching and other things it does stop working.
If you try and use python as the openscad language you'd have to rewrite
a lot of the core of the program. At that point you might as well just
use the libraries that OpenSCAD does and chunks of the OpenSCAD object
manipulation code to write something different, that was a proper python
library for manipulating 3D constructive geometry - like Blender has.
Alan
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
On 11/27/2020 9:12 AM, Alan Cox wrote:
If you try and use python as the openscad language you'd have to
rewrite a lot of the core of the program. At that point you might as
well just use the libraries that OpenSCAD does and chunks of the
OpenSCAD object manipulation code to write something different, that
was a proper python library for manipulating 3D constructive geometry
You must have looked at different Blender docs than I did.
I looked at them, because the idea of a Python plug-in to a tool that
also allowed interactive editing was fascinating.
I don't remember whether I ever even figured out how to drop a cube into
the scene. I do remember quite clearly that doing so was enormously
more complex than "cube(10);". It was a total deal killer. There was
absolutely no way I was going to move to an environment where basic
operations were so difficult. Maybe I just found entirely the wrong
docs to look at; if you can point me at something simpler please do.
It seems like maybe this is another case where there are disconnects
between what different people think the goals of moving to a different
language are.
It seems like the first thing that comes to your mind is the ability to
manipulate the mesh.
While that would be useful to me - in particular, to extract the
bounding box of an object - it's not the top of my mind. The top thing
on my mind is familiarity - I don't want to have to remember yet another
subtly different syntax with subtly different semantics. I keep five or
more programming languages "hot" in my head all the time; dropping one
or more would be nice. Next would be data structures, so that I could
express complex parameter sets in a more structured way than nested
arrays. After that would be the ability to have procedures that
generate geometry also return metadata about that geometry - dimensions,
attachment points, et cetera.
Those things could layer pretty easily over an OpenSCAD-like
infrastructure, if it was based on a standard full-featured language.
Blender is HARD, with a tough, steep, and long learning curve. Wish I
was fluent with it. <sigh>
On 11/27/20 3:06 PM, Jordan Brown wrote:
On 11/27/2020 9:12 AM, Alan Cox wrote:
If you try and use python as the openscad language you'd have to
rewrite a lot of the core of the program. At that point you might as
well just use the libraries that OpenSCAD does and chunks of the
OpenSCAD object manipulation code to write something different, that
was a proper python library for manipulating 3D constructive geometry
You must have looked at different Blender docs than I did.
I looked at them, because the idea of a Python plug-in to a tool that
also allowed interactive editing was fascinating.
I don't remember whether I ever even figured out how to drop a cube
into the scene. I do remember quite clearly that doing so was
enormously more complex than "cube(10);". It was a total deal
killer. There was absolutely no way I was going to move to an
environment where basic operations were so difficult. Maybe I just
found entirely the wrong docs to look at; if you can point me at
something simpler please do.
It seems like maybe this is another case where there are disconnects
between what different people think the goals of moving to a different
language are.
It seems like the first thing that comes to your mind is the ability
to manipulate the mesh.
While that would be useful to me - in particular, to extract the
bounding box of an object - it's not the top of my mind. The top
thing on my mind is familiarity - I don't want to have to remember yet
another subtly different syntax with subtly different semantics. I
keep five or more programming languages "hot" in my head all the time;
dropping one or more would be nice. Next would be data structures, so
that I could express complex parameter sets in a more structured way
than nested arrays. After that would be the ability to have
procedures that generate geometry also return metadata about that
geometry - dimensions, attachment points, et cetera.
Those things could layer pretty easily over an OpenSCAD-like
infrastructure, if it was based on a standard full-featured language.
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
JordanBrown wrote
On 11/26/2020 4:43 PM, adrianv wrote:
I asked about libraries when I first encountered OpenSCAD a couple years
ago,
I think. And I got a remarkably negative reception, with hostility to
libraries. A vocal group seemed to oppose the idea that libraries should
exist---everybody should design their own code in private from the ground
up. Maybe things have improved a bit, but there's still no good
mechanism
for managing them, or dealing with them, and we have the bug with "use"
that
creates big performance issues, which is apparently seen as very low
priority. (The issue for this bug was first opened in 2012, I think, by
someone who thought the fix was not hard.)
I don't remember so much hostility as apathy and disinterest. I know
that was my reaction. I reviewed my ~10K line project and came to the
conclusion that only a few percent of it could reasonably be replaced by
generic libraries. I simply don't spend enough time reinventing that
stuff to even make it worth the effort to go find what exists, much less
to spend any time building up a library/package infrastructure.
The vast majority of my work has been in modeling - not in the computer
sense of creating a 3D representation of something, but in the generic
sense of producing a duplicate of an existing physical object. I'm not
doing mechanical design, so I look at screw-and-gear libraries and say
"that's nice, but I don't have any use for it". I look at "up", "down",
"xscale", "triangle", and similar, and say "uh, what's wrong with
translate, scale, and circle?". None of the libraries that I've looked
at have provided enough value to me for me to spend the effort to adopt
them.
Libraries are fine. Libraries are great. By all means, write them. By
all means, build dependency/version trackers and packaging systems. But
so far I don't have any interest in using them or working on them.
No, I was met with, "there's no reason for libraries, everybody should just
do stuff directly like I do", "making libraries is too much work, nobody
should do it", "we shouldn't waste effort on doing stuff to support
libraries in OpenSCAD because it's pointless/unnecessary (and might take
away from useful additions)"
There were a few people who responded with "yeah, libraries" and they were
basically shut down by the anti-library crowd. It was a case of "I
don't need libraries...do what you want", which seems to be your position.
It seemed like active hostility to the idea of libraries.
There are two kinds of libraries for OpenSCAD: ones that supply new
geometric functionality (such as a sweep function) and ones that supply
specific objects like screws, gears, joint mechanisms, and so on. I think
the former are more likely to be broadly useful than the latter. I also
think that the way one designs a model is determined by the available tools.
And possibly even what models one sees as possible may be influenced by the
available tools.
--
Sent from: http://forum.openscad.org/
Alan Cox-2 wrote
Not sure what you mean. It's not iterative---it's a functional language,
using recursion instead of iteration. Still a programming language.
It's
Turing complete. Every programming language is a fixed mapping between
its
inputs and its outputs, unless you introduce a source of random bits.
I
mean, only certain types of I/O are possible in OpenSCAD, but that
doesn't
make it not a programming language.
That was sort fo the point I was trying to make - if you just plug
it into python it is not a functional language/data structure any more.
Everything in the way openscad works is built around that model. Try
adding random() to OpenSCAD and watch the world fall apart around you.
All the caching and other things it does stop working.
Note again, I'm just commenting on OpenSCAD, not taking a position on Python
or something.
I still really don't get your point.
Note random() already exists in OpenSCAD. I've even used it and nothing
blew up. It worked fine.
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Mathematical_Functions#rands
--
Sent from: http://forum.openscad.org/
On 27 Nov 2020 at 14:57, adrianv wrote:
There are two kinds of libraries for OpenSCAD: ones that supply new
geometric functionality (such as a sweep function) and ones that supply
specific objects like screws, gears, joint mechanisms, and so on. I think
the former are more likely to be broadly useful than the latter. I also
think that the way one designs a model is determined by the available tools.
And possibly even what models one sees as possible may be influenced by the
available tools.
I see a third kind of library... one that makes complex things more easily
implemented. My current favourite library is BOSL2, which has new
functionality, supplies specific objects, but most important for me, as a user
of intermediate skill, makes things easier to specify.
BOSL2 offers, for example, things like cubes (called cuboids), that include
the ability to apply chamfers or rounding on any edges, using easily
understood parameters, like TOP, FRONT, RIGHT+REAR, etc.
These are the sorts of things that really let me do things more intuitively and
far quicker.
Sure, those sorts of things are perhaps seen as syntactic sugar and
unnecessary by folks that are far more skilled than I, but for me, they are a
wonderful addition to a very capable program.
On Fri, Nov 27, 2020 at 4:38 PM David ainut@hiwaay.net wrote:
Blender is HARD, with a tough, steep, and long learning curve. Wish I was fluent with it. <sigh>
I first fiddled with Blender in 2010. I wanted to edit a bracket for
a Mendel printer to remove 3 holes from the STL. I spent 2.5 hours
trying to figure out how to use Blender, how to navigate in Blender,
or how to do any single damn thing in Blender. It was the most
non-intuitive piece of software I had ever encountered (I later found
out that using Blender from a laptop without a numeric keypad makes it
much harder to use). At the point I gave up, I went back to
Thingiverse and grabbed the DXF file and the OpenSCAD script that made
the STL in the first place, and in seconds figured out what the
program was doing and commented out three lines that made the holes I
wanted to not be there. F6 and export and I was done! I have been
a happy user of OpenSCAD ever since. Blender still pisses me off (the
last time I worked with it was to orchestrate some animation to,
effectively, drive a pre-rendered car around a virtual racetrack - it
did that fine, but it was animation, not object creation, in the
Python I was hacking).
With that, from what I'm reading in this thread, it sounds like a case
of "OpenSCAD isn't a procedural language and I don't like that" that
comes up pretty much every time someone wants to fiddle with variables
inside loops. I've been programming (professionally) for decades.
OpenSCAD is the only Functional Language that I've learned and, yes,
it was a bit of an adjustment coming from C and Perl, etc., but it's
not like OpenSCAD is the only Functional Language ever created. It's
a different category and in the specific case of twiddling things
inside and outside loops, it differs from a Procedural Language.
I'm not in favor of $SUBJECT. I've been working in OpenSCAD for over
10 years at this point and I don't see Functional vs Procedural as
something that needs to be "fixed". If someone wants to go make
Python into an object creation platform, that sounds like a different
project.
-ethan
On 27 Nov 2020 at 14:57, adrianv wrote:
There are two kinds of libraries for OpenSCAD: ones that supply new
geometric functionality (such as a sweep function) and ones that supply
specific objects like screws, gears, joint mechanisms, and so on. I think
the former are more likely to be broadly useful than the latter. I also
think that the way one designs a model is determined by the available tools.
And possibly even what models one sees as possible may be influenced by the
available tools.
I see a third kind of library... one that makes complex things more easily
implemented. My current favourite library is BOSL2, which has new
functionality, supplies specific objects, but most important for me, as a user
of intermediate skill, makes things easier to specify.
BOSL2 offers, for example, things like cubes (called cuboids), that include
the ability to apply chamfers or rounding on any edges, using easily
understood parameters, like TOP, FRONT, RIGHT+REAR, etc.
These are the sorts of things that really let me do things more intuitively and
far quicker.
Sure, those sorts of things are perhaps seen as syntactic sugar and
unnecessary by folks that are far more skilled than I, but for me, they are a
wonderful addition to a very capable program.
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Thing is, I’m not just trying to update a variable in a loop. I can do that awkwardly with C-style for().
I’m writing a library to do the hard things like make solids built from Bezier patches, or calculate path offsets, or calculate Voronoi regions so that I can do more complicated geometry. And I cannot feasibly implement some of the needed efficient algorithms because the language cannot make the data structures without being extremely inefficient.
If OpenSCAD even had a mutable dictionary type, I could make most the needed structures, but it doesn’t. And variables aren’t truly mutable.
And saying that that is not what OpenSCAD is designed for, sounds to me like saying “OpenSCAD is just a toy, and you shouldn’t try making it better.”
-Revar
On Nov 27, 2020, at 4:48 PM, Ethan Dicks ethan.dicks@gmail.com wrote:
On Fri, Nov 27, 2020 at 4:38 PM David ainut@hiwaay.net wrote:
Blender is HARD, with a tough, steep, and long learning curve. Wish I was fluent with it. <sigh>
I first fiddled with Blender in 2010. I wanted to edit a bracket for
a Mendel printer to remove 3 holes from the STL. I spent 2.5 hours
trying to figure out how to use Blender, how to navigate in Blender,
or how to do any single damn thing in Blender. It was the most
non-intuitive piece of software I had ever encountered (I later found
out that using Blender from a laptop without a numeric keypad makes it
much harder to use). At the point I gave up, I went back to
Thingiverse and grabbed the DXF file and the OpenSCAD script that made
the STL in the first place, and in seconds figured out what the
program was doing and commented out three lines that made the holes I
wanted to not be there. F6 and export and I was done! I have been
a happy user of OpenSCAD ever since. Blender still pisses me off (the
last time I worked with it was to orchestrate some animation to,
effectively, drive a pre-rendered car around a virtual racetrack - it
did that fine, but it was animation, not object creation, in the
Python I was hacking).
With that, from what I'm reading in this thread, it sounds like a case
of "OpenSCAD isn't a procedural language and I don't like that" that
comes up pretty much every time someone wants to fiddle with variables
inside loops. I've been programming (professionally) for decades.
OpenSCAD is the only Functional Language that I've learned and, yes,
it was a bit of an adjustment coming from C and Perl, etc., but it's
not like OpenSCAD is the only Functional Language ever created. It's
a different category and in the specific case of twiddling things
inside and outside loops, it differs from a Procedural Language.
I'm not in favor of $SUBJECT. I've been working in OpenSCAD for over
10 years at this point and I don't see Functional vs Procedural as
something that needs to be "fixed". If someone wants to go make
Python into an object creation platform, that sounds like a different
project.
-ethan
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org