3.3.2. 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:
Print the whole model:
- printModel <-JSON> <-file $fileName>
Print the nodes:
- printModel <-file $fileName> -node <-flag $flag> <$node1 $node2 ...>
Print the elements:
- printModel <-file $fileName> -ele <-flag $flag> <$ele1 $ele2 ...>
# 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)
Argument |
Type |
Description |
|---|---|---|
-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 … |
list integer |
tags of the nodes to print (optional: default = all nodes) |
$ele1 $ele2 … |
list integer |
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,-filemust be given.
Warning
-JSON must be followed by -file, i.e.
printModel -JSON -file model.json. In Tcl,printModel -JSONon its own, orprintModel -file model.json -JSON, stops the program. In Python,-JSONafter-filewrites nothing.-node -flag 1stops the program if a node printed has no displacements yet, e.g. a node that is not connected to any element.
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.
printModel -ele
printModel -node -flag 1 1 2
printModel -JSON -file model.json
ops.printModel('-ele')
ops.printModel('-node', '-flag', 1, 1, 2)
ops.printModel('-JSON', '-file', 'model.json')
Code Developed by: fmk