- Watch out
- What it costs
- Experienced readers
- Remember
- In BIMpedia
Most BIM people who automate didn't start as programmers. They started with a task they were tired of doing by hand. The trick is to choose the right task, describe it precisely, and only then build it.
- 1Written processThe steps, the inputs, the right result
- 2Checklist or templateSame result every time, still by hand
- 3Visual scriptDynamo or Grasshopper for one person’s task
- 4Team toolPython or pyRevit, tested, documented
- 5Scheduled serviceRuns on its own through APIs, feeds reports
Choose the task
Tasks done often, by many people, with clear rules pay back fast. Rare or fuzzy tasks rarely do; for those, a checklist is the better automation.
Good first tasks are frequent (done every week or every issue), rule-based (no judgement) and easy to check (you can see if it worked): numbering rooms, renaming views, filling a parameter from another, listing elements that break a rule.
Write the steps in plain words
Task: number rooms on each level from left to right, as 03-001, 03-002…
- For each level, get all rooms on that level.
- Sort the rooms by the X coordinate of their location point; if two have the same X, sort by Y.
- For each room in order, build the number: the level code, a dash, a three-digit sequence starting at 001.
- Write the number into the room's Number parameter.
- Skip rooms with no level, and list them at the end.
Step 2's tie-breaker and step 5's skip are the edge cases. Most first scripts fail on exactly these.
In Dynamo, each step is a node (get elements, sort, build text, set parameter), connected left to right. In Python (for example with pyRevit), the same steps are about 20 lines of text. Both call the same Revit API underneath.
The same steps in Python
from collections import defaultdict
rooms = get_rooms() # all placed rooms
by_level = defaultdict(list)
skipped = []
for room in rooms:
if room.level is None:
skipped.append(room) # step 5
else:
by_level[room.level.code].append(room)
for level, items in by_level.items():
items.sort(key=lambda r: (r.x, r.y)) # step 2, with tie-breaker
for i, room in enumerate(items, start=1):
room.number = f"{level}-{i:03d}" # steps 3 and 4
print("Rooms with no level:", [r.id for r in skipped])
get_rooms() and the room.x style properties stand for calls to the authoring tool's API; the shape of the logic is the point.
Your team fills the Department parameter of every room by hand from a spreadsheet: room number in one column, department in the other. It takes an hour per model update.
Write the plain-language steps of a script that does it, including at least three edge cases and what the script should do about each.
Key takeaways
- Good first tasks are frequent, rule-based and easy to check: numbering, renaming, filling parameters, simple checks.
- Write the steps in plain language first, including the edge cases.
- Visual (Dynamo, Grasshopper) is a fine start; move to Python when the task becomes a team tool.
- Test on a copy, check a sample, then run it for real, and keep a readme.
Your notes
Related tool
Define how rooms, sheets or assets are numbered and preview every new number.
Open Numbering Rule Builder →