Adding Custom Property Sets

Angel Velez

Note: This section is written based on IFC Exporter for Revit v2.5.0. Most of the information below will apply equally for previous and future versions, but some signatures and methods may change.

The Open Source Exporter allows programmatic addition of property set definitions for export. An example of this is ExporterInitializer.InitPropertySetBeamCommon.

Creating a PropertySetDescription

The class that contains the definition of the new property set is PropertySetDescription. Creating a new PropertySetDescription requires four steps, one optional:

  1. (Required) Set PropertySetDescription.Name as the name of the IFC property set (e.g., "PSet_BeamCommon").
  2. (Optional) Set PropertySetDescription.SubElementIndex as an integer between 0 and 65535 to create a consistent GUID for IfcPropertySet on export. If this is not supplied, a random GUID will be generated when the property set is created.
  3. (Required) Set PropertySetDescription.EntityTypes to contain a list of which IFC entities this property set is applicable for. Specifying a type will also make derived types also applicable. So, for example, PropertySetDescription.EntityTypes.Add(IfcWall) will add both IfcWall and IfcWallStandardCase.
  4. (Required) Call PropertySetDescription.AddEntry for each property in the property set.

Creating a PropertySetEntry

A property is defined by the class PropertySetEntry. A PropertySetEntry is created via the appropriate static function for type of the IFC property, and takes the property name as a parameter. For example, to define a property with the name "Reference" that is of type IfcLabel, call PropertySetEntry.CreateLabel("Reference").

If no other argument is set, the value of the property will be set by finding the Revit parameter of the same name (ignoring case, spacing, and underscores) in the same language (i.e., there is no internationalization). Optional arguments of PropertySetEntry can modify that behavior, if the matching parameter is not found:

  1. PropertySetEntry.RevitBuiltInParameter: This matches the IFC property with a Revit built-in parameter. The advantages here are that users are not required to add parameters to the file, and that these parameters are translated based on the local version of Revit.
  2. PropertySetEntry.PropertyCalculator: This allows a user to create a specialized function to determine the value of the IFC property for a given Revit element. Examples of these calculators are ReferenceCalculator and ExternalCalculator.

Adding the PropertySetDescription

Once the PropertySetDescription function has been created, it must be called at the beginning of export. This can occur in one of two functions, depending on the intent.

  1. When directly modifying the open source code, the routine ExporterInitializer.InitPropertySets should be modified to also add the new PropertySetDescription.
  2. When building an exporter on top of the open source exporter, the function Exporter.InitializePropertySets should be overriden, and the new property set description function called from the external initializer. Note that the programmer will probably want to call base.InitializePropertySets at the end of their function.

Related

Wiki: Home
Wiki: Supported property sets