I know this is somewhat off topic, but I've found that people who don't know
what OpenSCAD is don't even understand what I'm asking, and I only get "You
can do that in photoshop" or "Why would you need that?" when asking in other
places, and I thought the issue might interest OpenSCAD users.
I'm looking for something like OpenSCAD, but for creating 2D images using a
script.
This would be useful for geometric shapes or parametric designs. Say, for
example, that I want to make an image with a railroad track running in an
oval around a parameterized text. Simple scaling wouldn't do, since the
track would get strange proportions. However, with some scripting, it would
be trivial to draw a track that fits the text.
OpenSCAD, while nice, doesn't really do 2D images that looks nice, it's more
about "here be stuff, here be nothing" which is suitable for later
3D-printing.
Any ideas?
--
Sent from: http://forum.openscad.org/
I have been looking for something like this as well in the past month.
Openscad is also not very good for 2.5d as its pretty hard to draw lines on
a face (or at least I couldn't find a way).
Closest i could find were "parametric" cads, like freecad. It also have
openscad import. I know its not what you are looking for.
Would be very happy if there is one that I missed
--
Sent from: http://forum.openscad.org/
Sounds like SVG might work for what you described.
On October 20, 2017 12:28:27 AM Troberg troberg.anders@gmail.com wrote:
I know this is somewhat off topic, but I've found that people who don't know
what OpenSCAD is don't even understand what I'm asking, and I only get "You
can do that in photoshop" or "Why would you need that?" when asking in other
places, and I thought the issue might interest OpenSCAD users.
I'm looking for something like OpenSCAD, but for creating 2D images using a
script.
This would be useful for geometric shapes or parametric designs. Say, for
example, that I want to make an image with a railroad track running in an
oval around a parameterized text. Simple scaling wouldn't do, since the
track would get strange proportions. However, with some scripting, it would
be trivial to draw a track that fits the text.
OpenSCAD, while nice, doesn't really do 2D images that looks nice, it's more
about "here be stuff, here be nothing" which is suitable for later
3D-printing.
Any ideas?
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
The beauty of OpenSCAD is that it's easy to add functionality. If you want to
draw 2d lines just write a module, for example:
//line module draws a 2D line from p1 to p2
module line(p1,p2,w) {
hull() {
translate(p1) circle(r=w,$fn=20);
translate(p2) circle(r=w,$fn=20);
}
}
line([3,1],[5,4]);
If you want to have a polyline just add another module. For example.
//random points for demonstration purposes
p0=[-4,8];
p1=[2,7];
p2=[6,12];
p3=[8,24];
p4=[10,12];
points=[p0,p1,p2,p3,p4];
//line module draws a 2D line from p1 to p2
module line(p1,p2,w) {
hull() {
translate(p1) circle(r=w,$fn=20);
translate(p2) circle(r=w,$fn=20);
}
}
//polyline is a recursive module that to draw lines between all points in de
list of points.
module polyline(points, index, w) {
if(index < len(points)) {
line(points[index - 1], points[index],w);
polyline(points, index + 1,w);
}
}
polyline(points,1,0.5);
So I think it's entirely possible to do a railroad track around a
parameterized text and scale it. Here is a link to OpenSCAD articles by
Justin Lin https://openhome.cc/eGossip/OpenSCAD/index.html . He's done
several 2D projects like bezier curves and turtle graphics in OpenSCAD just
by adding functionality. Hopefully it provides inspiration to create your
project.
--
Sent from: http://forum.openscad.org/
On 2017-10-20 09:27, Troberg wrote:
I'm looking for something like OpenSCAD, but for creating 2D images
using a
script.
It is not really clear what you are after, but you can create 2d objects
and use boolean operations on them in OpenSCAD, and you can export that
as e.g. DXF to visualise somewhere else.
Carsten Arnholm
I'd say that what I'm looking for is something like "script controlled
PaintShop", much like one could say that OpenSCAD is a "script controlled
SketchUp" (and don't nitpick that definition, I'm just trying to get a
general idea across here...).
--
Sent from: http://forum.openscad.org/
If I understand what you're asking, the TeX community has a number of tools
for 2D drawing:
and of course, one can just use raw PostScript:
http://www.math.ubc.ca/~cass/graphics/manual/
There's also Nodebox and Processing or node.js or the various JavaScript
SVG libraries.
See
https://www.shapeoko.com/wiki/index.php/Programmatic_G-Code_Generators#Vector_graphic_languages
On Fri, Oct 20, 2017 at 7:06 AM, Troberg troberg.anders@gmail.com wrote:
I'd say that what I'm looking for is something like "script controlled
PaintShop", much like one could say that OpenSCAD is a "script controlled
SketchUp" (and don't nitpick that definition, I'm just trying to get a
general idea across here...).
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
The issue has to do with OpenSCAD's top-level union, which is automatically
applied. This means it can do 3D well, 2.5D with limitations (great as long
as the "D" are the same (e.g. a plate with holes and slots)), and is very
poor at 2D.
Let's say we want a cylinder, with a half-hollowed cylinder and an
axle-hole.
Here is the OpenSCAD code to create this shape (great if using a 3D
printer):
difference()
{
cylinder (d=50, h=20);
translate ([0, 0, 10]) cylinder (d=30, h=20);
cylinder (d=15, h=50, center=true);
}
http://forum.openscad.org/file/t486/1.png
The problem though, is that if you need a 2D end product (like a graphic),
or 2.5D (like CNC), all you get is the outermost shape.
for example
circle (d=50);
circle (d=30);
circle (d=15);
Only returns "circle (d=50)" since the others are contained in the bigger
circle.
http://forum.openscad.org/file/t486/2.png
To get the 3 2D concentric circles in OpenSCAD (that could be exported to 2D
outputs like DXF or SVG or PNG), you need to phrase it like:
difference()
{
circle (d=50);
circle (d=30);
}
circle (d=15);
http://forum.openscad.org/file/t486/3.png
This example would work for most 2.5D CNC programs, as it deals with
enclosed areas and shapes - however this technique breaks down in a hurry if
you are dealing with any shapes more complex than basic primitives or if you
are doing text, having the bit follow a single line, etc. If you needed
three concentric circles for a drawing (with no filled areas) (such as for a
graphic), you are out of luck.
Mostly out of luck, anyway. I have sometimes gotten away with extremely
thin shells:
module offsetShell()
{
difference()
{
children(0);
offset (r=-0.05) children(0);
}
}
offsetShell() circle (d=50);
offsetShell() circle (d=30);
offsetShell() circle (d=15);
http://forum.openscad.org/file/t486/4.png
In this case, the practical difference for most CNC applications is
negligible. I have also used extremely thin walls between features that
either break out from the bit or can be easily broken out by hand.
There has been talk of having a modifier that prevents top-level union in
OpenSCAD; this would enable OpenSCAD to do what you (and me, and many others
(since the topic crops up periodically)) are wanting to do - use OpenSCAD
for 2D artwork as well. This would allow one file to have all the
parameters for a project, even if it has 2D/2.5D/3D components. It also
would make OpenSCAD more useful for use with a laser cutter/CNC.
In the meantime, though, you might want to look at SVG programming in
Python. That would probably be the easiest route to get the output you need
parametrically; however it is not as interactive as modeling in OpenSCAD.
--
Sent from: http://forum.openscad.org/
The issue has to do with OpenSCAD's top-level union, which is automatically
applied. This means it can do 3D well, 2.5D with limitations (great as long
as the "D" are the same (e.g. a plate with holes and slots)), and is very
poor at 2D.
Let's say we want a cylinder, with a half-hollowed cylinder and an
axle-hole.
Here is the OpenSCAD code to create this shape (great if using a 3D
printer):
difference()
{
cylinder (d=50, h=20);
translate ([0, 0, 10]) cylinder (d=30, h=20);
cylinder (d=15, h=50, center=true);
}
http://forum.openscad.org/file/t486/1.png
The problem though, is that if you need a 2D end product (like a graphic),
or 2.5D (like CNC), all you get is the outermost shape.
for example
circle (d=50);
circle (d=30);
circle (d=15);
Only returns "circle (d=50)" since the others are contained in the bigger
circle.
http://forum.openscad.org/file/t486/2.png
To get the 3 2D concentric circles in OpenSCAD (that could be exported to 2D
outputs like DXF or SVG or PNG), you need to phrase it like:
difference()
{
circle (d=50);
circle (d=30);
}
circle (d=15);
http://forum.openscad.org/file/t486/3.png
This example would work for most 2.5D CNC programs, as it deals with
enclosed areas and shapes - however this technique breaks down in a hurry if
you are dealing with any shapes more complex than basic primitives or if you
are doing text, having the bit follow a single line, etc. If you needed
three concentric circles for a drawing (with no filled areas) (such as for a
graphic), you are out of luck.
Mostly out of luck, anyway. I have sometimes gotten away with extremely
thin shells:
module offsetShell()
{
difference()
{
children(0);
offset (r=-0.05) children(0);
}
}
offsetShell() circle (d=50);
offsetShell() circle (d=30);
offsetShell() circle (d=15);
http://forum.openscad.org/file/t486/4.png
In this case, the practical difference for most CNC applications is
negligible. I have also used extremely thin walls between features that
either break out from the bit or can be easily broken out by hand.
There has been talk of having a modifier that prevents top-level union in
OpenSCAD; this would enable OpenSCAD to do what you (and me, and many others
(since the topic crops up periodically)) are wanting to do - use OpenSCAD
for 2D artwork as well. This would allow one file to have all the
parameters for a project, even if it has 2D/2.5D/3D components. It also
would make OpenSCAD more useful for use with a laser cutter/CNC.
In the meantime, though, you might want to look at SVG programming in
Python. That would probably be the easiest route to get the output you need
parametrically; however it is not as interactive as modeling in OpenSCAD.
--
Sent from: http://forum.openscad.org/
or you could write a python extension for inkscape and then export to
openscad and extrude, or whatever...