They may be calculated dynamically and not stored at all. Here is what Gemini thinks about this:
Let's dive into the intricacies of accessing duct pressure information in Revit via the API. You're right, the Total and Static Pressure values displayed by the System Inspector aren't directly stored as parameters on the duct elements or the MEPSystem. Revit calculates these dynamically during duct sizing and analysis. Therefore, you can't directly retrieve them as stored properties.
Here's a breakdown of how to get the pressure information, combining best practices and addressing the nuances of the Revit API:
Understanding the Challenge:
The pressure calculations are performed by Revit's internal analysis engine. The API doesn't expose the raw calculated values directly. We need to leverage the analysis results indirectly.
Solution Strategy:
-
Execute Duct Sizing: You must programmatically run the duct sizing tool to trigger the pressure calculations.
-
Access Analysis Results: The key is to access the MEPAnalyticalResults associated with the duct system. This object holds the analysis data, including pressure drop information.
-
Navigate the Results: The MEPAnalyticalResults provides access to pressure loss information. However, directly getting total and static pressure at a specific point requires some calculation. We typically get pressure drop across a segment.
Code Example (C#):
Key Improvements and Explanations:
- Duct Sizing Trigger: Explicitly calls
mepModel.CalculateDuctSystem(ductSystem) to ensure the calculations are performed. This is crucial.
- Analytical Segments: Uses
results.GetAnalyticalSegments() which provides a more granular view of the analysis.
- Pressure Drop: Extracts
segment.PressureDrop which is the directly available value.
- Calculating Total/Static: Explains the crucial point that total and static pressures at a point are not directly available. We must calculate them based on pressure drop and upstream conditions.
- Simplified Example: Provides a simplified illustration of the calculation. A real implementation requires traversing the duct system.
- Error Handling: Includes checks for null results and systems.
- Comments: Added comments for clarity.
Further Considerations:
- System Traversal: You'll need to implement a method to traverse the duct system to determine upstream pressures. This might involve getting connected elements, their flow directions, and accumulating pressure drops.
- Air Properties: Get air density from the project or system properties for accurate total pressure calculation.
- Velocity: You'll need to find a way to get velocity information from the analysis results. This might require further exploration of the
MEPAnalyticalResults or related objects.
- Units: Be mindful of units (Pascals, etc.) and conversions if needed.
This detailed approach should give you a solid foundation for retrieving and calculating duct pressure information in your Revit add-in. Remember, the key is to trigger the analysis and then work with the analytical results. Let me know if you have any other questions.
Here is a description by The Building Coder of a modeless pressure drop tool whipped up in 2009, 15 years ago, that might also be of interest: