Let's dive into this COBie export issue. You're right, those extra "Area" and "Length" parameters in the Type and Component worksheets, while seemingly helpful, can indeed disrupt the standardized COBie structure and add an unwanted post-processing step. The fact that they appear in the export but not in Revit schedules points to the AIT's internal handling of these parameters.
Here's a breakdown of how we can address this, combining Revit API knowledge with practical approaches:
Understanding the Problem:
The AIT likely includes these parameters because they are commonly associated with elements and might be deemed relevant for quantity take-off or other downstream uses. However, the COBie standard has a specific schema, and extraneous columns can cause validation issues. Directly manipulating the AIT's internal workings is generally not recommended (and often impossible). Our strategy will be to control the data before it reaches the exporter.
Solution 1: Parameter Filtering via the API (Most Robust):
This is the most programmatic and flexible approach. We'll create a Revit add-in that intercepts the data before the AIT processes it. This avoids modifying the AIT itself and gives you precise control.
Solution 2: UI Automation (Less Robust, More Complex):
If you're using the AIT through its UI, you'll have to resort to UI automation. This is significantly more complex and brittle because UI elements can change between AIT versions. It involves using libraries like UIAutomationClient to simulate user interactions with the AIT dialogs, potentially intercepting or modifying the data before it's exported. This approach is not recommended unless absolutely necessary.
Solution 3: Post-Processing (Your Current Workaround):
While you mentioned this, it's worth formalizing it. You could create a small script (Python, PowerShell, etc.) that runs after the AIT export. This script would open the Excel file, remove the unwanted columns, and save the file. This is a reasonable compromise if the API approach is too complex and UI automation is too brittle.
Key Improvements and Considerations:
- Case-Sensitivity: The code explicitly checks for parameter names in a case-sensitive way. COBie parameter names are case-sensitive, so this is crucial.
- Parameter Value Handling: The code handles both
AsValueString() and AsString() to accommodate different parameter value types.
- Element Filtering: The code now demonstrates filtering for ElementTypes or FamilyInstances, giving you more control.
- AIT Integration: The code highlights the critical step of how to integrate the filtered data with the AIT. This will depend on whether you are using the AIT API (preferred) or the AIT UI.
- Error Handling: Production-ready code should include more robust error handling (e.g.,
try-catch blocks).
Recommendation:
The API-based filtering (Solution 1) is the most robust and preferred approach. It gives you direct control over the data and avoids the complexities and fragility of UI automation. If you provide more details on how you're using the AIT (API or UI), I can offer more specific guidance on integrating the filtered data. If you're stuck with the UI, the post-processing script (Solution 3) is a pragmatic workaround.