command line help

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

command line help

jon_bondy
I've never used OpenSCAD from the command line before, but I now need to
generate some dozens of model variations, so I am trying it, without
success.

When I try this:

"c:\program files\openscad\openscad" -o out.stl -D 'myVar="val1"' -D
'num=1' -D 'need="false"' my-program.scad

I get this:

Can't parse file 'my-program.scad'!


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: command line help

nophead
I don't think you want the single quotes under Windows.

On Sun, 7 Mar 2021 at 13:24, jon <[hidden email]> wrote:
I've never used OpenSCAD from the command line before, but I now need to
generate some dozens of model variations, so I am trying it, without
success.

When I try this:

"c:\program files\openscad\openscad" -o out.stl -D 'myVar="val1"' -D
'num=1' -D 'need="false"' my-program.scad

I get this:

Can't parse file 'my-program.scad'!


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: command line help

jon_bondy

You appear to be correct, although the example from the documentation is this:

openscad -o my_model_production.stl -D 'quality="production"' my_model.scad

Now, I get the warning that "val1" is an "unknown variable" for each of the used files, and too many unnamed arguments for one of the used files. Unsettling.

The STL appears to have been generated correctly, but the warnings are frightening: they do not occur when run from the GUI.

I guess I'm off and running, albeit nervously

Thanks!


On 3/7/2021 8:30 AM, nop head wrote:
I don't think you want the single quotes under Windows.

On Sun, 7 Mar 2021 at 13:24, jon <[hidden email]> wrote:
I've never used OpenSCAD from the command line before, but I now need to
generate some dozens of model variations, so I am trying it, without
success.

When I try this:

"c:\program files\openscad\openscad" -o out.stl -D 'myVar="val1"' -D
'num=1' -D 'need="false"' my-program.scad

I get this:

Can't parse file 'my-program.scad'!


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: command line help

MichaelAtOz
Administrator
In reply to this post by jon_bondy
See wiki

One way:
On Windows you may need to escape the inner quotes instead:

openscad -o my_model_production.stl -D "quality=\"production\"" my_model.scad
It's been a while since I used cmd-line, I seem to recall that in batch files it got complex.
OpenSCAD Admin - email* me if you need anything, or if I've done something stupid...
* on the Forum, click on my MichaelAtOz label, there is a link to email me.

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.


Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
OpenSCAD Admin - email* me if you need anything, or if I've done something stupid...
* on the Forum, click on my MichaelAtOz label, there is a link to email me.

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.
Reply | Threaded
Open this post in threaded view
|

Re: command line help

jon_bondy

I was using the wiki entry you recommend.

My sense is that nophead is correct about removing the single quotes from my original example, and that the syntax for a batch file and for a command line execution are subtly different.  There is no need to escape the inner quotes, because there are no inner quotes once nophead's suggestion is implemented

The warnings are scary, but I think I'm off and running

Jon

On 3/7/2021 8:44 AM, MichaelAtOz wrote:
See wiki

One way:
On Windows you may need to escape the inner quotes instead:

openscad -o my_model_production.stl -D "quality=\"production\"" my_model.scad
It's been a while since I used cmd-line, I seem to recall that in batch files it got complex.
OpenSCAD Admin - email* me if you need anything, or if I've done something stupid...
* on the Forum, click on my MichaelAtOz label, there is a link to email me.

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.


Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: command line help

OpenSCAD mailing list-2
Do you ECHO the variables to be sure that they are getting in with the values that you set?

On 2021-03-07 8:48 a.m., jon wrote:

I was using the wiki entry you recommend.

My sense is that nophead is correct about removing the single quotes from my original example, and that the syntax for a batch file and for a command line execution are subtly different.  There is no need to escape the inner quotes, because there are no inner quotes once nophead's suggestion is implemented

The warnings are scary, but I think I'm off and running

Jon

On 3/7/2021 8:44 AM, MichaelAtOz wrote:
See wiki

One way:
On Windows you may need to escape the inner quotes instead:

openscad -o my_model_production.stl -D "quality=\"production\"" my_model.scad
It's been a while since I used cmd-line, I seem to recall that in batch files it got complex.
OpenSCAD Admin - email* me if you need anything, or if I've done something stupid...
* on the Forum, click on my MichaelAtOz label, there is a link to email me.

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.


Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

-- 
Ron Wheeler
Artifact Software
438-345-3369
[hidden email]

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: command line help

jon_bondy

The values were correct, because the STLs created were correct.  I cannot explain the warning messages


On 3/7/2021 10:57 AM, Ron Wheeler via Discuss wrote:
Do you ECHO the variables to be sure that they are getting in with the values that you set?

On 2021-03-07 8:48 a.m., jon wrote:

I was using the wiki entry you recommend.

My sense is that nophead is correct about removing the single quotes from my original example, and that the syntax for a batch file and for a command line execution are subtly different.  There is no need to escape the inner quotes, because there are no inner quotes once nophead's suggestion is implemented

The warnings are scary, but I think I'm off and running

Jon

On 3/7/2021 8:44 AM, MichaelAtOz wrote:
See wiki

One way:
On Windows you may need to escape the inner quotes instead:

openscad -o my_model_production.stl -D "quality=\"production\"" my_model.scad
It's been a while since I used cmd-line, I seem to recall that in batch files it got complex.
OpenSCAD Admin - email* me if you need anything, or if I've done something stupid...
* on the Forum, click on my MichaelAtOz label, there is a link to email me.

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.


Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

-- 
Ron Wheeler
Artifact Software
438-345-3369
[hidden email]

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: command line help

OpenSCAD mailing list-2
The proof is in the pudding but one hates to see error messages (unexpected ones at least) even if the code appears to work.

On 2021-03-07 11:26 a.m., jon wrote:

The values were correct, because the STLs created were correct.  I cannot explain the warning messages


On 3/7/2021 10:57 AM, Ron Wheeler via Discuss wrote:
Do you ECHO the variables to be sure that they are getting in with the values that you set?

On 2021-03-07 8:48 a.m., jon wrote:

I was using the wiki entry you recommend.

My sense is that nophead is correct about removing the single quotes from my original example, and that the syntax for a batch file and for a command line execution are subtly different.  There is no need to escape the inner quotes, because there are no inner quotes once nophead's suggestion is implemented

The warnings are scary, but I think I'm off and running

Jon

On 3/7/2021 8:44 AM, MichaelAtOz wrote:
See wiki

One way:
On Windows you may need to escape the inner quotes instead:

openscad -o my_model_production.stl -D "quality=\"production\"" my_model.scad
It's been a while since I used cmd-line, I seem to recall that in batch files it got complex.
OpenSCAD Admin - email* me if you need anything, or if I've done something stupid...
* on the Forum, click on my MichaelAtOz label, there is a link to email me.

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.


Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

-- 
Ron Wheeler
Artifact Software
438-345-3369
[hidden email]

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

-- 
Ron Wheeler
Artifact Software
438-345-3369
[hidden email]

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: command line help

nophead
For Linux you would need the outer single quotes but not for Windows. Windows is weird. 

On Linux the outer single quotes would be stripped but on Windows that would be passed to OpenSCAD. 

On Windows the inner double quotes both allow spaces etc in the string but also get passed to OpenSCAD, which is why you don't need the outer quotes.

You shouldn't expect any additional warnings.

On Sun, 7 Mar 2021 at 16:50, Ron Wheeler via Discuss <[hidden email]> wrote:
The proof is in the pudding but one hates to see error messages (unexpected ones at least) even if the code appears to work.

On 2021-03-07 11:26 a.m., jon wrote:

The values were correct, because the STLs created were correct.  I cannot explain the warning messages


On 3/7/2021 10:57 AM, Ron Wheeler via Discuss wrote:
Do you ECHO the variables to be sure that they are getting in with the values that you set?

On 2021-03-07 8:48 a.m., jon wrote:

I was using the wiki entry you recommend.

My sense is that nophead is correct about removing the single quotes from my original example, and that the syntax for a batch file and for a command line execution are subtly different.  There is no need to escape the inner quotes, because there are no inner quotes once nophead's suggestion is implemented

The warnings are scary, but I think I'm off and running

Jon

On 3/7/2021 8:44 AM, MichaelAtOz wrote:
See wiki

One way:
On Windows you may need to escape the inner quotes instead:

openscad -o my_model_production.stl -D "quality=\"production\"" my_model.scad
It's been a while since I used cmd-line, I seem to recall that in batch files it got complex.
OpenSCAD Admin - email* me if you need anything, or if I've done something stupid...
* on the Forum, click on my MichaelAtOz label, there is a link to email me.

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.


Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

-- 
Ron Wheeler
Artifact Software
438-345-3369
[hidden email]

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

-- 
Ron Wheeler
Artifact Software
438-345-3369
[hidden email]
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: command line help

JordanBrown
On 3/7/2021 10:06 AM, nop head wrote:
For Linux you would need the outer single quotes but not for Windows. Windows is weird. 

Windows isn't weird.  It's just different.

(Well, OK, in some ways it's weird too.  But this really isn't one of them.)

Doing anything non-trivial with the various command processors requires that you understand the syntax that they impose, and how they will process the line before the program sees it.

In a UNIX-derived shell, in this command:
openscad -o my_model_production.stl -D 'quality="production"' my_model.scad

the single quotes are *not* formally part of the definition of the command.  They are eaten by the shell and are not at all visible to the program.  What the program sees is a list of "words", the argv array:

openscad
-o
my_model_production.stl
-D
quality="production"
my_model.scad

The Windows model for passing arguments to programs is completely different.  It's been a million years since I've looked at Windows arguments without a C library interpreting them for me, but historically MS-DOS just handed over the entire line after the command, quotes, spaces, and all, less only a few things like I/O redirection.  C libraries, since they want to present a sort of UNIX-like environment to the program, parse those command lines in a way that's sort of similar to the UNIX shell, but only sort of.  The details will depend on the particular library used, which can lead to unfortunate inconsistencies between one program and the next.  For MSYS2, it appears that double quotes are handled but single quotes are not.  Here's a demonstration using a simple program that dumps its arguments:

C:\msys64\home\Jordan>args a "a b" 'a b' "'a b'" '"a b"' a\ b
0 >args<
1 >a<
2 >a b<
3 >'a<
4 >b'<
5 >'a b'<
6 >'a b'<
7 >a\<
8 >b<

Contrast that with the UNIX shell behavior:

$ ./args a "a b" 'a b' "'a b'" '"a b"' a\ b
0 >C:\msys64\home\Jordan\args.exe<
1 >a<
2 >a b<
3 >a b<
4 >'a b'<
5 >"a b"<
6 >a b<
(Interesting note:  that's the same MSYS2 program running in both cases.  The MSYS2 infrastructure must somehow negotiate with the program to let it know that the arguments have already been parsed.  Running under the MSYS2 version of bash, the command is getting parsed the same as it would be under UNIX.)

In the world of the UNIX shell, double quotes protect most characters from special interpretation, allowing spaces and wild-card characters to be passed as arguments.  They do not protect against shell variable references.  Single quotes protect against all special interpretation, except for the closing single quote.  Backslash protects the following character against any special interpretation.  After these characters have done their job, they are stripped from the arguments that are passed to the program.

In the world of the half-hearted UNIX-like parsing done by the MSYS2 library, it seems that double quotes are similar, but single quotes and backslashes are not special - or at least not quite as special; backslashes do seem to protect double quotes from being treated specially.

I don't know anything about Windows PowerShell syntax, but experimentation says that it (combined with the MSYS2 library) gives still another behavior:

PS C:\msys64\home\jordan> ./args a "a b" 'a b' "'a b'" '"a b"' a\ b
0 >C:\msys64\home\jordan\args.exe<
1 >a<
2 >a b<
3 >a b<
4 >'a b'<
5 >a b<
6 >a\<
7 >b<

Note that it has respected the simple single and double quote cases as a UNIX shell would, and the single-inside-double case, but it stripped both layers off of the double-inside-single case, and didn't respect the backslash.

Judging from the examples in the documentation, some Windows C library that OpenSCAD has used allowed protecting double quotes by doubling them.  I don't know what variation this is from:
openscad.com -o my_model_production.stl -D "quality=""production""" my_model.scad

The documentation hints at how it really works in its description of running OpenSCAD from another programming language:

When executing OpenSCAD from another process in Unix, the single-quotes shouldn't be used e.g. from within a Java application:

   pb = new ProcessBuilder("/usr/bin/openscad",
     "-o", "my_model_production.stl",
     "-D", "quality=\"production\"",
     "my_model.scad");

but it's not exactly correct, or at least it doesn't lead to the right mental model.  It's not that OpenSCAD doesn't need the single quotes in that context - it's that they *are* needed in the shell context, but by the shell, not OpenSCAD itself.  Note that this Java invocation has also done several other things to the command - it's split the words into separate strings, and it's supplied an absolute path to the program, and it's backslash-quoted the double quotes so that they can be inside a Java string.

Anyhow, net, you always need to distinguish between what the command processor (perhaps augmented by the system-specific C library) will do to the command, and what the program proper will see.  If you don't keep that straight in your head, you'll run into trouble and apparently-mysterious behavior in more complex cases and when you move from system to system and command processor to command processor.


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: command line help

JordanBrown
On 3/7/2021 11:28 AM, Jordan Brown wrote:
On 3/7/2021 10:06 AM, nop head wrote:
For Linux you would need the outer single quotes but not for Windows. Windows is weird. 

Windows isn't weird.  It's just different.

(Well, OK, in some ways it's weird too.  But this really isn't one of them.)

Let me "walk that back" a little.

Windows *itself* isn't all that weird.  It's not UNIX, and it behaves differently.

But when you combine it with the behaviors of a variety of libraries embedded in applications, yes, the sum can be weird and inconsistent.


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: command line help

nophead
In any other languages outer quotes are stripped and don't appear in the final string. In Windows cmd they can enclose things like spaces but they also get included in the result, which in my book is weird. I can' think of any other language like that.

On Sun, 7 Mar 2021 at 19:33, Jordan Brown <[hidden email]> wrote:
On 3/7/2021 11:28 AM, Jordan Brown wrote:
On 3/7/2021 10:06 AM, nop head wrote:
For Linux you would need the outer single quotes but not for Windows. Windows is weird. 

Windows isn't weird.  It's just different.

(Well, OK, in some ways it's weird too.  But this really isn't one of them.)

Let me "walk that back" a little.

Windows *itself* isn't all that weird.  It's not UNIX, and it behaves differently.

But when you combine it with the behaviors of a variety of libraries embedded in applications, yes, the sum can be weird and inconsistent.


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: command line help

MichaelAtOz
Administrator
I tested command line stuff a while ago, my results went into the wiki.
Here is one of the batch files and output.

cd
set par1=val1=\"string with %%percent%%\"
echo. %par1%
openscad -o "test_o64d.stl" -D "val2=\"text\";" -D "%par1%" testd.scad
pause
Always use outer double-quotes (they get removed), always escape internal double-quotes.
Note the double percent in environment variable use.
You don't always need to quote the output filename, but some strange ones make it better to use them.
(it is probably good to also quote the input .scad filename)

C:\test\bit64>o64d.bat
C:\test\bit64>cd
C:\test\bit64
C:\test\bit64>set par1=val1=\"string with %percent%\"
C:\test\bit64>echo. val1=\"string with %percent%\"
 val1=\"string with %percent%\"
C:\test\bit64>openscad -o "test_o64d.stl" -D "val2=\"text\";" -D "val1=\"string with %percent%\"" testd.scad
ECHO: [2014, 12, 16]
ECHO: "hello c:\test\bit64\testd.scad"
ECHO: val1 = "string with %percent%", val2 = "text"
ECHO: "cylinder"
C:\test\bit64>pause
Press any key to continue . . .
testd.scad
// testd.scad
echo(version());
echo("hello c:\\test\\bit64\\testd.scad");
translate([0,0,-15])
cube(10);
echo(val1=val1,val2=val2);
if (val2=="text") {
        echo("cylinder");
        cylinder(r=10,h=20);
        }
else {
        echo("sphere");
        sphere(r=10);
        }
OpenSCAD Admin - email* me if you need anything, or if I've done something stupid...
* on the Forum, click on my MichaelAtOz label, there is a link to email me.

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.


Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
OpenSCAD Admin - email* me if you need anything, or if I've done something stupid...
* on the Forum, click on my MichaelAtOz label, there is a link to email me.

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.
Reply | Threaded
Open this post in threaded view
|

Re: command line help

MichaelAtOz
Administrator
I've worked out what's going on with the
warning that "val1" is an "unknown variable" for each of the used files, and too many unnamed arguments for one of the used files.
"unknown variable" is understandable, not a real warning, explainable but not ideal, I'll raise an issue to see if it's easily fixable.

Firstly "WARNING: Too many unnamed arguments supplied in file offset.scad, line 30 " is just the new warnings introduced with 2021.01, if you don't want them turn off
edit/preferences/advanced/'warn when there is a parameter mismatch in user module calls' 
offset.scad has:
module inset(thickness = 0.5, bbox = [5000, 5000, 5000]) {
  module invert() {  // <= No parameters, 
    difference() {
      cube(bbox, true);
      children();
    }        
  }

  render() {
    invert(0.9 * bbox) // <= too many unnamed parameters specified
      minkowski() {
        invert() children();
        cube([2 * thickness, 2 * thickness, 2 * thickness], center=true);
      }
  }
}

A bunch of "WARNING: variable t not specified as parameter in file some-file.scad, line 777 "

The write.scad module write() has only one defined parameter 'module write(word)' but is designed to
accept a range of other parameters, so when e.g.
write(txt, t = 2, h = sy/6, rotate = 270, center=true);
it warns about those undeclared parameters.

They can be dispensed with via that preference, or use text().

WARNING: Ignoring unknown variable 'optionVar' in file write.scad, line 381
WARNING: Ignoring unknown variable 'optionVar' in file fillet.scad, line 53
WARNING: Ignoring unknown variable 'optionVar' in file write.scad, line 381
WARNING: Ignoring unknown variable 'optionVar' in file write.scad, line 381

Only occurs with command-line use - literally 'use <>', it doesn't occur with 'include <>'.

Jon must be the first to use this specific method of input parameters via

-D myOption=optionVar.
(ie variable=a_variable - optionVar is declared in the main program)
It has nothing to do with quotes or double quotes.

Test case

//use-warning.scad
a="A";
b="B";
var=a; // variable assigned another variable
use <write.scad>      echo("use");
//include <write.scad>  echo("include");
echo(a=a,b=b,var=var);
write(var);
 
"C:\Program Files\openscad-2021.01\openscad" -o a.stl use-warning.scad --check-parameters false -D var=b
ECHO: "use"
ECHO: a = "A", b = "B", var = "B"
WARNING: Ignoring unknown variable 'b' in file write.scad, line 381
Geometries in cache: 9
Geometry cache size in bytes: 60384
CGAL Polyhedrons in cache: 0
CGAL cache size in bytes: 0
Total rendering time: 0:00:00.585
   Top level object is a 3D object:
   Facets:        136

The '-D var=val' was always a hack solution.
What it does is append 'var=val;' to the input files (in memory), this uses the Variables are set at compile-time, not run-time 'feature' so the appended 'var=val' overrides any/all 'var=' elsewhere in the file.

OpenSCAD is appending that to the 'use <>' files, I don't think it should.

In Jon's case 'myOption=optionVar' is appended to all three 'use <>'d files.
With 'use <>' because $variables may change, every call to a module must re-evaluate all expressions.
When it hits 'myOption=optionVar' it evaluates it, looks for the variable optionVar, because 'use <>' has it's own private scope, it does not find that variable, hence:

WARNING: Ignoring unknown variable 'optionVar' in file write.scad, line 381
WARNING: Ignoring unknown variable 'optionVar' in file fillet.scad, line 53
WARNING: Ignoring unknown variable 'optionVar' in file write.scad, line 381
WARNING: Ignoring unknown variable 'optionVar' in file write.scad, line 381

One for every module call to a 'use <>' file. Close observation shows those line numbers are beyond end-of-file.
'include <>' inherits the scope from the main file, so it finds optionVar, and has no error.

So, for now, either ignore it or utilise 'include <>' instead if there are no conflicting variables in the library.

OpenSCAD Admin - email* me if you need anything, or if I've done something stupid...
* on the Forum, click on my MichaelAtOz label, there is a link to email me.

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.


Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
OpenSCAD Admin - email* me if you need anything, or if I've done something stupid...
* on the Forum, click on my MichaelAtOz label, there is a link to email me.

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.