Add functions
Every public add endpoint, required/optional inputs, implementation status, coordinate rules, references, and examples.
Open section
swmmx Documentation
Add and remove paths follow m.add.<category>.<element_type>() and m.remove.<category>.<element_type>(). The API validates IDs, required fields, numeric values, enum-like inputs, and references before editing the INP document.
from swmmx import swmm
m = swmm(new="SI")
m.add.node.junction("J1", x=0.0, y=0.0, invert_elevation=10, max_depth=3)
m.add.node.outfall("OUT1", x=100.0, y=0.0, invert_elevation=9, type="FREE")
m.add.link.conduit(
"C1",
from_node="J1",
to_node="OUT1",
length=100,
roughness=0.013,
shape="CIRCULAR",
diameter=1.0,
)
m.add.time.time_series("Rain1", data=[("2026-01-01 00:00", 0.0), ("2026-01-01 00:05", 5.0)])
m.add.hydrology.rain_gage("RG1", format="INTENSITY", interval="00:05", source_type="TIMESERIES", time_series="Rain1")
m.add.hydrology.subcatchment("S1", rain_gage="RG1", outlet="J1", x=0.0, y=0.0, area=1.0)
m.save("new_model.inp")
m.remove.link.conduit("C1")
| Topic | Behavior |
|---|---|
| References | Referenced nodes, curves, time series, and related objects must exist before use. |
| Coordinates | Nodes require explicit x/y; subcatchments require centroid coordinates; rain gages can default to mapped extents. |
| Removal checks | Dependencies block deletion by default. |
force=True | Performs only conservative implemented cascades, such as dependent conduit removal for some node deletions. |
| State flags | Add/remove sets m.modified; if results exist, m.results_stale becomes true. |
m.add_element("node", "junction", "J2", x=200.0, y=0.0, invert_elevation=11, max_depth=2)
m.remove_element("node", "junction", "J2")
Every public add endpoint, required/optional inputs, implementation status, coordinate rules, references, and examples.
Open sectionEvery public remove endpoint, ids input, force behavior, dependency checks, output summaries, and reserved endpoints.
Open section