discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

DXF to "3D-printable" lines with thickness

M
MathLover
Fri, Sep 8, 2017 2:56 PM

Hello all,

I am using OpenSCAD to make a wax seal, and I want to hand draw my emblem,
digitize it into lines in with LibreCAD using a drawing tablet, and then
have something I can 3D print and cast into a real seal.

Now OpenSCAD can read lines from DXF, but treats them as an outline. I
wanted line segments to be represented by, for example, cylinders. Lines
with thickness, so I can subtract them from a disc to make a simple wax
seal.

I wrote a little python program to do this. It reads a DXF file through
stdin, and outputs function calls with the endpoints of each line segment
found. You can supply a layer name to include only lines on that layer.
Optionally, you can also provide another function name that will be called
with the endpoints themselves, to provide better corners.

For example, the command:

Would read all lines on layer "CORPUS" and  produce something like:

Which you can include in an OpenSCAD script.

Examples for the modules called are:

I hope this is a useful addition to the OpenSCAD tool set.

You can download the tool from:
http://www.w-p.dds.nl/dxflines2scad_py.txt
(after download, rename it to "dxflines2scad.py")

--
Sent from: http://forum.openscad.org/

Hello all, I am using OpenSCAD to make a wax seal, and I want to hand draw my emblem, digitize it into lines in with LibreCAD using a drawing tablet, and then have something I can 3D print and cast into a real seal. Now OpenSCAD can read lines from DXF, but treats them as an outline. I wanted line segments to be represented by, for example, cylinders. Lines with thickness, so I can subtract them from a disc to make a simple wax seal. I wrote a little python program to do this. It reads a DXF file through stdin, and outputs function calls with the endpoints of each line segment found. You can supply a layer name to include only lines on that layer. Optionally, you can also provide another function name that will be called with the endpoints themselves, to provide better corners. For example, the command: Would read all lines on layer "CORPUS" and produce something like: Which you can include in an OpenSCAD script. Examples for the modules called are: I hope this is a useful addition to the OpenSCAD tool set. You can download the tool from: http://www.w-p.dds.nl/dxflines2scad_py.txt (after download, rename it to "dxflines2scad.py") -- Sent from: http://forum.openscad.org/
M
MathLover
Fri, Sep 8, 2017 3:02 PM

Huh? What happened to all the "raw" texts that were perfectly visible in the
preview screen?

Let's post his message again:

I am using OpenSCAD to make a wax seal, and I want to hand draw my emblem,
digitize it into lines in with LibreCAD using a drawing tablet, and then
have something I can 3D print and cast into a real seal.

Now OpenSCAD can read lines from DXF, but treats them as an outline. I
wanted line segments to be represented by, for example, cylinders. Lines
with thickness, so I can subtract them from a disc to make a simple wax
seal.

I wrote a little python program to do this. It reads a DXF file through
stdin, and outputs function calls with the endpoints of each line segment
found. You can supply a layer name to include only lines on that layer.
Optionally, you can also provide another function name that will be called
with the endpoints themselves, to provide better corners.

For example, the command:

./dxflines2scad.py -l CORPUS -n draw_point -c 'Warning! Generated file. Do
not edit.' < ../deksels.dxf

Would read all lines on layer "CORPUS" and  produce something like:
//  Warning! Generated file. Do not edit.
line_segment([19.0, 13.0, 0], [16.75, 13.0, 0]); // DXF handle "C9"
line_segment([16.75, 4.0, 0], [16.75, 6.0, 0]); // DXF handle "CB"
line_segment([16.75, 4.0, 0], [3.0, 4.0, 0]); // DXF handle "CC"
...
draw_point([19.0, 13.0, 0]);
draw_point([16.75, 13.0, 0]);
draw_point([16.75, 4.0, 0]);
draw_point([16.75, 6.0, 0]);
...

Which you can include in an OpenSCAD script.

Examples for the modules called are:

module line_segment(vecFrom, vecTo)
{fltLength = norm(vecTo - vecFrom);
translate(vecFrom)
{rotate([0, 0, atan2(vecTo[1]-vecFrom[1],
vecTo[0]-vecFrom[0])])
{rotate([0, 90, 0])
{cylinder(h=fltLength, r=0.5);}
}
}
}
module draw_point(node)
{translate(node)
{sphere(0.75, center=true);}
}

I hope this is a useful addition to the OpenSCAD tool set.

You can download the tool from:
http://www.w-p.dds.nl/dxflines2scad_py.txt
(after download, rename it to "dxflines2scad.py")

--
Sent from: http://forum.openscad.org/

Huh? What happened to all the "raw" texts that were perfectly visible in the preview screen? Let's post his message again: I am using OpenSCAD to make a wax seal, and I want to hand draw my emblem, digitize it into lines in with LibreCAD using a drawing tablet, and then have something I can 3D print and cast into a real seal. Now OpenSCAD can read lines from DXF, but treats them as an outline. I wanted line segments to be represented by, for example, cylinders. Lines with thickness, so I can subtract them from a disc to make a simple wax seal. I wrote a little python program to do this. It reads a DXF file through stdin, and outputs function calls with the endpoints of each line segment found. You can supply a layer name to include only lines on that layer. Optionally, you can also provide another function name that will be called with the endpoints themselves, to provide better corners. For example, the command: ./dxflines2scad.py -l CORPUS -n draw_point -c 'Warning! Generated file. Do not edit.' < ../deksels.dxf Would read all lines on layer "CORPUS" and produce something like: // Warning! Generated file. Do not edit. line_segment([19.0, 13.0, 0], [16.75, 13.0, 0]); // DXF handle "C9" line_segment([16.75, 4.0, 0], [16.75, 6.0, 0]); // DXF handle "CB" line_segment([16.75, 4.0, 0], [3.0, 4.0, 0]); // DXF handle "CC" ... draw_point([19.0, 13.0, 0]); draw_point([16.75, 13.0, 0]); draw_point([16.75, 4.0, 0]); draw_point([16.75, 6.0, 0]); ... Which you can include in an OpenSCAD script. Examples for the modules called are: module line_segment(vecFrom, vecTo) {fltLength = norm(vecTo - vecFrom); translate(vecFrom) {rotate([0, 0, atan2(vecTo[1]-vecFrom[1], vecTo[0]-vecFrom[0])]) {rotate([0, 90, 0]) {cylinder(h=fltLength, r=0.5);} } } } module draw_point(node) {translate(node) {sphere(0.75, center=true);} } I hope this is a useful addition to the OpenSCAD tool set. You can download the tool from: http://www.w-p.dds.nl/dxflines2scad_py.txt (after download, rename it to "dxflines2scad.py") -- Sent from: http://forum.openscad.org/
MC
Mr C Camacho
Fri, Sep 8, 2017 3:32 PM

wouldn't it be easier just to use surface

https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_Language_Features#Surface

I made some great paper embossing stamps with this method (niece and
nephews seemed to like them!) ...

On 08/09/17 16:02, MathLover wrote:

Huh? What happened to all the "raw" texts that were perfectly visible in the
preview screen?

Let's post his message again:

I am using OpenSCAD to make a wax seal, and I want to hand draw my emblem,
digitize it into lines in with LibreCAD using a drawing tablet, and then
have something I can 3D print and cast into a real seal.

Now OpenSCAD can read lines from DXF, but treats them as an outline. I
wanted line segments to be represented by, for example, cylinders. Lines
with thickness, so I can subtract them from a disc to make a simple wax
seal.

I wrote a little python program to do this. It reads a DXF file through
stdin, and outputs function calls with the endpoints of each line segment
found. You can supply a layer name to include only lines on that layer.
Optionally, you can also provide another function name that will be called
with the endpoints themselves, to provide better corners.

For example, the command:

./dxflines2scad.py -l CORPUS -n draw_point -c 'Warning! Generated file. Do
not edit.' < ../deksels.dxf

Would read all lines on layer "CORPUS" and  produce something like:
//  Warning! Generated file. Do not edit.
line_segment([19.0, 13.0, 0], [16.75, 13.0, 0]); // DXF handle "C9"
line_segment([16.75, 4.0, 0], [16.75, 6.0, 0]); // DXF handle "CB"
line_segment([16.75, 4.0, 0], [3.0, 4.0, 0]); // DXF handle "CC"
...
draw_point([19.0, 13.0, 0]);
draw_point([16.75, 13.0, 0]);
draw_point([16.75, 4.0, 0]);
draw_point([16.75, 6.0, 0]);
...

Which you can include in an OpenSCAD script.

Examples for the modules called are:

module line_segment(vecFrom, vecTo)
{fltLength = norm(vecTo - vecFrom);
translate(vecFrom)
{rotate([0, 0, atan2(vecTo[1]-vecFrom[1],
vecTo[0]-vecFrom[0])])
{rotate([0, 90, 0])
{cylinder(h=fltLength, r=0.5);}
}
}
}
module draw_point(node)
{translate(node)
{sphere(0.75, center=true);}
}

I hope this is a useful addition to the OpenSCAD tool set.

You can download the tool from:
http://www.w-p.dds.nl/dxflines2scad_py.txt
(after download, rename it to "dxflines2scad.py")

--
Sent from: http://forum.openscad.org/


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

wouldn't it be easier just to use surface https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_Language_Features#Surface I made some great paper embossing stamps with this method (niece and nephews seemed to like them!) ... On 08/09/17 16:02, MathLover wrote: > Huh? What happened to all the "raw" texts that were perfectly visible in the > preview screen? > > Let's post his message again: > > I am using OpenSCAD to make a wax seal, and I want to hand draw my emblem, > digitize it into lines in with LibreCAD using a drawing tablet, and then > have something I can 3D print and cast into a real seal. > > Now OpenSCAD can read lines from DXF, but treats them as an outline. I > wanted line segments to be represented by, for example, cylinders. Lines > with thickness, so I can subtract them from a disc to make a simple wax > seal. > > I wrote a little python program to do this. It reads a DXF file through > stdin, and outputs function calls with the endpoints of each line segment > found. You can supply a layer name to include only lines on that layer. > Optionally, you can also provide another function name that will be called > with the endpoints themselves, to provide better corners. > > For example, the command: > > ./dxflines2scad.py -l CORPUS -n draw_point -c 'Warning! Generated file. Do > not edit.' < ../deksels.dxf > > Would read all lines on layer "CORPUS" and produce something like: > // Warning! Generated file. Do not edit. > line_segment([19.0, 13.0, 0], [16.75, 13.0, 0]); // DXF handle "C9" > line_segment([16.75, 4.0, 0], [16.75, 6.0, 0]); // DXF handle "CB" > line_segment([16.75, 4.0, 0], [3.0, 4.0, 0]); // DXF handle "CC" > ... > draw_point([19.0, 13.0, 0]); > draw_point([16.75, 13.0, 0]); > draw_point([16.75, 4.0, 0]); > draw_point([16.75, 6.0, 0]); > ... > > > Which you can include in an OpenSCAD script. > > Examples for the modules called are: > > module line_segment(vecFrom, vecTo) > {fltLength = norm(vecTo - vecFrom); > translate(vecFrom) > {rotate([0, 0, atan2(vecTo[1]-vecFrom[1], > vecTo[0]-vecFrom[0])]) > {rotate([0, 90, 0]) > {cylinder(h=fltLength, r=0.5);} > } > } > } > module draw_point(node) > {translate(node) > {sphere(0.75, center=true);} > } > > > I hope this is a useful addition to the OpenSCAD tool set. > > You can download the tool from: > http://www.w-p.dds.nl/dxflines2scad_py.txt > (after download, rename it to "dxflines2scad.py") > > > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
MS
Mark Schafer
Fri, Sep 8, 2017 10:45 PM

nice script. Also consider the inkscape extension that exports as openscad:

Inkscape has a raster to vector tool called "Trace Bitmap" under Path
menu item

On 9/9/2017 3:32 AM, Mr C Camacho wrote:

wouldn't it be easier just to use surface

https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_Language_Features#Surface

I made some great paper embossing stamps with this method (niece and
nephews seemed to like them!) ...

On 08/09/17 16:02, MathLover wrote:

Huh? What happened to all the "raw" texts that were perfectly visible
in the
preview screen?

Let's post his message again:

I am using OpenSCAD to make a wax seal, and I want to hand draw my
emblem,
digitize it into lines in with LibreCAD using a drawing tablet, and then
have something I can 3D print and cast into a real seal.

Now OpenSCAD can read lines from DXF, but treats them as an outline. I
wanted line segments to be represented by, for example, cylinders. Lines
with thickness, so I can subtract them from a disc to make a simple wax
seal.

I wrote a little python program to do this. It reads a DXF file through
stdin, and outputs function calls with the endpoints of each line
segment
found. You can supply a layer name to include only lines on that layer.
Optionally, you can also provide another function name that will be
called
with the endpoints themselves, to provide better corners.

For example, the command:

./dxflines2scad.py -l CORPUS -n draw_point -c 'Warning! Generated
file. Do
not edit.' < ../deksels.dxf

Would read all lines on layer "CORPUS" and  produce something like:
//  Warning! Generated file. Do not edit.
line_segment([19.0, 13.0, 0], [16.75, 13.0, 0]); // DXF handle "C9"
line_segment([16.75, 4.0, 0], [16.75, 6.0, 0]); // DXF handle "CB"
line_segment([16.75, 4.0, 0], [3.0, 4.0, 0]); // DXF handle "CC"
...
draw_point([19.0, 13.0, 0]);
draw_point([16.75, 13.0, 0]);
draw_point([16.75, 4.0, 0]);
draw_point([16.75, 6.0, 0]);
...

Which you can include in an OpenSCAD script.

Examples for the modules called are:

module line_segment(vecFrom, vecTo)
{fltLength = norm(vecTo - vecFrom);
translate(vecFrom)
{rotate([0, 0, atan2(vecTo[1]-vecFrom[1],
vecTo[0]-vecFrom[0])])
{rotate([0, 90, 0])
{cylinder(h=fltLength, r=0.5);}
}
}
}
module draw_point(node)
{translate(node)
{sphere(0.75, center=true);}
}

I hope this is a useful addition to the OpenSCAD tool set.

You can download the tool from:
http://www.w-p.dds.nl/dxflines2scad_py.txt
(after download, rename it to "dxflines2scad.py")

--
Sent from: http://forum.openscad.org/


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

nice script. Also consider the inkscape extension that exports as openscad: - https://www.thingiverse.com/thing:1065500 Inkscape has a raster to vector tool called "Trace Bitmap" under Path menu item On 9/9/2017 3:32 AM, Mr C Camacho wrote: > wouldn't it be easier just to use surface > > https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_Language_Features#Surface > > > I made some great paper embossing stamps with this method (niece and > nephews seemed to like them!) ... > > On 08/09/17 16:02, MathLover wrote: >> Huh? What happened to all the "raw" texts that were perfectly visible >> in the >> preview screen? >> >> Let's post his message again: >> >> I am using OpenSCAD to make a wax seal, and I want to hand draw my >> emblem, >> digitize it into lines in with LibreCAD using a drawing tablet, and then >> have something I can 3D print and cast into a real seal. >> >> Now OpenSCAD can read lines from DXF, but treats them as an outline. I >> wanted line segments to be represented by, for example, cylinders. Lines >> with thickness, so I can subtract them from a disc to make a simple wax >> seal. >> >> I wrote a little python program to do this. It reads a DXF file through >> stdin, and outputs function calls with the endpoints of each line >> segment >> found. You can supply a layer name to include only lines on that layer. >> Optionally, you can also provide another function name that will be >> called >> with the endpoints themselves, to provide better corners. >> >> For example, the command: >> >> ./dxflines2scad.py -l CORPUS -n draw_point -c 'Warning! Generated >> file. Do >> not edit.' < ../deksels.dxf >> >> Would read all lines on layer "CORPUS" and produce something like: >> // Warning! Generated file. Do not edit. >> line_segment([19.0, 13.0, 0], [16.75, 13.0, 0]); // DXF handle "C9" >> line_segment([16.75, 4.0, 0], [16.75, 6.0, 0]); // DXF handle "CB" >> line_segment([16.75, 4.0, 0], [3.0, 4.0, 0]); // DXF handle "CC" >> ... >> draw_point([19.0, 13.0, 0]); >> draw_point([16.75, 13.0, 0]); >> draw_point([16.75, 4.0, 0]); >> draw_point([16.75, 6.0, 0]); >> ... >> >> >> Which you can include in an OpenSCAD script. >> >> Examples for the modules called are: >> >> module line_segment(vecFrom, vecTo) >> {fltLength = norm(vecTo - vecFrom); >> translate(vecFrom) >> {rotate([0, 0, atan2(vecTo[1]-vecFrom[1], >> vecTo[0]-vecFrom[0])]) >> {rotate([0, 90, 0]) >> {cylinder(h=fltLength, r=0.5);} >> } >> } >> } >> module draw_point(node) >> {translate(node) >> {sphere(0.75, center=true);} >> } >> >> >> I hope this is a useful addition to the OpenSCAD tool set. >> >> You can download the tool from: >> http://www.w-p.dds.nl/dxflines2scad_py.txt >> (after download, rename it to "dxflines2scad.py") >> >> >> >> -- >> Sent from: http://forum.openscad.org/ >> >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@lists.openscad.org >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > > --- > This email has been checked for viruses by AVG. > http://www.avg.com > >
NH
nop head
Sat, Sep 9, 2017 10:17 AM

You can also convert 2D shapes to their outline by subtracting an offset
version of themselves. E.g.

module outline(width) difference() {
offset(width / 2) children();
offset(-width / 2) children();
}

outline(1) import("shape.dxf");

On 8 September 2017 at 23:45, Mark Schafer mschafer@wireframe.biz wrote:

nice script. Also consider the inkscape extension that exports as openscad:

Inkscape has a raster to vector tool called "Trace Bitmap" under Path menu
item

On 9/9/2017 3:32 AM, Mr C Camacho wrote:

wouldn't it be easier just to use surface

https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_Lan
guage_Features#Surface

I made some great paper embossing stamps with this method (niece and
nephews seemed to like them!) ...

On 08/09/17 16:02, MathLover wrote:

Huh? What happened to all the "raw" texts that were perfectly visible in
the
preview screen?

Let's post his message again:

I am using OpenSCAD to make a wax seal, and I want to hand draw my
emblem,
digitize it into lines in with LibreCAD using a drawing tablet, and then
have something I can 3D print and cast into a real seal.

Now OpenSCAD can read lines from DXF, but treats them as an outline. I
wanted line segments to be represented by, for example, cylinders. Lines
with thickness, so I can subtract them from a disc to make a simple wax
seal.

I wrote a little python program to do this. It reads a DXF file through
stdin, and outputs function calls with the endpoints of each line segment
found. You can supply a layer name to include only lines on that layer.
Optionally, you can also provide another function name that will be
called
with the endpoints themselves, to provide better corners.

For example, the command:

./dxflines2scad.py -l CORPUS -n draw_point -c 'Warning! Generated file.
Do
not edit.' < ../deksels.dxf

Would read all lines on layer "CORPUS" and  produce something like:
//  Warning! Generated file. Do not edit.
line_segment([19.0, 13.0, 0], [16.75, 13.0, 0]); // DXF handle "C9"
line_segment([16.75, 4.0, 0], [16.75, 6.0, 0]); // DXF handle "CB"
line_segment([16.75, 4.0, 0], [3.0, 4.0, 0]); // DXF handle "CC"
...
draw_point([19.0, 13.0, 0]);
draw_point([16.75, 13.0, 0]);
draw_point([16.75, 4.0, 0]);
draw_point([16.75, 6.0, 0]);
...

Which you can include in an OpenSCAD script.

Examples for the modules called are:

module line_segment(vecFrom, vecTo)
{fltLength = norm(vecTo - vecFrom);
translate(vecFrom)
{rotate([0, 0, atan2(vecTo[1]-vecFrom[1],
vecTo[0]-vecFrom[0])])
{rotate([0, 90, 0])
{cylinder(h=fltLength, r=0.5);}
}
}
}
module draw_point(node)
{translate(node)
{sphere(0.75, center=true);}
}

I hope this is a useful addition to the OpenSCAD tool set.

You can download the tool from:
http://www.w-p.dds.nl/dxflines2scad_py.txt
(after download, rename it to "dxflines2scad.py")

--
Sent from: http://forum.openscad.org/


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

You can also convert 2D shapes to their outline by subtracting an offset version of themselves. E.g. module outline(width) difference() { offset(width / 2) children(); offset(-width / 2) children(); } outline(1) import("shape.dxf"); On 8 September 2017 at 23:45, Mark Schafer <mschafer@wireframe.biz> wrote: > nice script. Also consider the inkscape extension that exports as openscad: > > - https://www.thingiverse.com/thing:1065500 > > Inkscape has a raster to vector tool called "Trace Bitmap" under Path menu > item > > > > On 9/9/2017 3:32 AM, Mr C Camacho wrote: > >> wouldn't it be easier just to use surface >> >> https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_Lan >> guage_Features#Surface >> >> I made some great paper embossing stamps with this method (niece and >> nephews seemed to like them!) ... >> >> On 08/09/17 16:02, MathLover wrote: >> >>> Huh? What happened to all the "raw" texts that were perfectly visible in >>> the >>> preview screen? >>> >>> Let's post his message again: >>> >>> I am using OpenSCAD to make a wax seal, and I want to hand draw my >>> emblem, >>> digitize it into lines in with LibreCAD using a drawing tablet, and then >>> have something I can 3D print and cast into a real seal. >>> >>> Now OpenSCAD can read lines from DXF, but treats them as an outline. I >>> wanted line segments to be represented by, for example, cylinders. Lines >>> with thickness, so I can subtract them from a disc to make a simple wax >>> seal. >>> >>> I wrote a little python program to do this. It reads a DXF file through >>> stdin, and outputs function calls with the endpoints of each line segment >>> found. You can supply a layer name to include only lines on that layer. >>> Optionally, you can also provide another function name that will be >>> called >>> with the endpoints themselves, to provide better corners. >>> >>> For example, the command: >>> >>> ./dxflines2scad.py -l CORPUS -n draw_point -c 'Warning! Generated file. >>> Do >>> not edit.' < ../deksels.dxf >>> >>> Would read all lines on layer "CORPUS" and produce something like: >>> // Warning! Generated file. Do not edit. >>> line_segment([19.0, 13.0, 0], [16.75, 13.0, 0]); // DXF handle "C9" >>> line_segment([16.75, 4.0, 0], [16.75, 6.0, 0]); // DXF handle "CB" >>> line_segment([16.75, 4.0, 0], [3.0, 4.0, 0]); // DXF handle "CC" >>> ... >>> draw_point([19.0, 13.0, 0]); >>> draw_point([16.75, 13.0, 0]); >>> draw_point([16.75, 4.0, 0]); >>> draw_point([16.75, 6.0, 0]); >>> ... >>> >>> >>> Which you can include in an OpenSCAD script. >>> >>> Examples for the modules called are: >>> >>> module line_segment(vecFrom, vecTo) >>> {fltLength = norm(vecTo - vecFrom); >>> translate(vecFrom) >>> {rotate([0, 0, atan2(vecTo[1]-vecFrom[1], >>> vecTo[0]-vecFrom[0])]) >>> {rotate([0, 90, 0]) >>> {cylinder(h=fltLength, r=0.5);} >>> } >>> } >>> } >>> module draw_point(node) >>> {translate(node) >>> {sphere(0.75, center=true);} >>> } >>> >>> >>> I hope this is a useful addition to the OpenSCAD tool set. >>> >>> You can download the tool from: >>> http://www.w-p.dds.nl/dxflines2scad_py.txt >>> (after download, rename it to "dxflines2scad.py") >>> >>> >>> >>> -- >>> Sent from: http://forum.openscad.org/ >>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> Discuss@lists.openscad.org >>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >>> >> >> >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@lists.openscad.org >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> >> --- >> This email has been checked for viruses by AVG. >> http://www.avg.com >> >> >> > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
MC
Mr C Camacho
Sat, Sep 9, 2017 11:14 AM

nice tip, simple and useful, thanks

On 09/09/17 11:17, nop head wrote:

You can also convert 2D shapes to their outline by subtracting an
offset version of themselves. E.g.

module outline(width) difference() {
    offset(width / 2) children();
    offset(-width / 2) children();
}

outline(1) import("shape.dxf");

On 8 September 2017 at 23:45, Mark Schafer <mschafer@wireframe.biz
mailto:mschafer@wireframe.biz> wrote:

 nice script. Also consider the inkscape extension that exports as
 openscad:

 - https://www.thingiverse.com/thing:1065500
 <https://www.thingiverse.com/thing:1065500>

 Inkscape has a raster to vector tool called "Trace Bitmap" under
 Path menu item



 On 9/9/2017 3:32 AM, Mr C Camacho wrote:

     wouldn't it be easier just to use surface

     https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_Language_Features#Surface
     <https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_Language_Features#Surface>


     I made some great paper embossing stamps with this method
     (niece and nephews seemed to like them!) ...

     On 08/09/17 16:02, MathLover wrote:

         Huh? What happened to all the "raw" texts that were
         perfectly visible in the
         preview screen?

         Let's post his message again:

         I am using OpenSCAD to make a wax seal, and I want to hand
         draw my emblem,
         digitize it into lines in with LibreCAD using a drawing
         tablet, and then
         have something I can 3D print and cast into a real seal.

         Now OpenSCAD can read lines from DXF, but treats them as
         an outline. I
         wanted line segments to be represented by, for example,
         cylinders. Lines
         with thickness, so I can subtract them from a disc to make
         a simple wax
         seal.

         I wrote a little python program to do this. It reads a DXF
         file through
         stdin, and outputs function calls with the endpoints of
         each line segment
         found. You can supply a layer name to include only lines
         on that layer.
         Optionally, you can also provide another function name
         that will be called
         with the endpoints themselves, to provide better corners.

         For example, the command:

         ./dxflines2scad.py -l CORPUS -n draw_point -c 'Warning!
         Generated file. Do
         not edit.' < ../deksels.dxf

         Would read all lines on layer "CORPUS" and  produce
         something like:
         //  Warning! Generated file. Do not edit.
         line_segment([19.0, 13.0, 0], [16.75, 13.0, 0]); // DXF
         handle "C9"
         line_segment([16.75, 4.0, 0], [16.75, 6.0, 0]); // DXF
         handle "CB"
         line_segment([16.75, 4.0, 0], [3.0, 4.0, 0]); // DXF
         handle "CC"
         ...
         draw_point([19.0, 13.0, 0]);
         draw_point([16.75, 13.0, 0]);
         draw_point([16.75, 4.0, 0]);
         draw_point([16.75, 6.0, 0]);
         ...


         Which you can include in an OpenSCAD script.

         Examples for the modules called are:

         module line_segment(vecFrom, vecTo)
                {fltLength = norm(vecTo - vecFrom);
                 translate(vecFrom)
                          {rotate([0, 0, atan2(vecTo[1]-vecFrom[1],
         vecTo[0]-vecFrom[0])])
                                 {rotate([0, 90, 0])
          {cylinder(h=fltLength, r=0.5);}
                                 }
                          }
                }
         module draw_point(node)
                {translate(node)
                          {sphere(0.75, center=true);}
                }


         I hope this is a useful addition to the OpenSCAD tool set.

         You can download the tool from:
         http://www.w-p.dds.nl/dxflines2scad_py.txt
         <http://www.w-p.dds.nl/dxflines2scad_py.txt>
         (after download, rename it to "dxflines2scad.py")



         -- 
         Sent from: http://forum.openscad.org/

         _______________________________________________
         OpenSCAD mailing list
         Discuss@lists.openscad.org <mailto:Discuss@lists.openscad.org>
         http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
         <http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org>



     _______________________________________________
     OpenSCAD mailing list
     Discuss@lists.openscad.org <mailto:Discuss@lists.openscad.org>
     http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
     <http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org>

     ---
     This email has been checked for viruses by AVG.
     http://www.avg.com




 _______________________________________________
 OpenSCAD mailing list
 Discuss@lists.openscad.org <mailto:Discuss@lists.openscad.org>
 http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
 <http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org>

OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

nice tip, simple and useful, thanks On 09/09/17 11:17, nop head wrote: > You can also convert 2D shapes to their outline by subtracting an > offset version of themselves. E.g. > > module outline(width) difference() { >     offset(width / 2) children(); >     offset(-width / 2) children(); > } > > outline(1) import("shape.dxf"); > > On 8 September 2017 at 23:45, Mark Schafer <mschafer@wireframe.biz > <mailto:mschafer@wireframe.biz>> wrote: > > nice script. Also consider the inkscape extension that exports as > openscad: > > - https://www.thingiverse.com/thing:1065500 > <https://www.thingiverse.com/thing:1065500> > > Inkscape has a raster to vector tool called "Trace Bitmap" under > Path menu item > > > > On 9/9/2017 3:32 AM, Mr C Camacho wrote: > > wouldn't it be easier just to use surface > > https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_Language_Features#Surface > <https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_Language_Features#Surface> > > > I made some great paper embossing stamps with this method > (niece and nephews seemed to like them!) ... > > On 08/09/17 16:02, MathLover wrote: > > Huh? What happened to all the "raw" texts that were > perfectly visible in the > preview screen? > > Let's post his message again: > > I am using OpenSCAD to make a wax seal, and I want to hand > draw my emblem, > digitize it into lines in with LibreCAD using a drawing > tablet, and then > have something I can 3D print and cast into a real seal. > > Now OpenSCAD can read lines from DXF, but treats them as > an outline. I > wanted line segments to be represented by, for example, > cylinders. Lines > with thickness, so I can subtract them from a disc to make > a simple wax > seal. > > I wrote a little python program to do this. It reads a DXF > file through > stdin, and outputs function calls with the endpoints of > each line segment > found. You can supply a layer name to include only lines > on that layer. > Optionally, you can also provide another function name > that will be called > with the endpoints themselves, to provide better corners. > > For example, the command: > > ./dxflines2scad.py -l CORPUS -n draw_point -c 'Warning! > Generated file. Do > not edit.' < ../deksels.dxf > > Would read all lines on layer "CORPUS" and  produce > something like: > //  Warning! Generated file. Do not edit. > line_segment([19.0, 13.0, 0], [16.75, 13.0, 0]); // DXF > handle "C9" > line_segment([16.75, 4.0, 0], [16.75, 6.0, 0]); // DXF > handle "CB" > line_segment([16.75, 4.0, 0], [3.0, 4.0, 0]); // DXF > handle "CC" > ... > draw_point([19.0, 13.0, 0]); > draw_point([16.75, 13.0, 0]); > draw_point([16.75, 4.0, 0]); > draw_point([16.75, 6.0, 0]); > ... > > > Which you can include in an OpenSCAD script. > > Examples for the modules called are: > > module line_segment(vecFrom, vecTo) >        {fltLength = norm(vecTo - vecFrom); >         translate(vecFrom) >                  {rotate([0, 0, atan2(vecTo[1]-vecFrom[1], > vecTo[0]-vecFrom[0])]) >                         {rotate([0, 90, 0]) >  {cylinder(h=fltLength, r=0.5);} >                         } >                  } >        } > module draw_point(node) >        {translate(node) >                  {sphere(0.75, center=true);} >        } > > > I hope this is a useful addition to the OpenSCAD tool set. > > You can download the tool from: > http://www.w-p.dds.nl/dxflines2scad_py.txt > <http://www.w-p.dds.nl/dxflines2scad_py.txt> > (after download, rename it to "dxflines2scad.py") > > > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org <mailto:Discuss@lists.openscad.org> > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > <http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org> > > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org <mailto:Discuss@lists.openscad.org> > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > <http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org> > > --- > This email has been checked for viruses by AVG. > http://www.avg.com > > > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org <mailto:Discuss@lists.openscad.org> > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > <http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org> > > > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org