Quantcast

Re: OpenSCAD DXF output?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: OpenSCAD DXF output?

Clifford Wolf
Hi Zach,

since I meanwhile have created the list I'm answering to the list quoting
your full mail. I hope this is fine with you..

On Mon, Nov 30, 2009 at 01:56:52PM -0500, Zach 'Hoeken' Smith wrote:

> I was wondering about something today...  would it be possible to
> output 2D dxf data from a 3D model in openscad?  For example, the
> makerbot design is all 2D DXF files which we need in order to actually
> get the part lasercut.  Right now we design in 2D, import into
> OpenSCAD to model it, and thats it.  However, I was thinking it would
> be really cool to be able to model the pieces in OpenSCAD directly,
> then export the 2D profile to DXF for lasercutting.  That way we could
> have parameterized MakerBot designs!  This would allow openscad to be
> a very powerful tool for making 3D objects with 2.5D fabrication
> technology like lasercutting, etc.

a 2d module is the next major thing that I want to implement in openscad.
philip and I are talking about it for over a month now and I have already a
pretty clear idea how to implement it..

there will be support for the following features:

1. pure 2d design: 2d primitives (like rectangle and circle) and csg
operations between them. like in the solid 3d designer the 2d object are not
lines but closed polygons with a clear definition of what is the inside and what
is the outside and an area greater than zero.

2. dxf import and export: it should be possible to import 2d designs from
DXf and export to dxf files.

3. interaction with 3d space: statements like dxf_extrude_linear and dxf_extrude_rotate
will enable the user to create 3d objects from 2d objects. additional
statements should allow conversion of 3d objects to 2d space either by intersecting
a 3d object with a plane or projecting a 3d object to a plane.

maybe I will find some time to implement this during the x-mas holidays.

yours,
 - clifford

--
there's no place like 127.0.0.1
until we found ::1 -- which is even bigger

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

scripted "export_stl"? (was Re: OpenSCAD DXF output?)

clothbot
Hi Clifford,

Zach's DXF output question reminded me of another related idea/request  
I had.

How easy would it be to add "export_stl" to the scripted  
capabilities?  I'd love to be able to do something like the attached  
example, where I algorithmically slice up a model, display the slice  
and write each slice to an STL file.

Once the infrastructure is there we could use OpenSCAD to "cube-up"  
really large designs into more fab-able volumes, algorithmically make  
3D puzzles from any STL source, etc.

Also, thinking of the 2D DXF export problem a little differently:  
lim(slice_width -> 0, STL Slice File) = 2D DXF File.

Andrew.





--

"The future is already here.  It's just not very evenly distributed"  
-- William Gibson




slice_export_stl.scad (802 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: scripted "export_stl"? (was Re: OpenSCAD DXF output?)

Zach Smith
both of those ideas are awesome (i particularly want the 2D dxf export....)

as for scriptable stl exporting, tis already there!  you can actually
call openscad from the command line....  you can pass parameters, an
output file, etc.  i'm not sure just exactly how fleshed out it is,
but i managed to get it to output an stl from the example files.

Zach

On Fri, Dec 4, 2009 at 10:20 AM, Andrew Plumb <[hidden email]> wrote:

> Hi Clifford,
>
> Zach's DXF output question reminded me of another related idea/request I
> had.
>
> How easy would it be to add "export_stl" to the scripted capabilities?  I'd
> love to be able to do something like the attached example, where I
> algorithmically slice up a model, display the slice and write each slice to
> an STL file.
>
> Once the infrastructure is there we could use OpenSCAD to "cube-up" really
> large designs into more fab-able volumes, algorithmically make 3D puzzles
> from any STL source, etc.
>
> Also, thinking of the 2D DXF export problem a little differently:
>  lim(slice_width -> 0, STL Slice File) = 2D DXF File.
>
> Andrew.
>
>
>
>
>
> --
>
> "The future is already here.  It's just not very evenly distributed" --
> William Gibson
>
>
>
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://rocklinux.net/mailman/listinfo/openscad
>
>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: scripted "export_stl"? (was Re: OpenSCAD DXF output?)

clothbot
Ah yes, forgot about the CLI options.  Adding a couple of conditional  
variables to trigger & control the slicer code should be easy enough.

A.

On 4-Dec-09, at 10:38 AM, Zach Smith wrote:

> both of those ideas are awesome (i particularly want the 2D dxf  
> export....)
>
> as for scriptable stl exporting, tis already there!  you can actually
> call openscad from the command line....  you can pass parameters, an
> output file, etc.  i'm not sure just exactly how fleshed out it is,
> but i managed to get it to output an stl from the example files.
>
> Zach
>
> On Fri, Dec 4, 2009 at 10:20 AM, Andrew Plumb <[hidden email]>  
> wrote:
>> Hi Clifford,
>>
>> Zach's DXF output question reminded me of another related idea/
>> request I
>> had.
>>
>> How easy would it be to add "export_stl" to the scripted  
>> capabilities?  I'd
>> love to be able to do something like the attached example, where I
>> algorithmically slice up a model, display the slice and write each  
>> slice to
>> an STL file.
>>
>> Once the infrastructure is there we could use OpenSCAD to "cube-up"  
>> really
>> large designs into more fab-able volumes, algorithmically make 3D  
>> puzzles
>> from any STL source, etc.
>>
>> Also, thinking of the 2D DXF export problem a little differently:
>>  lim(slice_width -> 0, STL Slice File) = 2D DXF File.
>>
>> Andrew.
>>
>>
>>
>>
>>
>> --
>>
>> "The future is already here.  It's just not very evenly  
>> distributed" --
>> William Gibson
>>
>>
>>
>>
>> _______________________________________________
>> OpenSCAD mailing list
>> [hidden email]
>> http://rocklinux.net/mailman/listinfo/openscad
>>
>>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://rocklinux.net/mailman/listinfo/openscad

--

"The future is already here.  It's just not very evenly distributed"  
-- William Gibson




Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: scripted "export_stl"? (was Re: OpenSCAD DXF output?)

Clifford Wolf
In reply to this post by clothbot
Hi Andrew,

On Fri, Dec 04, 2009 at 10:20:28AM -0500, Andrew Plumb wrote:
> Also, thinking of the 2D DXF export problem a little differently:  
> lim(slice_width -> 0, STL Slice File) = 2D DXF File.

this is basically how I plan to implement the "intersect with plane" 3d to
2d transformation.

but afaik CGAL doesn't support something like that directly. so the
algorithm I have in had would be something like that:

1. generate an "infinite" cube with the given plane as one side.
   (CGAL doesn't support infinite nef polyhydrons. so "infinite"
   would in fact just be "large enought to cover the whole scene".)

2. extract all facets that are in the plane. openscad is using the CGAL
   Gmpq math kernel - so whether a facet is in the plane is an exact
   problem and free of rounding errors.

3. project all 3d coordinates of the facets to the 2d coordinate space
   defined by the plane and create the resulting nef polygon.

the cuboid in step 1 could also be only "infinite" in two direction and
very thing in the third direcion. this doesn't change the result of the
algorithm and I'd simply profile the runtime of both alternatives to figure
out which one is better.

yours,
 - clifford

--
Caffeine for mind, pizza for body, sushi for soul.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: scripted "export_stl"? (was Re: OpenSCAD DXF output?)

Clifford Wolf
In reply to this post by Zach Smith
Hi Zach,

On Fri, Dec 04, 2009 at 10:38:31AM -0500, Zach Smith wrote:
> as for scriptable stl exporting, tis already there!  you can actually
> call openscad from the command line....  you can pass parameters, an
> output file, etc.  i'm not sure just exactly how fleshed out it is,
> but i managed to get it to output an stl from the example files.

it _should_ be complete in svn head.

there was one bug in the 2009.11 release regarding the 'automake' feature
that has been fixed in svn rev 139.

and there was another bug in the -D handling that I have fixed now (svn rev
143).

I think the whole feature set is still undocumented - so here's a simple
introduction to it:

openscad has the command line switch '-m' that can be used to specify a
command that can be used to generate yet not generated files.

Example: I have played a bit with Catarinas Helical Gears script [1] to
integrate it with my DXF generator for involute gears [2]. The results can
be found in my 'handicraft' svn repo:

        http://svn.clifford.at/handicraft/2009/heligears

in the scad file you can find the following statement:

        dxf_linear_extrude(file = str("invgear_n", numTeeth,
                "_m", (rootRad*2 + dedendum)/numTeeth, "_autogen.dxf"),
                convexity = 10, height = heightGear,
                twist = i[1]*angle/2, center = true);

as you can see, the filename used for the dxf extrusion is auto generated
to include all relevant data for my script.

there also is a Makefile with a rule to generate such DXF files:

        invgear_%_autogen.dxf: gearsgen.py
                python gearsgen.py -f $@ `echo $@ | sed 's,^invgear,,; s,\.00*_,_,g; s,_autogen.dxf$$,,; s,_, -,g;'`

so when you run openscad with a command line like:

        openscad -m make -s gears_helical.stl -D teethNum=15 gears_helical.scad

you won't get an error message because the dxf file isn't there. instead
openscad will call 'make' with the filename as argument and will then try
to open the dxf file a second time. the -D overwrites the value of teethNum
from the script, so this command generate a gear with 15 teeth.

happy hacking,
 - clifford

[1] http://www.thingiverse.com/thing:1339
[2] http://www.thingiverse.com/thing:829

--
An infinite number of mathematicians walk into a bar. The first one orders
a beer. The second orders half a beer. The third, a quarter of a beer. The
bartender says "You're all idiots", and pours two beers.

Loading...