I've been finding AutoHotKey (AHK) excellent for automating repetitive Revit tasks. I'm going to share some of the scripts I've been using for my consulting work.
Writing an AHK script usually starts with using AutoScriptWriter II that comes with the AHK install. I go through the motions of the task I want to automate and it records some of the things I did. I then paste that text into my text editor (I'm liking PSPad.).
Things like mouse clicks obviously depend on one's screen resolution. There is a function to find a bitmap onscreen (to click on) but I haven't needed that yet.
When I'm recording I use the keyboard as much as possible. E.g.: Alt-Enter = Element Properties.
Reading the AHK help file obviously helps.
These lines go at the top of the AHK file:Here's a script where I select a solid in the family editor, hit F7, and it sets the solid's material to a new parameter called "Material". I had to do it for many families and each F7 saves me many keystrokes. The "MouseClick" line would have to be modified depending on one's screen size.Code:#SingleInstance force SetBatchLines, 10ms ; Slows the script down to 10ms per line, helps prevent it going to fast for Revit to handle
Code:F7:: ; hotkey for adding Material parameter to solid WinWait, Revit WinWaitActive, Revit Sleep, 100 Send, {ALTDOWN}{ENTER}{ALTUP} WinWait, Element Properties, Instance Parameters IfWinNotActive, Element Properties, Instance Parameters , WinActivate, Element Properties, Instance Parameters WinWaitActive, Element Properties, Instance Parameters MouseClick, left, 411, 430 Sleep, 100 WinWait, Associate Family Parameter, &Existing family par IfWinNotActive, Associate Family Parameter, &Existing family par, WinActivate, Associate Family Parameter, &Existing family par WinWaitActive, Associate Family Parameter, &Existing family par Send, {ALTDOWN}d{ALTUP} WinWait, Parameter Properties, (Cannot appear in sc IfWinNotActive, Parameter Properties, (Cannot appear in sc, WinActivate, Parameter Properties, (Cannot appear in sc WinWaitActive, Parameter Properties, (Cannot appear in sc Send, Material{TAB}m{ENTER}{ENTER}{ENTER} return