discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

difference block and syntax error

M
MichaelAtOz
Fri, Nov 20, 2015 9:04 PM

This post from Randy was auto-discarded for some reason.

(slightly edited)

/*
Hi All,
I'm trying to create my first project from scratch and having been staring
at a syntax error for a while now.
I can generate two cubes just fine but as soon as I try to carve one out of
the other with a difference statement it won't compile. What obvious thing
am I missing?
Thanks in advance:
Randy in Seattle
WORKS:
*/
// simple lantern frame for paper inserts
// for LED candles only

//bottom_thickness=1;  // added by MichaelAtOz

//lantern_frame();
module lantern_frame() {
// size of the inserts
pane_height = 130;
pane_width = 85;
pane_thickness = 1;
// depth of the pane slot in the frame
pane_slot_depth = 3;
// depth of the pane inset from the outside of the frame
pane_inset = 2;
// dimensions of the frame
frame_thickness = 5;
top_frame_width = 10;
bottom_frame_width = 10;
side_frame_width = 10;
box_width = pane_width + 2 * (side_frame_width - pane_slot_depth);
box_height = pane_height + bottom_frame_width + top_frame_width - 2 *
pane_slot_depth;
cube([box_width, box_width, box_height], center = true);
inside_width = box_width - 2 * frame_thickness;
inside_height = box_height - bottom_thickness;
cube([box_width, box_width, box_height], center = true);
}
//DOESN "T WORK: (syntax error on the line right after the difference call)
// simple lantern frame for paper inserts
// for LED candles only

lantern_frame2();
module lantern_frame2() {
// size of the inserts
pane_height = 130;
pane_width = 85;
pane_thickness = 1;
// depth of the pane slot in the frame
pane_slot_depth = 3;
// depth of the pane inset from the outside of the frame
pane_inset = 2;
// dimensions of the frame
frame_thickness = 5;
top_frame_width = 10;
bottom_frame_width = 10;
side_frame_width = 10;
difference() {
box_width = pane_width + 2 * (side_frame_width - pane_slot_depth);
box_height = pane_height + bottom_frame_width + top_frame_width - 2 *
pane_slot_depth;
cube([box_width, box_width, box_height], center = true);
inside_width = box_width - 2 * frame_thickness;
inside_height = box_height - bottom_thickness;
cube([box_width, box_width, box_height], center = true);
}
}


Randy,

I did not get a syntax error. There was the unknown variable message
(bottom_thickness) which I added above (currently commented out).

What it gives me is a null cube, because you are difference()ing the exact
same cube from itself.

If you still have an error please include a cut/paste from the console.


Newly minted Admin - PM me if you need anything, or if I've done something stupid...

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.

The TPP is no simple “trade agreement.”  Fight it! http://www.ourfairdeal.org/  time is running out!

View this message in context: http://forum.openscad.org/difference-block-and-syntax-error-tp14680.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

This post from Randy was auto-discarded for some reason. (slightly edited) -------------------------------------------------------------------------------------------------------------------------- /* Hi All, I'm trying to create my first project from scratch and having been staring at a syntax error for a while now. I can generate two cubes just fine but as soon as I try to carve one out of the other with a difference statement it won't compile. What obvious thing am I missing? Thanks in advance: Randy in Seattle WORKS: */ // simple lantern frame for paper inserts // for LED candles only //bottom_thickness=1; // added by MichaelAtOz //lantern_frame(); module lantern_frame() { // size of the inserts pane_height = 130; pane_width = 85; pane_thickness = 1; // depth of the pane slot in the frame pane_slot_depth = 3; // depth of the pane inset from the outside of the frame pane_inset = 2; // dimensions of the frame frame_thickness = 5; top_frame_width = 10; bottom_frame_width = 10; side_frame_width = 10; box_width = pane_width + 2 * (side_frame_width - pane_slot_depth); box_height = pane_height + bottom_frame_width + top_frame_width - 2 * pane_slot_depth; cube([box_width, box_width, box_height], center = true); inside_width = box_width - 2 * frame_thickness; inside_height = box_height - bottom_thickness; cube([box_width, box_width, box_height], center = true); } //DOESN "T WORK: (syntax error on the line right after the difference call) // simple lantern frame for paper inserts // for LED candles only lantern_frame2(); module lantern_frame2() { // size of the inserts pane_height = 130; pane_width = 85; pane_thickness = 1; // depth of the pane slot in the frame pane_slot_depth = 3; // depth of the pane inset from the outside of the frame pane_inset = 2; // dimensions of the frame frame_thickness = 5; top_frame_width = 10; bottom_frame_width = 10; side_frame_width = 10; difference() { box_width = pane_width + 2 * (side_frame_width - pane_slot_depth); box_height = pane_height + bottom_frame_width + top_frame_width - 2 * pane_slot_depth; cube([box_width, box_width, box_height], center = true); inside_width = box_width - 2 * frame_thickness; inside_height = box_height - bottom_thickness; cube([box_width, box_width, box_height], center = true); } } ---------------------------------------------------------------------------------------------------------------- Randy, I did not get a syntax error. There was the unknown variable message (bottom_thickness) which I added above (currently commented out). What it gives me is a null cube, because you are difference()ing the exact same cube from itself. If you still have an error please include a cut/paste from the console. ----- Newly minted Admin - PM me if you need anything, or if I've done something stupid... Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above. The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out! -- View this message in context: http://forum.openscad.org/difference-block-and-syntax-error-tp14680.html Sent from the OpenSCAD mailing list archive at Nabble.com.
M
MichaelAtOz
Fri, Nov 20, 2015 9:09 PM

Randy,

I suspect you are using an old version of OpenSCAD?

Where you are not allowed to put assignments inside things like
difference().

I'd suggest going to the latest release.
Otherwise move all the assignments out to the top level of the module.


Newly minted Admin - PM me if you need anything, or if I've done something stupid...

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.

The TPP is no simple “trade agreement.”  Fight it! http://www.ourfairdeal.org/  time is running out!

View this message in context: http://forum.openscad.org/difference-block-and-syntax-error-tp14680p14681.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Randy, I suspect you are using an old version of OpenSCAD? Where you are not allowed to put assignments inside things like difference(). I'd suggest going to the latest release. Otherwise move all the assignments out to the top level of the module. ----- Newly minted Admin - PM me if you need anything, or if I've done something stupid... Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above. The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out! -- View this message in context: http://forum.openscad.org/difference-block-and-syntax-error-tp14680p14681.html Sent from the OpenSCAD mailing list archive at Nabble.com.