.. _printModel: printModel Command ****************** This command is used to print information about the model, e.g. the nodes and elements, to the screen or a file. There are several forms of the command: .. tabs:: .. tab:: Tcl 1. Print the whole model: .. function:: printModel <-JSON> <-file $fileName> 2. Print the nodes: .. function:: printModel <-file $fileName> -node <-flag $flag> <$node1 $node2 ...> 3. Print the elements: .. function:: printModel <-file $fileName> -ele <-flag $flag> <$ele1 $ele2 ...> .. tab:: Python .. code-block:: python # 1. print the whole model ops.printModel('-JSON', '-file', fileName) # 2. print the nodes ops.printModel('-file', fileName, '-node', '-flag', flag, *nodeTags) # 3. print the elements ops.printModel('-file', fileName, '-ele', '-flag', flag, *eleTags) .. csv-table:: :header: "Argument", "Type", "Description" :widths: 10, 10, 40 -JSON, |string|, "write the whole model in JSON format, e.g. for use by other programs (optional)" $fileName, |string|, "name of the file to which the information is written; text output is added to the end of an existing file, while JSON output overwrites it (optional: default = the screen)" $node1 $node2 ..., |listInt|, "tags of the nodes to print (optional: default = all nodes)" $ele1 $ele2 ..., |listInt|, "tags of the elements to print (optional: default = all elements)" $flag, |integer|, "flag passed to the print method of each object, which may print more or different information depending on its type (optional: default = 0, the full current state). For nodes, a flag of **1** prints only the node tag and its displacements" .. note:: #. Without any options, the whole model is printed to the screen. #. Only one of **-node** or **-ele** can be given in a command. Anything after it is read as its arguments. #. **-file** must come before **-node** or **-ele**. #. In Tcl, the dashes may be left out, e.g. ``printModel node 1 2``, and the file name may be given without ``-file``, e.g. ``printModel out.txt -node``. In Python, ``-file`` must be given. .. warning:: #. **-JSON** must be followed by **-file**, i.e. ``printModel -JSON -file model.json``. In Tcl, ``printModel -JSON`` on its own, or ``printModel -file model.json -JSON``, stops the program. In Python, ``-JSON`` after ``-file`` writes nothing. #. ``-node -flag 1`` stops the program if a node printed has no displacements yet, e.g. a node that is not connected to any element. .. admonition:: Example: The following example prints all elements, then the tags and displacements (flag **1**) of nodes **1** and **2**, and then writes the whole model in JSON format to the file ``model.json``. .. tabs:: .. tab:: Tcl .. code-block:: tcl printModel -ele printModel -node -flag 1 1 2 printModel -JSON -file model.json .. tab:: Python .. code-block:: python ops.printModel('-ele') ops.printModel('-node', '-flag', 1, 1, 2) ops.printModel('-JSON', '-file', 'model.json') Code Developed by: |fmk|