Pass parameters via command line

1 view
Skip to first unread message

Wink Saville

unread,
Jun 13, 2020, 12:41:05 PM6/13/20
to cu...@googlegroups.com
Is there a way to pass parameters via the command line?

For example, here and duplicated below, Doug provided code that shows how you can change the boxMitred boolean to select between cube or sphere (or box.mitred | box) at runtime:

let
  if_shape[c,s1,s2] = make_shape {
    dist p = if (c) s1.dist p else s2.dist p;
    colour p = if (c) s1.colour p else s2.colour p;
    bbox = [min[s1.bbox[MIN],s2.bbox[MIN]],max[s1.bbox[MAX],s2.bbox[MAX]]];
    is_2d = s1.is_2d && s2.is_2d;
    is_3d = s1.is_3d && s2.is_3d;
  };
  dim = [25,25,25];
in
parametric
  boxMitred :: checkbox = true;
in
  //if_shape[boxMitred, box.mitred dim, box dim]
  if_shape[boxMitred, cube, sphere]

But I'd also like to be able to control the boxMitred boolean, or other values, from the command line. Say, when I output a ".obj" file for my 3D printer or maybe to change the default condition for boxMitred when starting curv in the "live" mode. Be nice for the future if now available now.

-- wink

Doug Moen

unread,
Jun 13, 2020, 1:37:39 PM6/13/20
to Curv
Yes, there is a way to do this.

Let's say this source file is named `mitred.curv`.

You can render the file using
     curv mitred.curv
but this is really an abbreviation for
     curv -x 'file "mitred.curv"'
The '-x' flag interprets the command line argument as a Curv expression, rather than as a file name.

To change the value of 'boxMitred' from the command line, you can use:
    curv -x 'file "mitred.curv" {boxMitred:false}'

That will work for changing parameters, for the purpose of outputting a '.obj' file.

However, an unfortunate side effect of this technique is that the value pickers (the check box, in this case) disappear from the GUI. This is a minor bug. I haven't been setting parameters from the command line during interactive use, or I would have noticed and fixed this already.

Doug Moen.
--
You received this message because you are subscribed to the Google Groups "Curv" group.
To unsubscribe from this group and stop receiving emails from it, send an email to curv+uns...@googlegroups.com.

Wink Saville

unread,
Jun 13, 2020, 2:49:26 PM6/13/20
to Doug Moen, Curv
Great, txs.
Reply all
Reply to author
Forward
0 new messages