Hi all,
I am generating a set of tiles and I am using the (windows) commandline
to do it. My typical cmd command is:
"c:\Program Files\OpenSCAD\openscad.com" -o stl\tile_6_3.stl -D "x=6" -D
"y=3" cmdline_tile.scad
The cmdline_tile.scad file contains this code:
$fn = 30;
use <tile_module.scad>;
// dQ
midHeight = 38;
slopeN = [-95 / 12 * y, -57 / 12 * x, 32];
tile (slopeN, h = midHeight);
And this produces an error:
WARNING: Ignoring unknown variable 'y', in file cmdline_tile.scad, line 6.
WARNING: undefined operation (number * undefined) in file
cmdline_tile.scad, line 6
WARNING: Ignoring unknown variable 'x', in file cmdline_tile.scad, line 6.
WARNING: undefined operation (number * undefined) in file
cmdline_tile.scad, line 6
And of course the result is empty...
If I add echo before the slopeN= […] assignment, the variables show
themselves to be existent:
echo (x=x, y=y);
which produces this output line:
ECHO: x = 6, y = 3
again followed by the error claiming that variable 'y' is unknown etc.
What is, however, unexplainable for me, is the fact that the command on
last line works, if I build the slope vector inline:
tile (n = [-95 / 12 * y, -57 / 12 * x, 32], h = midHeight);
This does not raise any warning and builds the expected tile. Why? And
why I cannot build the vector and then use it?
(OK, I have a workaround now but I am not happy with the path)
Jan
'-D' adds that text to the end of the file (in memory).
so you get this
$fn = 30;
use <tile_module.scad>;
// dQ
midHeight = 38;
slopeN = [-95 / 12 * y, -57 / 12 * x, 32];
tile (slopeN, h = midHeight);
x=6;y=3;
Try that in the GUI
The magic source is
$fn = 30;
use <tile_module.scad>;
// dQ
midHeight = 38;
x=0; y=0;
slopeN = [-95 / 12 * y, -57 / 12 * x, 32];
tile (slopeN, h = midHeight);
x=6;y=3;
If you want to know why, ask, but I'll answer tomorrow, I have a glass of red calling to me...
From: Discuss [mailto:discuss-bounces@lists.openscad.org] On Behalf Of Jan Koupil
Sent: Fri, 14 Aug 2020 17:32
To: discuss@lists.openscad.org
Subject: [OpenSCAD] Weird behaviour of commandline parameters
Hi all,
I am generating a set of tiles and I am using the (windows) commandline to do it. My typical cmd
command is:
"c:\Program Files\OpenSCAD\openscad.com" -o stl\tile_6_3.stl -D "x=6" -D "y=3" cmdline_tile.scad
The cmdline_tile.scad file contains this code:
$fn = 30;
use <tile_module.scad>;
// dQ
midHeight = 38;
slopeN = [-95 / 12 * y, -57 / 12 * x, 32];
tile (slopeN, h = midHeight);
And this produces an error:
WARNING: Ignoring unknown variable 'y', in file cmdline_tile.scad, line 6.
WARNING: undefined operation (number * undefined) in file cmdline_tile.scad, line 6
WARNING: Ignoring unknown variable 'x', in file cmdline_tile.scad, line 6.
WARNING: undefined operation (number * undefined) in file cmdline_tile.scad, line 6
And of course the result is empty...
If I add echo before the slopeN = [.] assignment, the variables show themselves to be existent:
echo (x=x, y=y);
which produces this output line:
ECHO: x = 6, y = 3
again followed by the error claiming that variable 'y' is unknown etc.
What is, however, unexplainable for me, is the fact that the command on last line works, if I build
the slope vector inline:
tile (n = [-95 / 12 * y, -57 / 12 * x, 32], h = midHeight);
This does not raise any warning and builds the expected tile. Why? And why I cannot build the
vector and then use it?
(OK, I have a workaround now but I am not happy with the path)
Jan
--
This email has been checked for viruses by AVG.
https://www.avg.com
On 14.08.20 09:32, Jan Koupil wrote:
This does not raise any warning and builds the expected tile.
Why? And why I cannot build the vector and then use it?
Variables are initialized in order, modules called afterwards,
so if you want to use -D variables to calculate others, you
need to give them some initial value in the script before use.
a = 3;
b = a + 2;
echo(a, b);
openscad -Da=1 ...
ciao,
Torsten.