Sunday, December 16, 2012

revit 2012 Application macro set up tutorials

Revit application macro is easy to develop using vsta. And easy to debug. If you are not aiming to sell your program, and not care about sharing the source code, it is a good and time saving tool. To deploy it is as easy as copying you module file under your revit.
The main tricks for setting up revit application Macro is reference passing. In ThisApplication.cs , the module class, you need to pass 'this',which is the running application itself to your macro class.

In your macro class, you need to define 3 variables,
1. m_app point to running application
2. m_uidoc point to active uidocument , you can use it to get user selection, etc.
3. m_doc point to current active document, the opening revit file you want to modify.

now is the form class, the user interface to take user input if necessary. it is created as an object inside your macro class. just make the controls (elements) public for easy access from macro class. for example:
mainFrame.Textbox1.Text will return you the text input from textbox1(a text field)
also when create this form in macro class, you need to pass macro class itself to it using 'this' key word. the corresponding variable in form class is m_dataBuffer. if you want to access macro class, you can call m_dataBuffer.methodYouWant().

overall, you need 3 files, ThisApplication.cs is created for you by macro manager. ClassMacro.cs for put your business logic(thing to do, to interactive with revit file), Form.cs to interactive with user. put classmacro and form file in a folder for easy management in future.

 below are video tutorials:




No comments: