Revit C# .NET add-in to import and store meta properties created in Forge
MIT License
Revit C# .NET add-in to import and store meta properties created in Philippe Leefsma's Forge Configurator – Meta Properties sample.
Handily enough, RvtMetaProp can also be used as a stand-alone utility to automatically create shared parameters and populate their values on BIM elements from a spreadsheet, completely independently of the Forge app.
It reads the properties associated with individual BIM elements from a CSV
or JSON
file.
If the property corresponds to an existing parameter on a BIM element, its value is updated accordingly.
For a new property, a shared parameter is created.
For a quick first impression, check out the four and a half minute recording of this add-in in action.
The CSV
and JSON
input files specify the following data, which correspond to the list Revit information:
externalId
– the Revit database element UniqueId
component
– element name and element id (ignored)displayCategory
– built-in parameter group name under which to display and store a shared parametercategoryId
– built-in parameter group enumeration value as stringdisplayName
– meta property namedisplayValue
– meta property valuemetaType
– meta property data type; for Revit, all but Double, Int and Text are ignoredfilelink
– meta property file URL (ignored)filename
– meta property file name (ignored)link
– meta property link URL (ignored)As you can see, some information defined in Forge and specified in the files may be ignored when importing into Revit.
The CSV
file format looks like this:
"externalId","component","displayCategory","categoryId","displayName","displayValue","metaType","filelink","filename","link"
"7df7740a-9736-4a3e-81ec-45e05b0d2ad2-0000c28d","Basic Wall [49805]","General","PG_GENERAL","test_text","this is a text added in forge","Text",,,
"7df7740a-9736-4a3e-81ec-45e05b0d2ad2-0000c28d","Basic Wall [49805]","General","PG_GENERAL","test_real","0.12","Double",,,
"7df7740a-9736-4a3e-81ec-45e05b0d2ad2-0000c28d","Basic Wall [49805]","General","PG_GENERAL","test_int","12","Int",,,
The fields are read in an order dependent manner.
The JSON
file contents are analoguous:
[
{
"displayCategory": "General",
"displayValue": "this is a text added in forge",
"displayName": "test_text",
"categoryId": "PG_GENERAL",
"externalId": "7df7740a-9736-4a3e-81ec-45e05b0d2ad2-0000c28d",
"component": "Basic Wall [49805]",
"metaType": "Text"
},
{
"displayCategory": "General",
"displayValue": "0.12",
"displayName": "test_real",
"categoryId": "PG_GENERAL",
"externalId": "7df7740a-9736-4a3e-81ec-45e05b0d2ad2-0000c28d",
"component": "Basic Wall [49805]",
"metaType": "Double"
},
{
"displayCategory": "General",
"displayValue": "12",
"displayName": "test_int",
"categoryId": "PG_GENERAL",
"externalId": "7df7740a-9736-4a3e-81ec-45e05b0d2ad2-0000c28d",
"component": "Basic Wall [49805]",
"metaType": "Int"
}
]
You can create a CSV
or JSON
input file matching this format to generate new shared parameters in your BIM, either using the Forge meta property editor, or in any other way you like.
A sample meta property editor is included in the online Forge configurator sample:
The office model is displayed, and its properties displayed in a panel on the right-hand side.
You can select any BIM element and see all its properties as well.
The buttons on the top right-hand side of the property panel enable search, export to CSV
and JSON
, and adding new properties.
Each property can also be deleted.
The models in this sample are hard-wired.
To demonstrate round-trip meta property editing on your own Revit BIM model in the Forge Viewer, Philippe implemented the Forge meta property editor.
It enables you to upload your own model, add properties to it in the Forge viewer, download the mesta property specifications, and intergrate them into the BIM see file using the RvtMetaProp add-in.
Again, the buttons on the top right-hand side of the property panel enable adding new properties (the plus sign icon) and export to CSV
and JSON
(the cloud icon).
RvtMetaProp reads modification into Revit and updates the BIM accordingly.
Retranslation of the updated BIM to Forge completes the round trip.
In order to enable the round trip intact, the meta property data types and group names are restricted to those supported by Revit shared parameters:
The list of Revit built-in parameter group enumeration values and display string labels was generated by the BipGroupList add-in and reformatted into a JavaScript dictionary mapping the enums to the labels using a regular expression.
Before implementing RvtMetaProp, I pondered the best way to add custom properties to a Revit BIM.
Basically, there are two fundamentally different approaches, as shown by the following Q & A:
[Q] How can I import updated and added properties into the Revit BIM?
[A] If all you need to do is attach additional information such as your database GUID to a Revit database element, the solution is easy.
You have two options to programmatically attach arbitrary data to building elements in the Revit BIM:
Category
, not on a per-Element
basis.Element
basis.Jeremy Tammik, The Building Coder, ADN Open, Autodesk Inc.
This sample is licensed under the terms of the MIT License. Please see the LICENSE file for full details.