https://github.com/mayconrfreitas/revitapisnippets
Revit API snippets for Visual Studio.
https://github.com/mayconrfreitas/revitapisnippets
api autodesk csharp revit revit-api revitapi snippets visual-studio
Last synced: 14 days ago
JSON representation
Revit API snippets for Visual Studio.
- Host: GitHub
- URL: https://github.com/mayconrfreitas/revitapisnippets
- Owner: mayconrfreitas
- License: mit
- Created: 2022-05-12T20:30:49.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2025-03-04T22:08:03.000Z (about 2 months ago)
- Last Synced: 2025-04-15T00:16:49.714Z (14 days ago)
- Topics: api, autodesk, csharp, revit, revit-api, revitapi, snippets, visual-studio
- Language: Vim Snippet
- Homepage:
- Size: 1.59 MB
- Stars: 24
- Watchers: 3
- Forks: 9
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# RevitAPISnippets
Revit API snippets for Visual Studio and JetBrains Rider.
[](#)
[](#)
[](https://github.com/mayconrfreitas/RevitAPISnippets/releases)
[](https://github.com/mayconrfreitas/RevitAPISnippets/stargazers)
[](https://github.com/mayconrfreitas/RevitAPISnippets/network/members)
[](https://github.com/mayconrfreitas/RevitAPISnippets/issues)
[](https://github.com/mayconrfreitas/RevitAPISnippets/issues?q=is%3Aissue+is%3Aclosed)
[](https://github.com/mayconrfreitas/RevitAPISnippets/graphs/contributors)
[](LICENSE)## Installation For Visual Studio
1. [Download](https://github.com/mayconrfreitas/RevitAPISnippets/archive/refs/heads/main.zip) or [clone](git-client://clone?repo=https%3A%2F%2Fgithub.com%2Fmayconrfreitas%2FRevitAPISnippets) this repo;
2. On Visual Studio, go to `Tools > Code Snippets Manager...` or press Ctrl + K and Ctrl + B;
3. Click on `Add` button.
4. Navigate to the folder where you saved this repo;
5. Open the repo [`Folder > Snippets`](./Snippets/) and Select the RevitAPI folder according to your Revit version (E.g.: [`RevitAPI2020`](./Snippets/RevitAPI2020/));
6. Click on `OK`.## Installation For JetBrains Rider
Download the Settings File (.zip) for Rider and Import to your project. You can leave this file zipped as when we import these settings, we will need a zip file.After download, open Rider. Click on File > Manage IDE Settings > Import Settings...

Navigate to the zip file downloaded and click "Select Folder".

You should see a new dialog display that asks if you desire to import the Live Templates

Finally, Restart Rider.

## How to use
1. After installation, type the command (as in the [Snippets List](#snippets)) `command` and press tab 2x;
![]()
2. Use tab to navigate through fields and edit them as you wish;
![]()
3. Press enter to complete the command.
### [](https://youtu.be/moD7CYUkJHw) Watch this [video](https://youtu.be/moD7CYUkJHw) to see a more detailed use of Revit API snippets.
---
## Snippets
Below is a hyperlink to each individual .snippet for Visual Studio. JetBrains Rider code is the exact same, but the settings cannot be visualized the same way on GitHub.
List of snippets ready to use:
| Command | Description |
|------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------|
| [rvtiexcom](./Snippets/RevitAPI2020/CreateIExternalCommand.snippet) | Creates a sample of a IExternal Command implemented with the main codes. |
| [rvtallinstcat](./Snippets/RevitAPI2020/Collector/CollectAllInstancesByCategory.snippett) | Collects all instances in the project by the builtin category. |
| [rvtalltypescat](./Snippets/RevitAPI2020/Collector/CollectAllTypesByCategory.snippet) | Collects all element types in the project by the builtin category. |
| [rvtgetparamdoub](./Snippets/RevitAPI2020/Parameters/GetParameterValueAsDouble.snippet) | Gets a parameter value as a double. |
| [rvtgetparamelmid](./Snippets/RevitAPI2020/Parameters/GetParameterValueAsElementId.snippet) | Gets a parameter value as an ElementId. |
| [rvtgetparamint](./Snippets/RevitAPI2020/Parameters/GetParameterValueAsInteger.snippet) | Gets a parameter value as an integer. |
| [rvtgetparamstr](./Snippets/RevitAPI2020/Parameters/GetParameterValueAsString.snippet) | Get Parameter Value As String. |
| [rvtgetparamvalstr](./Snippets/RevitAPI2020/Parameters/GetParameterValueAsValueString.snippet) | Get Parameter Value As Value String. |
| [rvtsetparam](./Snippets/RevitAPI2020/Parameters/SetParameterValue.snippet) | Set Parameter Value. |
| [rvtsetparamstr](./Snippets/RevitAPI2020/Parameters/SetParameterValueString.snippet) | Set Parameter Value String. |
| [rvtselfilt](./Snippets/RevitAPI2020/Selection/CreateSelectionFilter.snippet) | Creates a sample of a Selection Filter code implementing ISelectionFilter interface. |
| [rvtgetsel](./Snippets/RevitAPI2020/Selection/GetSelectedElements.snippet) | Gets the elements in the model. |
| [rvtpickelms](./Snippets/RevitAPI2020/Selection/SelectElements.snippet) | Creates a selection of elements in the model. |
| [rvttrans](./Snippets/RevitAPI2020/Transactions/CreateTransaction.snippet) | Creates a sample of a Transaction code. |
---## Contributors
If you have any snippets that you think might be interesting to share, follow the steps below to contribute to this project:
### Instructions
1. [Fork](https://github.com/mayconrfreitas/RevitAPISnippets/fork) this repo;
2. Use the `template` inside [`Snippets > Templates > Csharp.snippet`](./Snippets/Templates/Csharp.snippet);
3. Use the **prefix** `rvt` to name your **shortcut** (E.g.: `rvt` + `getsel` (abbreviation to Get Selection) = [`rvtgetsel`](./Snippets/RevitAPI2020/Selection/GetSelectedElements.snippet));
4. **Be sure** that your shortcut doesn't exist in the [Snippets List](#snippets);
5. Write your snippets in **individual files** grouped inside folders of their **respective subject** (E.g.: [rvtselfilt](./Snippets/RevitAPI2020/Selection/CreateSelectionFilter.snippet) is inside [Selection](./Snippets/RevitAPI2020/Selection/) folder);
6. `Commit` and `Push` your changes to your forked repo;
7. Send a `Pull Request` to [Develop branch](https://github.com/mayconrfreitas/RevitAPISnippets/tree/develop).### More Information
For more information, feel free to contact me via email `[email protected]` or [LinkedIn](https://www.linkedin.com/in/maycon-freitas/).
---
## License
This project is [licensed](LICENSE) under the [MIT Licence](https://en.wikipedia.org/wiki/MIT_License).
---
Do you like this solution? Please [star this project on GitHub](../../stargazers)!