You need the following items installed to successfully follow this guide:
0.9.11-alpha.0
or later
dotnet tool update --global Hypar.CLI --version 0.9.11-alpha.0
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.
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:
.vscode
contains pre-configured settings for debugging your converter.MyBestConverter.cs
is the converter class file — this is where we’ll do most of our editing.MyBestConverter.csproj
is the converter project file.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