For programmatic control, use the ProcessMap class and its associated methods. This approach allows you to build complex diagrams using Python objects, providing fine-grained control over pools, lanes, and element types.
Core components:
ProcessMap(title, colour_theme): The root container for the diagram.add_pool(name): Adds a new pool to the map.add_lane(name): Adds a lane to a pool or the map.add_element(label, type): Adds an element (Event, Activity, or Gateway) to a lane.element.connect(target, label): Creates a directed connection between elements, supporting method chaining.draw(): Renders the diagram.save(filename): Exports the diagram to a file (supports PNG and SVG).
from processpiper import ProcessMap, EventType, ActivityType, GatewayType
with ProcessMap(
"Sample Test Process", colour_theme="BLUEMOUNTAIN") as my_process_map:
with my_process_map.add_lane("End User") as lane1:
start = lane1.add_element("Start", EventType.START)
enter_keyword = lane1.add_element("Enter Keyword", ActivityType.TASK)
with my_process_map.add_pool("System Search") as pool1:
with pool1.add_lane("Database System") as lane2:
login = lane2.add_element("Login", ActivityType.TASK)
search_records = lane2.add_element("Search Records", ActivityType.TASK)
result_found = lane2.add_element("Result Found?", GatewayType.EXCLUSIVE)
display_result = lane2.add_element("Display Result", ActivityType.TASK)
logout = lane2.add_element("Logout", ActivityType.TASK)
end = lane2.add_element("End", EventType.END)
with pool1.add_lane("Log System") as lane3:
log_error = lane3.add_element("Log Error", ActivityType.TASK)
start.connect(login, "User \nAuthenticates").connect(
enter_keyword, "Authenticated"
).connect(search_records, "Search Criteria")
search_records.connect(result_found, "Result").connect(display_result, "Yes")
display_result.connect(logout).connect(end)
result_found.connect(log_error, "No").connect(display_result)
my_process_map.set_footer("Generated by ProcessPiper")
my_process_map.draw()
my_process_map.save("my_process_map.png")