Skip to content

A cross-platform toolkit for reading metadata of .rfa, .rvt etc. Reading / writing hared sparameter and type catalog files WITHOUT Revit

License

Notifications You must be signed in to change notification settings

CodeCavePro/revitless-toolkit

Repository files navigation

RevitLESS Toolkit

A cross-platform Revit-less toolkit for processing .rfa, .rvt and other files without Revit

Revit API NuGet version Revit API Revit API

License NuGet downloads GitHub downloads

AppVeyor build status AppVeyor tests Coverage Status Read the Docs (version)

Installation

RevitLESS Toolkit can be installed via NuGet by using Package Manager in your IDE, dotnet binary or Package Console

# Add the CodeCave.Revit.Toolkit package to a project named [<PROJECT>]
dotnet add [<PROJECT>] package CodeCave.Revit.Toolkit

or Visual Studio's Package Console

# Add the CodeCave.Revit.Toolkit package to the default project
Install-Package CodeCave.Revit.Toolkit

# Add the CodeCave.Revit.Toolkit package to a project named [<PROJECT>]
Install-Package CodeCave.Revit.Toolkit -ProjectName [<PROJECT>]

Usage

RevitLESS Toolkit provides various tools, you can easily find the full list by browsing the documentation.

Shared parameter file

One of the most interesting tools is Revit shared parameter file reading and manipulation.

var sharedParamFile = new SharedParameterFile(@"path/to/shared/parameter/file.txt");

// alternatively you can supply the content of the file
var sharedParamFile = new SharedParameterFile(File.ReadAllText(@"path/to/file.txt"));

// .. or you can create a completely new (empty) shared file
var sharedParamFile = new SharedParameterFile();

// .. or with some empty (with no parameters assigned yet) groups
var sharedParamFile = new SharedParameterFile(new Dictionary<string,int> { { "Identity Data", 100 } } );

sharedParamFile.Parameters.Add(
    new Guid("61ff3d56-09d7-4049-8c78-4abe745e4e5a"),"EquipmentName",
    "Identity Data", // Referencing group by name
    ParameterType.Text
);

sharedParamFile.Parameters.Add(
    new Guid("b5a53ea4-55d9-497c-8488-6607faa11e5f"), "EquipmentServed",
    new SharedParameterFile.Group("Identity Data", 100), // Creating group as object
    ParameterType.Text
);

sharedParamFile.Parameters.Add(
    new Guid("758c97dc-6b88-4fbd-9570-4affdc32f08d"), "EquipmentNumber",
    sharedParamFile.Groups.FirstOrDefault(g => "Identity Data".Equals(g.Name)), // Finding group dynamically
    ParameterType.Text
);


// Create a group object
var electricalGroup = new SharedParameterFile.Group("Electrical", 999);

// Add some parameters assigned to this group
sharedParamFile.Parameters.Add(
    new Guid("5031db93-bb19-454e-bea4-0f77d60f15e6"), "ApparentPower",
    electricalGroup, ParameterType.ElectricalApparentPower
);
sharedParamFile.Parameters.Add(
    new Guid("963abdb6-372f-496c-b99e-f11d8e0e5d20"), "Current",
    electricalGroup, ParameterType.ElectricalCurrent
);
sharedParamFile.Parameters.Add(
    new Guid("c006d4d6-0b12-42ad-8078-fe38ab8b1eff"), "Phases",
    "Electrical", // Using group's name, because it's just added parameters with a group object having the same name
    ParameterType.NumberOfPoles
);

// Write out shared parameters file to disk
sharedParamFile.Save("path/a/new/shared/file.txt");

Catalog type file

This is a pretty useful tool for easily creating and then writing out Revit type catalog files.

var catalogTypeFile = new TypeCatalogFile();
var iPhoneCommonParameters = new List<IParameterWithValue>
{
    new TypeCatalogFile.Parameter<string>("Manufacturer", ParameterType.Text, "Apple"),
    new TypeCatalogFile.Parameter<string>("Model", ParameterType.Text, "A1549"),
    new TypeCatalogFile.Parameter<double>("Width", ParameterType.Length, 77.8, DisplayUnitType.DUT_MILLIMETERS),
    new TypeCatalogFile.Parameter<double>("Depth", ParameterType.Length, 6.9, DisplayUnitType.DUT_MILLIMETERS),
    new TypeCatalogFile.Parameter<double>("Height", ParameterType.Length, 158.1, DisplayUnitType.DUT_MILLIMETERS),
};

catalogTypeFile.Add("MG562LL/A", iPhoneCommonParameters.Concat(new List<IParameterWithValue>
{
    new TypeCatalogFile.Parameter<string>("AssemblyCode", ParameterType.Text, "MG562LL/A"),
    new TypeCatalogFile.Parameter<string>("Description", ParameterType.Text, "iPhone 6 16GB Gold (GSM) T-Mobile"),
    new TypeCatalogFile.Parameter<double>("Price", ParameterType.Currency, 299.90),
    new TypeCatalogFile.Parameter<string>("Currency", ParameterType.Text, "$"),
    new TypeCatalogFile.Parameter<int>("Storage GB", 16),
    new TypeCatalogFile.Parameter<bool>("Unlocked", ParameterType.YesNo, false),
}).ToArray());
catalogTypeFile.Add("MG5D2LL/A", iPhoneCommonParameters.Concat(new List<IParameterWithValue>
{
    new TypeCatalogFile.Parameter<string>("AssemblyCode", ParameterType.Text, "MG5D2LL/A"),
    new TypeCatalogFile.Parameter<string>("Description", ParameterType.Text, "iPhone 6 64GB Gold (GSM) T-Mobile"),
    new TypeCatalogFile.Parameter<double>("Price", ParameterType.Currency, 380.0),
    new TypeCatalogFile.Parameter<string>("Currency", ParameterType.Text, "$"),
    new TypeCatalogFile.Parameter<int>("Storage GB", 32),
    new TypeCatalogFile.Parameter<bool>("Unlocked", ParameterType.YesNo, false),
}).ToArray());
catalogTypeFile.Add("MG3A2CL/A", iPhoneCommonParameters.Concat(new List<IParameterWithValue>
{
    new TypeCatalogFile.Parameter<string>("AssemblyCode", ParameterType.Text, "MG3A2CL/A"),
    new TypeCatalogFile.Parameter<string>("Description", ParameterType.Text, "iPhone 6 16GB Space Grey Unlocked"),
    new TypeCatalogFile.Parameter<double>("Price", ParameterType.Currency, 600.0),
    new TypeCatalogFile.Parameter<string>("Currency", ParameterType.Text, "CAD"),
    new TypeCatalogFile.Parameter<int>("Storage GB", 16),
    new TypeCatalogFile.Parameter<bool>("Unlocked", ParameterType.YesNo, true),
}).ToArray());

// Write out type catalog file to disk
catalogTypeFile.Save("path/a/new/shared/file.txt");