discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

working on color export SVG.

JD
John David
Wed, Apr 23, 2025 10:35 AM

I was looking at a couple of different ways to crack this nut, and stumbled
across
mickvav's pull request from 2016 <
https://github.com/openscad/openscad/compare/master...mickvav:openscad:svg-colors>.
I was trying to reimplement this in the current master branch, but got
stuck on how to deal with the EvalContexts.

Anyway, I thought I would ask if anyone could give me a pointer on what
this might have turned into over the last 10 years, and I will give a stab
at reimplementing the functionality.

Off for a nap...

EBo --

I was looking at a couple of different ways to crack this nut, and stumbled across mickvav's pull request from 2016 < https://github.com/openscad/openscad/compare/master...mickvav:openscad:svg-colors>. I was trying to reimplement this in the current master branch, but got stuck on how to deal with the EvalContexts. Anyway, I thought I would ask if anyone could give me a pointer on what this might have turned into over the last 10 years, and I will give a stab at reimplementing the functionality. Off for a nap... EBo --
GS
Guenther Sohler
Wed, Apr 23, 2025 11:13 AM

Don't focus on the EvalContexts. It appears they are only used for the
ExportModule and its unlikely that the export() will be merged.

On Wed, Apr 23, 2025 at 12:35 PM John David via Discuss <
discuss@lists.openscad.org> wrote:

I was looking at a couple of different ways to crack this nut, and
stumbled across
mickvav's pull request from 2016 <
https://github.com/openscad/openscad/compare/master...mickvav:openscad:svg-colors>.
I was trying to reimplement this in the current master branch, but got
stuck on how to deal with the EvalContexts.

Anyway, I thought I would ask if anyone could give me a pointer on what
this might have turned into over the last 10 years, and I will give a stab
at reimplementing the functionality.

Off for a nap...

EBo --


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

Don't focus on the EvalContexts. It appears they are only used for the ExportModule and its unlikely that the export() will be merged. On Wed, Apr 23, 2025 at 12:35 PM John David via Discuss < discuss@lists.openscad.org> wrote: > I was looking at a couple of different ways to crack this nut, and > stumbled across > mickvav's pull request from 2016 < > https://github.com/openscad/openscad/compare/master...mickvav:openscad:svg-colors>. > I was trying to reimplement this in the current master branch, but got > stuck on how to deal with the EvalContexts. > > Anyway, I thought I would ask if anyone could give me a pointer on what > this might have turned into over the last 10 years, and I will give a stab > at reimplementing the functionality. > > Off for a nap... > > EBo -- > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
JD
John David
Wed, Apr 23, 2025 11:27 AM

I took a few minutes and looked at RenderNode.cc and ImportNode.cc to
inform how they built the builtin modules.  Instead of the EvalContexts, it
appears that they build it from the Arguments.  I'll probably take another
poke or two later.  Hope I can figure it out in the time I have.  It would
make it SO much easier for laser cutting...

EBo --

On Wed, Apr 23, 2025 at 7:13 AM Guenther Sohler via Discuss <
discuss@lists.openscad.org> wrote:

Don't focus on the EvalContexts. It appears they are only used for the
ExportModule and its unlikely that the export() will be merged.

On Wed, Apr 23, 2025 at 12:35 PM John David via Discuss <
discuss@lists.openscad.org> wrote:

I was looking at a couple of different ways to crack this nut, and
stumbled across
mickvav's pull request from 2016 <
https://github.com/openscad/openscad/compare/master...mickvav:openscad:svg-colors>.
I was trying to reimplement this in the current master branch, but got
stuck on how to deal with the EvalContexts.

Anyway, I thought I would ask if anyone could give me a pointer on what
this might have turned into over the last 10 years, and I will give a stab
at reimplementing the functionality.

Off for a nap...

EBo --


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

I took a few minutes and looked at RenderNode.cc and ImportNode.cc to inform how they built the builtin modules. Instead of the EvalContexts, it appears that they build it from the Arguments. I'll probably take another poke or two later. Hope I can figure it out in the time I have. It would make it SO much easier for laser cutting... EBo -- On Wed, Apr 23, 2025 at 7:13 AM Guenther Sohler via Discuss < discuss@lists.openscad.org> wrote: > Don't focus on the EvalContexts. It appears they are only used for the > ExportModule and its unlikely that the export() will be merged. > > > On Wed, Apr 23, 2025 at 12:35 PM John David via Discuss < > discuss@lists.openscad.org> wrote: > >> I was looking at a couple of different ways to crack this nut, and >> stumbled across >> mickvav's pull request from 2016 < >> https://github.com/openscad/openscad/compare/master...mickvav:openscad:svg-colors>. >> I was trying to reimplement this in the current master branch, but got >> stuck on how to deal with the EvalContexts. >> >> Anyway, I thought I would ask if anyone could give me a pointer on what >> this might have turned into over the last 10 years, and I will give a stab >> at reimplementing the functionality. >> >> Off for a nap... >> >> EBo -- >> _______________________________________________ >> 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 >
TP
Torsten Paul
Wed, Apr 23, 2025 12:27 PM

On 23.04.25 12:35, John David via Discuss wrote:

Anyway, I thought I would ask if anyone could give me a pointer on what
this might have turned into over the last 10 years, and I will give a
stab at reimplementing the functionality.

What is that functionality exactly?

Note that someone is working on extended setup for PDF
https://github.com/openscad/openscad/pull/5845
and expressed interest in doing the same for SVG as well.

ciao,
Torsten.

On 23.04.25 12:35, John David via Discuss wrote: > Anyway, I thought I would ask if anyone could give me a pointer on what > this might have turned into over the last 10 years, and I will give a > stab at reimplementing the functionality. What is that functionality exactly? Note that someone is working on extended setup for PDF https://github.com/openscad/openscad/pull/5845 and expressed interest in doing the same for SVG as well. ciao, Torsten.
WF
William F. Adams
Wed, Apr 23, 2025 12:43 PM

All of this makes me wonder if it wouldn't be better to just wrap up an existing 2D tool?

I've been looking at re-implementing (at least part of) METAFONT/POST in OpenPythonSCAD --- and of course in the course of that, it would be pretty straight-forward to just write out .mp files and process those to get anything which it can output, which includes SVGs.

William

-- 
https://designinto3d.com/
Sphinx of black quartz, judge my vow.

All of this makes me wonder if it wouldn't be better to just wrap up an existing 2D tool? I've been looking at re-implementing (at least part of) METAFONT/POST in OpenPythonSCAD --- and of course in the course of that, it would be pretty straight-forward to just write out .mp files and process those to get anything which it can output, which includes SVGs. William --  https://designinto3d.com/ Sphinx of black quartz, judge my vow.
JD
John David
Wed, Apr 23, 2025 1:35 PM

The use case is to generate a 2D image whose outlines which have the same
color as what was programmed.

This is used in laser cutter GUI's to allow people to associate a specific
color with power/speed profiles.  At the moment, we need to import the SVG
image into Inkscape(or other digital image editor) and then modify the
image data.

I will also check out the color PDF work.  I may be able to use that
directly.  I'll check it out.

EBo --

On Wed, Apr 23, 2025 at 8:43 AM William F. Adams via Discuss <
discuss@lists.openscad.org> wrote:

All of this makes me wonder if it wouldn't be better to just wrap up an
existing 2D tool?

I've been looking at re-implementing (at least part of) METAFONT/POST in
OpenPythonSCAD --- and of course in the course of that, it would be pretty
straight-forward to just write out .mp files and process those to get
anything which it can output, which includes SVGs.

William

--
https://designinto3d.com/
Sphinx of black quartz, judge my vow.


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

The use case is to generate a 2D image whose outlines which have the same color as what was programmed. This is used in laser cutter GUI's to allow people to associate a specific color with power/speed profiles. At the moment, we need to import the SVG image into Inkscape(or other digital image editor) and then modify the image data. I will also check out the color PDF work. I may be able to use that directly. I'll check it out. EBo -- On Wed, Apr 23, 2025 at 8:43 AM William F. Adams via Discuss < discuss@lists.openscad.org> wrote: > All of this makes me wonder if it wouldn't be better to just wrap up an > existing 2D tool? > > I've been looking at re-implementing (at least part of) METAFONT/POST in > OpenPythonSCAD --- and of course in the course of that, it would be pretty > straight-forward to just write out .mp files and process those to get > anything which it can output, which includes SVGs. > > William > > -- > https://designinto3d.com/ > Sphinx of black quartz, judge my vow. > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
JD
John David
Wed, Apr 23, 2025 1:45 PM

I looked around for the PDF extension noted in
https://github.com/openscad/openscad/pull/5845 . Is it around some place I
can get to to play with?

EBo --

On Wed, Apr 23, 2025 at 9:35 AM John David ebo.2112@gmail.com wrote:

The use case is to generate a 2D image whose outlines which have the same
color as what was programmed.

This is used in laser cutter GUI's to allow people to associate a specific
color with power/speed profiles.  At the moment, we need to import the SVG
image into Inkscape(or other digital image editor) and then modify the
image data.

I will also check out the color PDF work.  I may be able to use that
directly.  I'll check it out.

EBo --

On Wed, Apr 23, 2025 at 8:43 AM William F. Adams via Discuss <
discuss@lists.openscad.org> wrote:

All of this makes me wonder if it wouldn't be better to just wrap up an
existing 2D tool?

I've been looking at re-implementing (at least part of) METAFONT/POST in
OpenPythonSCAD --- and of course in the course of that, it would be pretty
straight-forward to just write out .mp files and process those to get
anything which it can output, which includes SVGs.

William

--
https://designinto3d.com/
Sphinx of black quartz, judge my vow.


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

I looked around for the PDF extension noted in https://github.com/openscad/openscad/pull/5845 . Is it around some place I can get to to play with? EBo -- On Wed, Apr 23, 2025 at 9:35 AM John David <ebo.2112@gmail.com> wrote: > The use case is to generate a 2D image whose outlines which have the same > color as what was programmed. > > This is used in laser cutter GUI's to allow people to associate a specific > color with power/speed profiles. At the moment, we need to import the SVG > image into Inkscape(or other digital image editor) and then modify the > image data. > > I will also check out the color PDF work. I may be able to use that > directly. I'll check it out. > > EBo -- > > On Wed, Apr 23, 2025 at 8:43 AM William F. Adams via Discuss < > discuss@lists.openscad.org> wrote: > >> All of this makes me wonder if it wouldn't be better to just wrap up an >> existing 2D tool? >> >> I've been looking at re-implementing (at least part of) METAFONT/POST in >> OpenPythonSCAD --- and of course in the course of that, it would be pretty >> straight-forward to just write out .mp files and process those to get >> anything which it can output, which includes SVGs. >> >> William >> >> -- >> https://designinto3d.com/ >> Sphinx of black quartz, judge my vow. >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> >
WF
William F. Adams
Wed, Apr 23, 2025 1:56 PM

On Wednesday, April 23, 2025 at 09:35:22 AM EDT, John David ebo.2112@gmail.com wrote:

The use case is to generate a 2D image whose outlines which have the same color as what was programmed. 

This is used in laser cutter GUI's to allow people to associate a specific color with power/speed profiles.  At the moment, 
we need to import the SVG image into Inkscape(or other digital image editor) and then modify the image data.

Alternately, I have direct DXF export working via OpenPythonSCAD:

https://pythonscad.org/

https://github.com/WillAdams/gcodepreview/blob/main/gcpdxf.py

if a DXF would work, and you have a very simple example/template w/ all the colours you need it should be pretty easy to add support for colour to that.

If not, re-implementing at least a sub-set of METAFONT/POST is on my radar and that should be easy to add onto that aspect of the project:

https://github.com/WillAdams/gcodepreview

William

On Wednesday, April 23, 2025 at 09:35:22 AM EDT, John David <ebo.2112@gmail.com> wrote: >The use case is to generate a 2D image whose outlines which have the same color as what was programmed.  >This is used in laser cutter GUI's to allow people to associate a specific color with power/speed profiles.  At the moment,  >we need to import the SVG image into Inkscape(or other digital image editor) and then modify the image data. Alternately, I have direct DXF export working via OpenPythonSCAD: https://pythonscad.org/ https://github.com/WillAdams/gcodepreview/blob/main/gcpdxf.py if a DXF would work, and you have a very simple example/template w/ all the colours you need it should be pretty easy to add support for colour to that. If not, re-implementing at least a sub-set of METAFONT/POST is on my radar and that should be easy to add onto that aspect of the project: https://github.com/WillAdams/gcodepreview William
WF
William F. Adams
Sat, Apr 26, 2025 2:16 AM

Took a stab at this for DXFs in OpenPythonSCAD, and have a file:

https://github.com/WillAdams/gcodepreview/blob/main/gcpdxf.py

which makes a DXF (see attached DXF) which has multiple colors (see attached screengrab showing the DXF open in LibreCAD).

Usage is:

Install OpenPythonSCAD from: https://pythonscad.org/ (for Windows I would suggest the older build: https://www.pythonscad.org/downloads/PythonSCAD-2024.12.29-x86-64-Installer.exe until there is an updated version which fixes Library import for Windows).

Download the .zip archive of the gcodepreview files: https://github.com/WillAdams/gcodepreview/archive/refs/heads/main.zip and unzip it, and copy the files gcodepreview.py and gcodepreview.scad into the folder revealed by PythonSCAD | File | Show Library Folder (for my account this was: C:\Users\willa\OneDrive\Documents\OpenSCAD\libraries) then open a template file and use it as a guide to make the file which you want.

The file gcpdxf.py shows making a color DXF which requires just a few commands, notably gcp.setdxfcolor("Black/Red/Yellow/Green/Cyan/Blue/Magenta/White/Dark Gray/Light Gray") --- there is an OpenSCAD version, "setdxfcolor("<color name here>"); and one can coordinate the DXF geometry with the 3D model.

If anyone has trouble making a file, send me a .scad file and let me know the specifics of the DXF which you would like to see and I'll work up an example.

William

-- 
https://designinto3d.com/
Sphinx of black quartz, judge my vow.

Took a stab at this for DXFs in OpenPythonSCAD, and have a file: https://github.com/WillAdams/gcodepreview/blob/main/gcpdxf.py which makes a DXF (see attached DXF) which has multiple colors (see attached screengrab showing the DXF open in LibreCAD). Usage is: Install OpenPythonSCAD from: https://pythonscad.org/ (for Windows I would suggest the older build: https://www.pythonscad.org/downloads/PythonSCAD-2024.12.29-x86-64-Installer.exe until there is an updated version which fixes Library import for Windows). Download the .zip archive of the gcodepreview files: https://github.com/WillAdams/gcodepreview/archive/refs/heads/main.zip and unzip it, and copy the files gcodepreview.py and gcodepreview.scad into the folder revealed by PythonSCAD | File | Show Library Folder (for my account this was: C:\Users\willa\OneDrive\Documents\OpenSCAD\libraries) then open a template file and use it as a guide to make the file which you want. The file gcpdxf.py shows making a color DXF which requires just a few commands, notably gcp.setdxfcolor("Black/Red/Yellow/Green/Cyan/Blue/Magenta/White/Dark Gray/Light Gray") --- there is an OpenSCAD version, "setdxfcolor("<color name here>"); and one can coordinate the DXF geometry with the 3D model. If anyone has trouble making a file, send me a .scad file and let me know the specifics of the DXF which you would like to see and I'll work up an example. William --  https://designinto3d.com/ Sphinx of black quartz, judge my vow.