Script Editor
Script Editor
PCSWMM Support
Articles
Back
Script Editor
As part of PCSWMM's scripting capability, the Script Editor supports the creation,
execution and management of Python scripts.
The Script Editor comprises three sections: the script manager, the code editor and the
output window. The script manager is used to create, duplicate, order, rename, save,
delete, and filter the displayed scripts. The code editor provides intellisense, auto-
completion, syntax highlighting, as well as multi-line commenting, search/replace
functionality and tagging scripts (for filtering in the script manager). The resizable
output window provides an option for scripts to print text (for debugging or outputting
results).
Scripts are stored as separate files with the " .py " file extension in the App Data folder
(i.e. C:\Users\<username>\AppData\Roaming\PCSWMM\Scripts) and are available in all
projects.
New
Creates a new script. A New Script dialog will open requiring a unique script name.
Duplicate
Duplicates the current script. A Duplicate Script dialog will open prompting for a unique
script name.
Arrange
Move Top
Moves the selected script to the top.
Move Up
Moves the selected script up one.
Move Down
Move Bottom
Moves the selected script to the bottom.
Rename
Renames the current script. A Rename Script dialog will appear for the user to input a
new script name.
Save
Delete
Filter
Project
Filters the list of scripts to only show those used previously with the currently open
project.
All
Displays all the scripts which are saved to the App Data folder (C:\Users\<user
name>\AppData\Roaming\PCSWMM) on the user's computer.
Tags
Filters the list of scripts to only show those with the selected tag. Tags are optionally
defined in the script itself to classify or group scripts in the script manager. A script can
have multiple tags defined. Tags are defined in a comment (either a separate comment
line or an inline comment) anywhere in a script file. The tag definition has the format:
Comment/Uncomment (Ctrl + Q)
Comment or uncomment selected code line(s). If a selected line does not have the
pound sign (#) as its first character, a pound sign will be inserted at the line start. If a
selected line has a pound sign as its first character, the pound sign will be removed.
Open the Find/Replace dialog to find certain text and optionally replace it with new text,
within the current script file.
Clear Output
Clear the content in the Output Window.
Copy Output
Copy the content in the Output Window to the Microsoft Windows clipboard for pasting
to other programs (e.g. Excel file) for further data analysis. If the content contains time
series in a delimited tabular format, it can be directly pasted in the Graph panel.
Close
Close the script editor.
Shortcut Keys
Additional to the buttons, several keyboard shortcut keys are supported to work with
the Script Editor:
F6: run the current script.
Esc: close the Script Editor when the code editor is not focused.
Ctrl + F: open the Find/Replace window, with the Find tab activated. Note when the
Map panel or the Graph panel is focused this key combination will open the Select
by Query window or Find time series window, respectively.
Ctrl + H: open the Find/Replace window, with the Replace tab activated.
Ctrl + S: save the current script if the Script Editor is focused. Note when the Map
panel is focused this key combination will save the current project.
Ctrl + N: open the New Script window to create a new script.
Ctrl + V: paste the selected text at the current cursor position in the Script Editor.