Writing against an API nobody documented
InfraWorks has a script console. What sits behind it, the objects, the tables, the rules for adding anything to a model, is almost entirely unwritten. I wanted it to place traffic signal equipment at an intersection: the signals, the manholes, and the conduit that connects them. So before we could write any of that, we had to find out how InfraWorks actually works.
Here is what that looked like in numbers. The finished project is 24 scripts. Three of them do the real work. Eighteen of them exist only to ask InfraWorks a question, and they hold 1,742 of the 2,687 lines. About two thirds of everything we wrote never placed a single object.
The signals that weren't there
The first placement script ran clean. The signals were in the database, at the right coordinates, with the right style. And nothing showed up on screen.
What do you do with that? You stop guessing. I placed one signal by hand and let the script place another, and then we compared the two, field by field. Almost everything matched. The difference was the geometry itself: the one I placed by hand was stored in 2D, and the script's was 3D. InfraWorks will happily store a 3D point for a signal. It just won't draw one.
That took four separate question scripts to pin down. The fix was one line.
How the loop worked
Claude cannot reach InfraWorks. I can. So every experiment went the same way: Claude wrote a script that asked one question, I pasted it into the console, and I reported back what came out. And what came out was always an error message, because the console has no other way to show you anything. A thrown error is the only output there is.
Each round took minutes, not seconds. That is slow. It is also how you learn a system nobody has written down.
What is still open
One script is not finished. Selective delete finds exactly the right items and then removes more than it should. I have ruled out four causes so far. I would rather say so here than pretend the job is done.
The part worth keeping
The placement scripts solve my problem. The question scripts are what make the next problem easier, mine or anybody's. Each one records something InfraWorks does that is written down nowhere else. When the manual doesn't exist, the notes you keep while finding out become the manual.
Be Better - write down what you find.