Skip to main content

Input Directly in the Command Line

Input variables can be entered directly in the command line with the -i flag. The -i flag should be provided once for each notebook input, and inputs should be provided in the order in which they appear in the notebook.

Example Usage:

 "C:/Program Files/nTopology/nTopology/ntopcl.exe" -i "C:\nTopCLI_101\CLI-numtext" -i 7mm -i 7mm -i 7mm SampleFile.ntop

Supported Types

There is support for just two types directly in the command line:
  • Scalar (with or without units)
  • Text
Use the JSON option for support for more types.

Input From a JSON File

The input can also be processed with a JSON file containing the input values. Use the -j flag with the path to your JSON file that contains the inputs.

Example Usage:

  "C:/Program Files/nTopology/nTopology/ntopcl.exe" -j inputs.json SampleFile.ntop
The JSON file must contain a dictionary entry with the key inputs, pointing to an array of the individual notebook inputs. The basic structure of an individual input is as follows:
{
  "description: string,
  "name": string,
  "type": string,
  "value": type,
  "units": string
}
Note that description is optional and units may be required, optional, or ignored depending on the type (see Supported Types for type specific information). All other fields are required.

An example of a valid JSON file:

    {
        "description": "",
        "inputs": [
            {
                "description": "",
                "name": "Output directory",
                "type": "text",
                "value": "C:\\CLI-numtext\\"
            },
            {
                "description": "",
                "name": "Length",
                "type": "real",
                "units": "mm",
                "value": 7.0
            },
            {
                "description": "",
                "name": "Width",
                "type": "real",
                "units": "mm",
                "value": 2.0
            },
            {
                "description": "",
                "name": "Height",
                "type": "real",
                "units": "mm",
                "value": 2.0
            }
        ],
        "title": "Surface Area of Box"
    }

Creating a JSON template

You can compose your own JSON file in your favorite code editor. Alternatively, use the —template (-t) flag to create input and output template files in JSON that you can modify and pass back in. These files will write to your current directory.

Example Usage:

    "C:/Program Files/nTopology/nTopology/ntopcl.exe" --template SampleFile.ntop
or
"C:/Program Files/nTopology/nTopology/ntopcl.exe" -t SampleFile.ntop

Supported Types

nTop can load boolean, integer, scalar, text, file path, vector, point, and enum input types from a JSON file.
Variable TypeCommentExample
BooleanEach value should be true or false, not enclosed in quotes.{"name": "Rotate Y to Z", "type": "bool", "value": true}
ScalarEach value can be an integer or a float. Units are optional.{"name": "Scalar_0", "type": "scalar", "value": 5, "units": "mm"}
IntegerEach value must be an integer, without units.{"name": "Number of points", "type": "integer", "value": 6}
TextEach value should be a string.{"name": "Text_0", "type": "text", "value": "d:\\auto"}
File PathEach value should be a valid file path as a string. Paths require double slashes due to JSON string rules.{"name": "Path", "type": "file_path", "value": "C:\\Outputs\\geometry.stl"}
PointEach value should be an array of integers or floats.{"name": "Center", "type": "point", "value": [1, 1, 1], "units": "mm"}
VectorEach value should be an array of integers or floats. Units are optional (some vectors require units — if not provided, the notebook will not run).{"name": "Scale", "type": "vector", "value": [1, 1, 1], "units": "mm"}
EnumEnums refer to input types selected from a dropdown in nTopology. Each value should be an integer representing the enum’s id. You can find the id of your enum here.{"name": "Lattice Type", "type": "enum", "value": 0}

JSON with input arrays for iterative execution

There is also an option to provide an array of values, allowing the user to specify multiple sets of inputs, so that the notebook runs once for each set. This provides a particular advantage when the notebook takes a long time to load – this way, it need only be loaded once by nTop, and then it can be run many times. For this option, each input would look like:
{
  "name": string,
  "type": string,
  "values": array,
  "units": string
}
In that case, an example of valid JSON looks like:
{
  "inputs": [
    {
      "name": "Resolution",
      "type": "scalar",
      "values": [2.5, 3.1],
      "units": "mm"
    },
    {
      "name": "Path",
      "type": "file_path",
      "values": ["d:\\auto", "d:\\auto"]
    }
  ]
}
Note that the inputs can be in any order, but each one must be uniquely identified by its name. If two inputs have the same name the behavior is undefined. Also note that when nTop is run with multiple sets of inputs (i.e. with values), each input must contain the same number of values, with the exception that any inputs that are to remain constant for each run can be specified just once. For example, the following input data is valid, and in this case, the notebook is built three times, with a different value for Path and Position on each run, but the same value for Scale and Rotation:
{
  "inputs": [
    {
      "name": "Scale",
      "type": "vector",
      "values": [[0.003, 0.003, 0.003]],
      "units": "m"
    },
    {
      "name": "Path",
      "type": "file_path",
      "values": ["C:\\Outputs\\output1.stl", "C:\\Outputs\\output2.stl", "C:\\Outputs\\output3.stl"]
    },
    {
      "name": "Rotation",
      "type": "vector",
      "values": [[1, 1, 1]]
    },
    {
      "name": "Position",
      "type": "point",
      "values": [[0, 0, 0], [4, 5, 6], [8, 9, 7]],
      "units": "mm"
    }
  ]
}