discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

the Write.SCAD file

J
jon
Tue, Nov 24, 2020 9:36 PM

I have been working with Carsten to get his OpenSCAD-in-AngelCAD feature
working.  We stumbled across this:

I use Write.SCAD, which apparently includes lines like this:

import(file = "Letters.dxf", layer = "undef", origin = [0, 0], scale =
1, convexity = 1, $fn = 100, $fa = 12, $fs = 2, timestamp = 1606225466);

In other words it requests import of a DXF layer called "undef" from
Letters.dxf, but no such layer exists in that file.

You cannot just skip that file, because you cannot linear_extrude
nothing....

So how is it supposed to work?  I mean it does work, but how or why?

The main question could perhaps be "what does OpenSCAD do when asked to
extract a non-existing DXF layer 'undef' as part of a linear_extrude?".
I would have thought it would stop processing, but apparently it does not.

Thoughts or comments?

Jon

I have been working with Carsten to get his OpenSCAD-in-AngelCAD feature working.  We stumbled across this: I use Write.SCAD, which apparently includes lines like this: import(file = "Letters.dxf", layer = "undef", origin = [0, 0], scale = 1, convexity = 1, $fn = 100, $fa = 12, $fs = 2, timestamp = 1606225466); In other words it requests import of a DXF layer called "undef" from Letters.dxf, but no such layer exists in that file. You cannot just skip that file, because you cannot linear_extrude nothing.... So how is it supposed to work?  I mean it does work, but how or why? The main question could perhaps be "what does OpenSCAD do when asked to extract a non-existing DXF layer 'undef' as part of a linear_extrude?". I would have thought it would stop processing, but apparently it does not. Thoughts or comments? Jon
CA
Carsten Arnholm
Tue, Nov 24, 2020 10:42 PM

On 24.11.2020 22:36, jon wrote:

I have been working with Carsten to get his OpenSCAD-in-AngelCAD feature
working.  We stumbled across this:

I use Write.SCAD, which apparently includes lines like this:

import(file = "Letters.dxf", layer = "undef", origin = [0, 0], scale =
1, convexity = 1, $fn = 100, $fa = 12, $fs = 2, timestamp = 1606225466);

To be precise, that line is taken from the csg-file that is generated by
openscad if you do

$ openscad somefile.scad --o=somefile.csg

...and somefile.scad "uses" write.scad like this:

use <write.scad>

It is write.scad that does import of "Letters.dxf", obviously containing
one letter in each DXF layer. However, sometimes write.scad tries to
import an "undef" layer (no such layer exist) as child of a linear_extrude.

I guess this is a bug in write.scad, but how does OpenSCAD manage to
process such things without even complaining?

I realise OpenSCAD does not process via the csg file, but surely it must
process the same tree internally.

Carsten Arnholm

On 24.11.2020 22:36, jon wrote: > I have been working with Carsten to get his OpenSCAD-in-AngelCAD feature > working.  We stumbled across this: > > I use Write.SCAD, which apparently includes lines like this: > > import(file = "Letters.dxf", layer = "undef", origin = [0, 0], scale = > 1, convexity = 1, $fn = 100, $fa = 12, $fs = 2, timestamp = 1606225466); To be precise, that line is taken from the csg-file that is generated by openscad if you do $ openscad somefile.scad --o=somefile.csg ...and somefile.scad "uses" write.scad like this: use <write.scad> It is write.scad that does import of "Letters.dxf", obviously containing one letter in each DXF layer. However, sometimes write.scad tries to import an "undef" layer (no such layer exist) as child of a linear_extrude. I guess this is a bug in write.scad, but how does OpenSCAD manage to process such things without even complaining? I realise OpenSCAD does not process via the csg file, but surely it must process the same tree internally. Carsten Arnholm
DM
Doug Moen
Tue, Nov 24, 2020 11:05 PM

What happens if you feed somefile.csg back into OpenSCAD? Can OpenSCAD itself process the CSG file that it generates?

On Tue, Nov 24, 2020, at 5:42 PM, Carsten Arnholm wrote:

On 24.11.2020 22:36, jon wrote:

I have been working with Carsten to get his OpenSCAD-in-AngelCAD feature
working.  We stumbled across this:

I use Write.SCAD, which apparently includes lines like this:

import(file = "Letters.dxf", layer = "undef", origin = [0, 0], scale =
1, convexity = 1, $fn = 100, $fa = 12, $fs = 2, timestamp = 1606225466);

To be precise, that line is taken from the csg-file that is generated by
openscad if you do

$ openscad somefile.scad --o=somefile.csg

...and somefile.scad "uses" write.scad like this:

use <write.scad>

It is write.scad that does import of "Letters.dxf", obviously containing
one letter in each DXF layer. However, sometimes write.scad tries to
import an "undef" layer (no such layer exist) as child of a linear_extrude.

I guess this is a bug in write.scad, but how does OpenSCAD manage to
process such things without even complaining?

I realise OpenSCAD does not process via the csg file, but surely it must
process the same tree internally.

Carsten Arnholm


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

What happens if you feed somefile.csg back into OpenSCAD? Can OpenSCAD itself process the CSG file that it generates? On Tue, Nov 24, 2020, at 5:42 PM, Carsten Arnholm wrote: > On 24.11.2020 22:36, jon wrote: > > I have been working with Carsten to get his OpenSCAD-in-AngelCAD feature > > working.  We stumbled across this: > > > > I use Write.SCAD, which apparently includes lines like this: > > > > import(file = "Letters.dxf", layer = "undef", origin = [0, 0], scale = > > 1, convexity = 1, $fn = 100, $fa = 12, $fs = 2, timestamp = 1606225466); > > To be precise, that line is taken from the csg-file that is generated by > openscad if you do > > $ openscad somefile.scad --o=somefile.csg > > ...and somefile.scad "uses" write.scad like this: > > use <write.scad> > > It is write.scad that does import of "Letters.dxf", obviously containing > one letter in each DXF layer. However, sometimes write.scad tries to > import an "undef" layer (no such layer exist) as child of a linear_extrude. > > I guess this is a bug in write.scad, but how does OpenSCAD manage to > process such things without even complaining? > > I realise OpenSCAD does not process via the csg file, but surely it must > process the same tree internally. > > Carsten Arnholm > > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
MM
Michael Marx
Tue, Nov 24, 2020 11:50 PM

write()
...
for (r = [0:len(word)]){  // count off each character

Needs a -1

import() fails silently like most things.

-----Original Message-----
From: Discuss [mailto:discuss-bounces@lists.openscad.org] On Behalf Of Doug Moen
Sent: Wed, 25 Nov 2020 10:05
To: OpenSCAD Discuss
Subject: Re: [OpenSCAD] the Write.SCAD file

What happens if you feed somefile.csg back into OpenSCAD? Can OpenSCAD itself process the
CSG file that it generates?

On Tue, Nov 24, 2020, at 5:42 PM, Carsten Arnholm wrote:

On 24.11.2020 22:36, jon wrote:

I have been working with Carsten to get his OpenSCAD-in-AngelCAD feature
working.  We stumbled across this:

I use Write.SCAD, which apparently includes lines like this:

import(file = "Letters.dxf", layer = "undef", origin = [0, 0], scale =
1, convexity = 1, $fn = 100, $fa = 12, $fs = 2, timestamp = 1606225466);

To be precise, that line is taken from the csg-file that is generated by
openscad if you do

$ openscad somefile.scad --o=somefile.csg

...and somefile.scad "uses" write.scad like this:

use <write.scad>

It is write.scad that does import of "Letters.dxf", obviously containing
one letter in each DXF layer. However, sometimes write.scad tries to
import an "undef" layer (no such layer exist) as child of a linear_extrude.

I guess this is a bug in write.scad, but how does OpenSCAD manage to
process such things without even complaining?

I realise OpenSCAD does not process via the csg file, but surely it must
process the same tree internally.

Carsten Arnholm


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.
https://www.avg.com

write() ... for (r = [0:len(word)]){ // count off each character Needs a -1 import() fails silently like most things. > -----Original Message----- > From: Discuss [mailto:discuss-bounces@lists.openscad.org] On Behalf Of Doug Moen > Sent: Wed, 25 Nov 2020 10:05 > To: OpenSCAD Discuss > Subject: Re: [OpenSCAD] the Write.SCAD file > > What happens if you feed somefile.csg back into OpenSCAD? Can OpenSCAD itself process the > CSG file that it generates? > > On Tue, Nov 24, 2020, at 5:42 PM, Carsten Arnholm wrote: > > On 24.11.2020 22:36, jon wrote: > > > I have been working with Carsten to get his OpenSCAD-in-AngelCAD feature > > > working.  We stumbled across this: > > > > > > I use Write.SCAD, which apparently includes lines like this: > > > > > > import(file = "Letters.dxf", layer = "undef", origin = [0, 0], scale = > > > 1, convexity = 1, $fn = 100, $fa = 12, $fs = 2, timestamp = 1606225466); > > > > To be precise, that line is taken from the csg-file that is generated by > > openscad if you do > > > > $ openscad somefile.scad --o=somefile.csg > > > > ...and somefile.scad "uses" write.scad like this: > > > > use <write.scad> > > > > It is write.scad that does import of "Letters.dxf", obviously containing > > one letter in each DXF layer. However, sometimes write.scad tries to > > import an "undef" layer (no such layer exist) as child of a linear_extrude. > > > > I guess this is a bug in write.scad, but how does OpenSCAD manage to > > process such things without even complaining? > > > > I realise OpenSCAD does not process via the csg file, but surely it must > > process the same tree internally. > > > > Carsten Arnholm > > > > > > > > _______________________________________________ > > 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. https://www.avg.com
CA
Carsten Arnholm
Wed, Nov 25, 2020 7:43 AM

On 25.11.2020 00:05, Doug Moen wrote:

What happens if you feed somefile.csg back into OpenSCAD? Can OpenSCAD itself process the CSG file that it generates?

Yes it can, see attachment. Somehow, the import statements referring to
nonexistent "undef" layers are silently ignored. I would expect
processing to stop on such an issue, or at least write a warning. I am
still not sure how it manages to do linear_extrude on nothing and get
away with it?

Instead import warnings are issued about something unrelated (?) that
isn't even true: Using version 2020.11.23.nightly (git 0d5065d) under
Ubuntu, it complains about missing timestamps that are not missing.
here's one example:

"WARNING: variable timestamp not specified as parameter in file Orange
Crush Foot Switch.csg, line 234 "

There is one such warning for every import statement, including for the
cases where the DXF layer exists. I think this is unrelated to the
original issue though.

Carsten Arnholm

On 25.11.2020 00:05, Doug Moen wrote: > What happens if you feed somefile.csg back into OpenSCAD? Can OpenSCAD itself process the CSG file that it generates? Yes it can, see attachment. Somehow, the import statements referring to nonexistent "undef" layers are silently ignored. I would expect processing to stop on such an issue, or at least write a warning. I am still not sure how it manages to do linear_extrude on nothing and get away with it? Instead import warnings are issued about something unrelated (?) that isn't even true: Using version 2020.11.23.nightly (git 0d5065d) under Ubuntu, it complains about missing timestamps that are not missing. here's one example: "WARNING: variable timestamp not specified as parameter in file Orange Crush Foot Switch.csg, line 234 " There is one such warning for every import statement, including for the cases where the DXF layer exists. I think this is unrelated to the original issue though. Carsten Arnholm
CA
Carsten Arnholm
Wed, Nov 25, 2020 7:45 AM

On 25.11.2020 00:50, Michael Marx wrote:

write()
...
for (r = [0:len(word)]){  // count off each character

Needs a -1

import() fails silently like most things.

Thant's probably the root cause indeed! A classic off-by-one bug.

Thanks.

Carsten Arnholm

On 25.11.2020 00:50, Michael Marx wrote: > > write() > ... > for (r = [0:len(word)]){ // count off each character > > Needs a -1 > > import() fails silently like most things. Thant's probably the root cause indeed! A classic off-by-one bug. Thanks. Carsten Arnholm