Back to the beginning with a quick look at the Revit MEP API, and a great step forward for RevitPythonShell:
Question: I am trying to develop some Revit add-ins.
I would like to know how to enable the user to insert a predefined MEP component in a model and how to detect programmatically whether two components are connected, for example two pipes.
Could you please let me know where I can find the related information?
Do you have any related examples to share with me?
Answer: Welcome to the Revit API!
The Building Coder shares a wealth of information on getting started with the Revit API.
However, before you start even thinking about programming, it is important to gain some fundamental understanding of the BIM, the BIM paradigm and BIM processes.
Furthermore, you should determine in detail exactly how to address your task manually through the end user interface making use of the optimal workflows and respecting best practices, before you start trying to automate the task.
All the questions you raise are addressed by and demonstrated in the Revit SDK samples. The SDK can be downloaded from the official Autodesk Revit developer page.
MEP components are represented by family instances, so you can simply use generic code to insert a family instance.
However, there are also many MEP-specific enhancements that may or may not apply.
To determine whether two pipes are connected, you simply query them for their connectors, represented by
It has a ConnectorManager property.
That in turn proves access to the neighbouring parts' connectors.
System traversal is also demonstrated by some of the SDK samples.
In addition to the official sample material from Autodesk, you can also check out The Building Coder blog. My favourite articles from there on connecting pipes is the series exploring how to create a rolling offset.
Here are two other articles from The Building Coder on system traversal:
RevitPythonShell was apparently nearing the end of its active life when its author Daren Thomas moved on to other things.
Now new life has been breathed into the faltering project by Chuong Ho or Hồ Văn Chương, with numerous contributions:
- Updated for Revit 2023
- Implemented a CI pipeline for continuous integration
- Added new powerful functionality by hooking it up directly with RevitLookup
So, now you can snoop your database directly in an interactive REPL command line console, a so-called read–eval–print loop, providing powerful database exploration functionality par excellence, never previously available to such an extent.
Here are some of the pull requests and issues implementing this:
- Automatic Process CI/CD Maintain Support 2023 #122
- Need create a branch dev to collaborator #123
- Update Support use method from revitlookup to snoop #124
The new RevitPythonShell release 1.0.1 includes:
- Add Process CI/CD Automatic
- Fix Problem show owner window
- Upgrade process use SDK Style .NET6
- Improve Codebase build button
- Fix minimize form window
- Support installation in one single file msi from Revit 2018 to Revit 2023
- Version number changed due to single msi installer for all versions, e.g., from 2023.0.0 to 1.0.0
Here is a direct link to the installer:
Ever so many thanks to Chuong Ho for this brilliant work!
Talking about REPL and loops, watch out...