I meant to look at this before I left work and it's too late now so I'll have a look tomorrow. Just to clarify though, are you wanting the number you have divided by 1000 or something else? If you just want a simple sum done you can do it through the block editor. Right click on the attdef and use the Insert Field method. In the box that you build your field in you can insert a formula.
If you can find one of my TerminalRail blocks that I've posted here from time to time you MAY find one with a formula field. I divide the length of rail by the terminal width (and format it to an integer) to show the number of terminals. On more recent ones I also factor in the inserted scale so that they can be used in imperial drawings!