Preflight

You need the following items installed to successfully follow this guide:

If you haven’t used the Hypar Revit plug-in before, it’s worth getting familiar with it before trying to write your own converter. See Hypar for Revit for details.

Overview

To create a converter, you’ll use the Hypar CLI to quickly get up and running. Run the following command, providing whatever converter name you like:

hypar converter new -n "MyConverterName"

This sets up a project for you with all the necessary references to build and debug a new converter. In VS Code, open the folder that was created. (The folder will be given the name you supplied in the previous step — MyBestConverter in this example).

Inside you’ll see these items:

Writing Converters

Each Converter is a class that implements the IRevitConverter interface. A converter is responsible for converting model elements between Hypar and Revit.

A converter can convert from Revit to Hypar, from Hypar to Revit or in both directions. It’s up to you to decide which direction(s) to implement for your converter.

Each direction has a set of associated properties and methods that you are responsible for writing. The Hypar Revit plug-in will take care of running your converter code on all the correct elements when a user imports or exports a model.

From Revit

bool CanConvertFromRevit This method determines whether or not your converter supports converting from Revit elements to Hypar elements.
DB.FilteredElementCollector AddElementFilters(DB.FilteredElementCollector collector) This method lets you pre-filter the elements in the Revit model, to limit them to only those your converter can handle.
Elements.Element[] FromRevit(ADSK.Element revitElement, ADSK.Document document) This method handles creating one or more new Hypar elements from a supplied Revit element.

To Revit