Revit Development: Starting with Revit

autodesk-revit-badge-1024px.jpg

There are many Revit API development tutorials available online, covering a wide range of topics. However, one problem that some developers may face after completing these tutorials is how to independently carry out development on their own.

 

In addition to the development logic mentioned in the previous article, mastering how to quickly search for Revit API is also an essential skill for developers.

 

Autodesk Revit is a globally used software that supports multiple languages, but the API in the code uses English keywords. This article will introduce methods to help non-English speaking developers quickly develop and find the necessary information.

 

This article will introduce two methods for quickly finding Revit API references to help everyone develop more efficiently.

 

Quickly Retrieve Keywords in Revit via API

After completing the tutorials or SDK code study, many developers hope to further expand their development based on what they have learned. However, they often encounter the dilemma of having a development idea but struggling to find the corresponding API keywords.

 

At this point, we can solve this problem using the following method: by checking the keywords in the English interface, we can quickly locate the corresponding functions or methods in the API. This approach can effectively shorten the search time and improve development efficiency.

Modify Revit properties

  • Right-click on Revit and click Properties
  • Modify the highlighted bar to end with ENU, and use the End key to quickly navigate to the end.
  • scgq425_0-1737773710249.png

KeyWord

  1. After opening Revit, you can see the English names of all component categories. Similar to the method names in the API, we can quickly search for APIs in this way and obtain the required methods for the next steps. In the API, we can quickly find them based on keywords.
    • 轴网 - grille -Grid
    • 墙 - mur - Wall
    • 零件 - partie - Part(The part creation function is in PartUtil. By understanding the English name of the part and searching for the keyword in the API documentation, we can quickly find all the methods related to the part.)

scgq425_1-1737773733442.png

 

 

    • Select Filter: This cannot be directly created in our operation, but it is possible to create a component collection in the API and attach the desired display style in the view filter. For example, as shown in the image below, we can directly enter "Selection Filter" in the API to get the method.
      scgq425_2-1737773749661.png

       


      Operation Steps + English Keywords

  • This situation is due to the limited introduction of this part of the API on the internet, but by using the operations in Revit to assist with English keywords, we can quickly find the corresponding API location.
  • For example, in the case below: we want to control the visibility of components via code.
  • Switch to the English version of Revit and manually perform the following steps.
  • Press the shortcut key "vv" to bring up the command window.
  • We can select the component categories to hide and apply the action. The corresponding categories in Revit will be hidden. From the screenshot, we can see that the subname of the window is "Model Categories".

scgq425_3-1737773775969.png

 

 

  • At this point, we can search for the keyword "Category" in the API to view the related classes. As shown in the image, the API returns many classes, and searching through them one by one is obviously very time-consuming. 
  • Therefore, we can incorporate the operational logic into the analysis. For example, when modeling, we know that each view can independently control the visibility of family categories. This suggests that the method is likely located in the View class, or it might be a function that requires passing a View parameter. By using this logical deduction, we can more precisely narrow the search scope and improve efficiency.
  • By continuing to look at the methods under View related to Category, we can see several key functions like GetCategoryHidden and SetCategoryHidden. The explanations for these two functions indicate that they are used for controlling the visibility of family categories in the current view.scgq425_6-1737773812579.png
    • When we try running this code, we can see that the wall disappears, and the wall category is also hidden in the 'vv' command. By incorporating the operation logic and shortcut keys, we were able to quickly locate an unfamiliar API method.
    • doc.ActiveView.SetCategoryHidden(new ElementId(BuiltInCategory.OST_Walls),true);

 

Revit Hidden Category.gif

Search Log

Revit records user operation logs. In certain cases, if you want to quickly find the method corresponding to a command, you can first perform the related operation in Revit and then quickly search the log for keywords.

The log is located at: %localappdata%\Autodesk\Revit\Autodesk Revit 2024\Journals

Additionally, if you wish to directly invoke Revit's built-in commands to perform certain operations, information about these commands can also be found in the log files. This method can not only speed up problem localization during development but also help developers better understand Revit's internal command structure, leading to more efficient implementation of the desired functionality.

Calling Revit's built-in commands (using the View Visibility Settings Browser as an example):

1. In Revit, use the shortcut "vv" to open the window and then close it.

2. Open the log file and find the last edited command. You will see in the log that we performed the operation using the shortcut key, and the command is ID_VIEW_CATEGORY_VISIBILITY.

scgq425_7-1737773882114.png

 

By doing this, we can call this command in the code to open the Visibility Management.
UiApplication.PostCommand(RevitCommandId.LookupCommandId("ID_VIEW_CATEGORY_VISIBILITY"));

Video_2025-01-14_165042.gif

 

Use logs to quickly search for API keywords

Searching through log keywords is similar to the method of searching for keywords in the English version of Revit. If you prefer not to switch back and forth, you can quickly search for keywords through the logs and make modifications in the API.

Create Curtain Wall Grid

  1. After creating the curtain wall grid in Revit, you can open the log file and find the keyword CurtainGrid.

scgq425_9-1737773968487.png

     2. By entering the keyword into the API, you can see all the methods. This way, you can quickly find the relevant method.

Summary of this article

Through the above two methods, developers learning Revit (especially those whose first language is not English) can transition more efficiently from daily production operations to development practice. These methods help developers leverage their strengths in design and modeling operations to quickly master the use of Revit API and the hierarchical logic involved in development, allowing them to better apply theory to real-world projects.

This approach not only helps developers digest knowledge from tutorials or books more easily but also provides a more natural transition, gradually shifting from familiar modeling tasks to a development role.

 

Furthermore, by combining Revit operation experience with development skills, developers gain a deeper understanding of Revit's architecture and working principles, thus laying a solid foundation for more complex development tasks. It is hoped that the content of this article can inspire readers, enabling more developers to quickly adapt to and master Revit's secondary development, thereby contributing to improved work efficiency and innovation capabilities.