Nice3point.Revit.Extensions 2022.3.1-preview.2.1

Prefix Reserved
This is a prerelease version of Nice3point.Revit.Extensions.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Nice3point.Revit.Extensions --version 2022.3.1-preview.2.1                
NuGet\Install-Package Nice3point.Revit.Extensions -Version 2022.3.1-preview.2.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Nice3point.Revit.Extensions" Version="2022.3.1-preview.2.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Nice3point.Revit.Extensions --version 2022.3.1-preview.2.1                
#r "nuget: Nice3point.Revit.Extensions, 2022.3.1-preview.2.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Nice3point.Revit.Extensions as a Cake Addin
#addin nuget:?package=Nice3point.Revit.Extensions&version=2022.3.1-preview.2.1&prerelease

// Install Nice3point.Revit.Extensions as a Cake Tool
#tool nuget:?package=Nice3point.Revit.Extensions&version=2022.3.1-preview.2.1&prerelease                

Improve your experience with Revit API

Nuget Downloads Last Commit

Extensions bring a fresh, intuitive way to interact with the Revit API. By adding extension methods, they make your code more readable, maintainable, and concise.

Forget about complex utility methods — extensions provide a fluent syntax that lets you focus on what matters:

new ElementId(123469)
    .ToElement<Door>()
    .Mirror()
    .FindParameter("Height")
    .AsDouble()
    .ToMillimeters()
    .Round()

Seamless integration with modern .NET features like Nullable and Generics gives you greater flexibility and control over your code.

Installation

You can install Extensions as a nuget package.

Packages are compiled for a specific version of Revit, to support different versions of libraries in one project, use RevitVersion property.

<PackageReference Include="Nice3point.Revit.Extensions" Version="$(RevitVersion).*"/>

Package included by default in Revit Templates.

Table of contents

Element extensions

FindParameter extension finds a parameter in the instance or symbol by identifier. For instances that do not have such a parameter, this method will find and return it at the element type. This method combines all API methods for getting a parameter into one, such as get_Parameter, LookupParameter, GetParameter.

var parameter = element.FindParameter(ParameterTypeId.AllModelUrl);
var parameter = element.FindParameter(BuiltInParameter.ALL_MODEL_URL);
var parameter = element.FindParameter("URL");

Element transform extensions

Copy extension copies an element and places the copy at a location indicated by a given transformation.

element.Copy(1, 1, 0);
element.Copy(new XYZ(1, 1, 0));

Mirror extension creates a mirrored copy of an element about a given plane.

element.Mirror(plane);

Move extension moves the element by the specified vector.

element.Move(1, 1, 0);
element.Move(new XYZ(1, 1, 0));

Rotate extension rotates an element about the given axis and angle.

element.Rotate(axis, angle);

CanBeMirrored extension determines whether element can be mirrored.

var canRotate = element.CanBeMirrored();

CanBeMirrored extension determines whether element can be mirrored.

var canRotate = element.CanBeMirrored();

Element association extensions

IsAnalyticalElement extension returns true if the element is an analytical element.

var isAnalytical = element.IsAnalyticalElement();

IsPhysicalElement extension returns true if the element is a physical element.

var isPhysical = element.IsPhysicalElement();

Element worksharing extensions

GetCheckoutStatus extension gets the ownership status of an element.

var status = element.GetCheckoutStatus();

GetCheckoutStatus extension gets the ownership status and outputs the owner of an element.

var status = element.GetCheckoutStatus(out var owner);

GetCheckoutStatus extension gets worksharing information about an element to display in an in-canvas tooltip.

var info = element.GetWorksharingTooltipInfo();

GetModelUpdatesStatus extension gets the status of a single element in the central model.

var status = element.GetModelUpdatesStatus();

Element schema extensions

SaveEntity extension stores data in the element. Existing data is overwritten.

document.ProjectInformation.SaveEntity(schema, "data", "schemaField");
door.SaveEntity(schema, "white", "doorColorField");

LoadEntity extension retrieves the value stored in the schema from the element.

var data = document.ProjectInformation.LoadEntity<string>(schema, "schemaField");
var color = door.LoadEntity<string>(schema, "doorColorField");

ElementId extensions

ToElement extension retrieves the element associated with the specified ElementId.

Element element = wallId.ToElement(document);
Wall wall = wallId.ToElement<Wall>(document);

ToElements extension retrieves a collection of elements associated with the specified ElementIds.

IList<Element> element = wallIds.ToElements(document);
IList<Wall> element = wallIds.ToElements<Wall>(document);

To improve the database access performance, it is not guaranteed that the elements will be retrieved in the original order, if you need the same order, use the ToOrderedElements extension.

ToOrderedElements extension retrieves the elements associated with the specified ElementIds in their original order.

IList<Element> element = wallIds.ToOrderedElements(document);
IList<Wall> element = wallIds.ToOrderedElements<Wall>(document);

The elements will be retrieved in the same order as the original ElementIds collection.

AreEquals extension checks if an ID matches BuiltInСategory or BuiltInParameter.

categoryId.AreEquals(BuiltInCategory.OST_Walls);
parameterId.AreEquals(BuiltInParameter.WALL_BOTTOM_IS_ATTACHED);

ElementId transform extensions

CanMirrorElements extension determines whether elements can be mirrored.

var canMirror = elementIds.CanMirrorElements(document);

MirrorElements extension mirrors a set of elements about a given plane.

var elements = elementIds.MirrorElements(document, plane, mirrorCopies: true);

MoveElements extension moves a set of elements by a given transformation.

elementIds.MoveElements(document, new XYZ(1, 1, 1));

RotateElements extension rotates a set of elements about the given axis and angle.

elementIds.RotateElements(document, axis, angle: 3.14);

CopyElements extension copies a set of elements from source view to destination view.

var copy = elementIds.CopyElements(source, destination);
var copy = elementIds.CopyElements(source, destination, transform, options);

CopyElements extension copies a set of elements and places the copies at a location indicated by a given translation.

var copy = elementIds.CopyElements(document, new XYZ(1, 1, 1));

Application extensions

Ribbon Extensions

Revit API Ribbon controls Guidelines

CreatePanel extension creates or retrieves an existing panel in the "Add-ins" tab of the Revit ribbon.

If a panel with the specified name already exists within the tab, it will return that panel; otherwise, a new one will be created.

var panel = application.CreatePanel("Panel name");
var panel = application.CreatePanel("Panel name", "Tab name");

AddPushButton extension adds a PushButton to the ribbon.

var button = panel.AddPushButton<Command>("Button text");
var button = pullDownButton.AddPushButton<Command>("Button text");

AddPullDownButton extension adds a PullDownButton to the ribbon.

var button = panel.AddPullDownButton("Button text");

AddSplitButton extension adds a SplitButton to the ribbon.

var button = panel.AddSplitButton("Button text");

AddRadioButtonGroup extension adds a RadioButtonGroup to the ribbon.

var radioGroup = panel.AddRadioButtonGroup();

AddComboBox extension adds a ComboBox to the ribbon.

var comboBox = panel.AddComboBox();

AddTextBox extension adds a TextBox to the ribbon.

var textBox = panel.AddTextBox();

regularControls

AddStackPanel extension adds a vertical stack panel to the Ribbon panel.

var stackPanel = panel.AddStackPanel();

By default, the StackPanel accommodates one to three elements vertically. If the added items exceed the maximum threshold, they will be automatically added to a new column.

These 5 items will create 2 vertical panels, one will contain 3 items and the other 2 items:

var stackPanel = panel.AddStackPanel();
stackPanel.AddPushButton<StartupCommand>("Execute");
stackPanel.AddPullDownButton("Execute");
stackPanel.AddSplitButton("Execute");
stackPanel.AddComboBox();
stackPanel.AddTextBox();

verticalStack

SetImage extension adds an image to the RibbonButton.

button.SetImage("/RevitAddIn;component/Resources/Icons/RibbonIcon16.png");
button.SetImage("https://example.com/RibbonIcon16.png");
button.SetImage("C:/Pictures/RibbonIcon16.png");

SetLargeImage extension adds a large image to the RibbonButton.

button.SetLargeImage("/RevitAddIn;component/Resources/Icons/RibbonIcon32.png");
button.SetLargeImage("https://example.com/RibbonIcon32.png");
button.SetLargeImage("C:/Pictures/RibbonIcon32.png");

SetAvailabilityController extension specifies the class that decides the availability of PushButton.

pushButton.SetAvailabilityController<CommandController>();

ContextMenu Extensions

ConfigureContextMenu extension registers an action used to configure a Context menu.

application.ConfigureContextMenu(menu =>
{
    menu.AddMenuItem<Command>("Menu title");
    menu.AddMenuItem<Command>("Menu title")
        .SetAvailabilityController<Controller>()
        .SetToolTip("Description");
});

You can also specify your own context menu title. By default, Revit uses the Application name

application.ConfigureContextMenu("Title", menu =>
{
    menu.AddMenuItem<Command>("Menu title");
});

AddMenuItem extension adds a menu item to the Context Menu.

menu.AddMenuItem<Command>("Menu title");

AddSeparator extension adds a separator to the Context Menu.

menu.AddSeparator();

AddSubMenu extension adds a sub menu to the Context Menu.

var subMenu = new ContextMenu();
subMenu.AddMenuItem<Command>("Menu title");
subMenu.AddMenuItem<Command>("Menu title");

menu.AddSubMenu("Sub menu title", subMenu);

SetAvailabilityController extension specifies the class type that decides the availability of menu item.

menuItem.SetAvailabilityController<Controller>()

Document extensions

GetProfileSymbols extension gets the profile Family Symbols of the document.

var symbols = document.GetProfileSymbols(ProfileFamilyUsage.Any, oneCurveLoopOnly: true);

RelinquishOwnership extension gets the profile Family Symbols of the document.

var items = document.RelinquishOwnership(relinquishOptions, transactOptions);

Document managers extensions

GetTemporaryGraphicsManager extension gets a TemporaryGraphicsManager reference of the document.

var manager = document.GetTemporaryGraphicsManager();

GetAnalyticalToPhysicalAssociationManager extension gets a AnalyticalToPhysicalAssociationManager reference of the document.

var manager = document.GetAnalyticalToPhysicalAssociationManager();

GetLightGroupManager extension creates a light group manager object from the given document.

var manager = document.GetLightGroupManager();

Geometry extensions

Distance extension returns distance between two lines. The lines are considered endless.

var line1 = Line.CreateBound(new XYZ(0,0,1), new XYZ(1,1,1));
var line2 = Line.CreateBound(new XYZ(1,2,2), new XYZ(1,2,2));
var distance = line1.Distance(line2);

Contains extension determines whether the specified point is contained within this BoundingBox.

var point = new XYZ(1,1,1);
var isContains = boundingBox.Contains(point);

Contains extension determines whether the specified point is contained within this BoundingBox. Set strict mode if the point needs to be fully on the inside of the source. A point coinciding with the box border will be considered outside.

var point = new XYZ(1,1,1);
var isContains = boundingBox.Contains(point, strict:true);

Contains extension determines whether one BoundingBoxXYZ contains another BoundingBoxXYZ.

var boundingBox2 = new BoundingBoxXYZ();
var isContains = boundingBox1.Contains(boundingBox2);

Contains extension determines whether one BoundingBoxXYZ contains another BoundingBoxXYZ. Set strict mode if the box needs to be fully on the inside of the source. Coincident boxes will be considered outside.

var boundingBox2 = new BoundingBoxXYZ();
var isContains = boundingBox1.Contains(boundingBox2, strict:true);

Overlaps extension determines whether this BoundingBox overlaps with another BoundingBox.

var boundingBox2 = new BoundingBoxXYZ();
var isContains = boundingBox1.Overlaps(boundingBox2);

ComputeCentroid extension computes the geometric center point of the bounding box.

var center = boundingBox.ComputeCentroid();

ComputeVertices extension retrieves the coordinates of the eight vertices that define the bounding box.

var vertices = boundingBox.ComputeVertices();

ComputeVolume extension calculates the volume enclosed by the bounding box.

var volume = boundingBox.ComputeVolume();

ComputeSurfaceArea extension calculates the total surface area of the bounding box.

var area = boundingBox.ComputeSurfaceArea();

SetCoordinateX extension creates an instance of a curve with a new X coordinate.

var newLine = line.SetCoordinateX(1);
var newArc = arc.SetCoordinateX(1);

SetCoordinateY extension creates an instance of a curve with a new Y coordinate.

var newLine = line.SetCoordinateY(1);
var newArc = arc.SetCoordinateY(1);

SetCoordinateZ extension creates an instance of a curve with a new coordinate.

var newLine = line.SetCoordinateZ(1);
var newArc = arc.SetCoordinateZ(1);

Element geometry extensions

JoinGeometry extension creates clean joins between two elements that share a common face.

element1.JoinGeometry(element2);

UnjoinGeometry extension removes a join between two elements.

element1.UnjoinGeometry(element2);

AreElementsJoined extension determines whether two elements are joined.

var areJoined = element1.AreElementsJoined(element2);

GetJoinedElements extension returns all elements joined to given element.

var elements = element1.GetJoinedElements();

SwitchJoinOrder extension reverses the order in which two elements are joined.

element1.SwitchJoinOrder();

IsCuttingElementInJoin extension determines whether the first of two joined elements is cutting the second element.

var isCutting = element1.IsCuttingElementInJoin(element2);

Parameters extensions

AsBool extension provides access to the boolean value within the parameter.

bool value = element.FindParameter("IsClosed").AsBool();

AsColor extension provides access to the Color within the parameter.

Color value = element.FindParameter("Door color").AsColor();

AsElement extension provides access to the Element within the parameter.

Element value = element.FindParameter("Door material").AsElement();
Material value = element.FindParameter("Door material").AsElement<Material>();

Set extension sets the parameter to a new value.

parameter.Set(true);
parameter.Set(new Color(66, 69, 96);

IsBuiltInParameter extension checks whether a Parameter identifies a built-in parameter.

var isBuiltIn = parameter.IsBuiltInParameter();

Document global parameters extensions

FindGlobalParameter extension finds whether a global parameter with the given name exists in the input document.

var parameter = document.FindGlobalParameter(name);

GetAllGlobalParameters extension returns all global parameters available in the given document.

var parameters = document.GetAllGlobalParameters();

GetGlobalParametersOrdered extension returns all global parameters in an ordered array.

var parameters = document.GetGlobalParametersOrdered();

SortGlobalParameters extension sorts global parameters in the desired order.

document.SortGlobalParameters(ParametersOrder.Ascending);

MoveGlobalParameterUpOrder extension moves given global parameter Up in the current order.

var isMoved = globalParameter.MoveUpOrder();

MoveGlobalParameterDownOrder extension moves given global parameter Down in the current order.

var isMoved = globalParameter.MoveDownOrder();

IsUniqueGlobalParameterName extension tests whether a name is unique among existing global parameters of a given document.

var isUnique = document.IsUniqueGlobalParameterName(name);

IsValidGlobalParameter extension tests whether an ElementId is of a global parameter in the given document.

var isValid = document.IsValidGlobalParameter(parameterId);

AreGlobalParametersAllowed extension tests whether global parameters are allowed in the given document.

var isAllowed = document.AreGlobalParametersAllowed();

FilteredElementCollector extensions

This set of extensions encapsulates all the work of searching for elements in the Revit database.

GetElements a generic method which constructs a new FilteredElementCollector that will search and filter the set of elements in a document. Filter criteria are not applied to the method.

var elements = document.GetElements().WhereElementIsViewIndependent().ToElements();
var elements = document.GetElements(elementIds).WhereElementIsViewIndependent.ToElements();
var elements = document.GetElements(viewId).ToElements();

The remaining methods contain a ready implementation of the collector, with filters applied:

var elements = document.GetInstances();
var elements = document.GetInstances(new ElementParameterFilter());
var elements = document.GetInstances([elementParameterFilter, logicalFilter]);

var elements = document.GetInstances(BuiltInCategory.OST_Walls);
var elements = document.GetInstances(BuiltInCategory.OST_Walls, new ElementParameterFilter());
var elements = document.GetInstances(BuiltInCategory.OST_Walls, [elementParameterFilter, logicalFilter]);    

var elements = document.EnumerateInstances();
var elements = document.EnumerateInstances(new ElementParameterFilter());
var elements = document.EnumerateInstances([elementParameterFilter, logicalFilter]);

var elements = document.EnumerateInstances(BuiltInCategory.OST_Walls);
var elements = document.EnumerateInstances(BuiltInCategory.OST_Walls, new ElementParameterFilter());
var elements = document.EnumerateInstances(BuiltInCategory.OST_Walls, [elementParameterFilter, logicalFilter]);   

var elements = document.EnumerateInstances<Wall>();
var elements = document.EnumerateInstances<Wall>(new ElementParameterFilter());
var elements = document.EnumerateInstances<Wall>(new [elementParameterFilter, logicalFilter]);

var elements = document.EnumerateInstances<Wall>(BuiltInCategory.OST_Walls);
var elements = document.EnumerateInstances<Wall>(BuiltInCategory.OST_Walls, new ElementParameterFilter());
var elements = document.EnumerateInstances<Wall>(BuiltInCategory.OST_Walls, [elementParameterFilter, logicalFilter]);   

The same overloads exist for InstanceIds, Type, TypeIds:

var types = document.GetTypes();
var types = document.GetTypeIds();
var types = document.GetInstanceIds();
var types = document.EnumerateTypes();
var types = document.EnumerateTypeIds();
var types = document.EnumerateInstanceIds();

Remarks: Get methods are faster than Enumerate due to RevitApi internal optimizations. However, enumeration allows for more flexibility in finding elements.

Don't try to call GetInstances().Select().Tolist() instead of EnumerateInstances().Select().Tolist(), you will degrade performance.

ForgeTypeId extensions

IsSpec extension Checks whether a ForgeTypeId identifies a spec.

var isSpec = forgeId.IsSpec();

IsBuiltInGroup extension checks whether a ForgeTypeId identifies a built-in parameter group.

var isGroup = forgeId.IsBuiltInGroup();

IsBuiltInParameter extension checks whether a ForgeTypeId identifies a built-in parameter.

var isBuiltInParameter = forgeId.IsBuiltInParameter();

IsSymbol extension checks whether a ForgeTypeId identifies a symbol.

var isSymbol = symbolTypeId.IsSymbol();

IsUnit extension checks whether a ForgeTypeId identifies a unit.

var isUnit = unitTypeId.IsUnit();

IsValidDataType extension returns true if the given ForgeTypeId identifies a valid parameter data type.

var isValid = forgeId.IsValidDataType();

IsValidUnit extension checks whether a unit is valid for a given measurable spec.

var isValid = specTypeId.IsValidUnit(unitTypeId);

IsMeasurableSpec extension checks whether a ForgeTypeId identifies a spec associated with units of measurement.

var isMeasurable = specTypeId.IsMeasurableSpec(unitTypeId);

GetBuiltInParameter extension gets the BuiltInParameter value corresponding to built-in parameter identified by the given ForgeTypeId.

var builtInParameter = forgeId.GetBuiltInParameter();

GetParameterTypeId extension gets the ForgeTypeId identifying the built-in parameter corresponding to the given BuiltInParameter value.

var forgeId = builtInParameter.GetParameterTypeId();

GetDiscipline extension gets the discipline for a given measurable spec.

var disciplineId = specTypeId.GetDiscipline();

GetValidUnits extension gets the identifiers of all valid units for a given measurable spec.

var unitIds = specTypeId.GetValidUnits();

GetTypeCatalogStringForSpec extension gets the string used in type catalogs to identify a given measurable spec.

var catalog = specTypeId.GetTypeCatalogStringForSpec();

GetTypeCatalogStringForUnit extension gets the string used in type catalogs to identify a given unit.

var catalog = unitTypeId.GetTypeCatalogStringForUnit();

DownloadCompanyName extension downloads the name of the given parameter's owning account and records it in the given document. If the owning account's name is already recorded in the given document, this method returns the name without downloading it again.

var name = forgeId.DownloadCompanyName(document);

DownloadParameterOptions extension retrieves settings associated with the given parameter from the Parameters Service.

var options = forgeId.DownloadParameterOptions(document);

DownloadParameter extension creates a shared parameter element in the given document according to a parameter definition downloaded from the Parameters Service.

var sharedParameter = forgeId.DownloadParameter(document, options);

Unit Extensions

FromMillimeters extension converts millimeters to internal Revit number format (feet).

var value = 69d.FromMillimeters(); // 0.226

ToMillimeters extension converts a Revit internal format value (feet) to millimeters.

var value = 69d.ToMillimeters(); // 21031

FromMeters extension converts meters to internal Revit number format (feet).

var value = 69d.FromMeters(); // 226.377

ToMeters extension converts a Revit internal format value (feet) to meters.

var value = 69d.ToMeters(); // 21.031

FromInches extension converts inches to internal Revit number format (feet).

var value = 69d.FromInches(); // 5.750

ToInches extension converts a Revit internal format value (feet) to inches.

var value = 69d.ToInches(); // 827.999

FromDegrees extension converts degrees to internal Revit number format (radians).

var value = 69d.FromDegrees(); // 1.204

ToDegrees extension converts a Revit internal format value (radians) to degrees.

var value = 69d.ToDegrees(); // 3953

FromUnit(UnitTypeId) extension converts the specified unit type to internal Revit number format.

var value = 69d.FromUnit(UnitTypeId.Celsius); // 342.15

ToUnit(UnitTypeId) extension converts a Revit internal format value to the specified unit type.

var value = 69d.ToUnit(UnitTypeId.Celsius); // -204.15

FormatUnit extension formats a number with units into a string.

var value = document.GetUnits().FormatUnit(SpecTypeId.Length, 69, false); // 21031
var value = document.GetUnits().FormatUnit(SpecTypeId.Length, 69, false, new FormatValueOptions {AppendUnitSymbol = true}); // 21031 mm

TryParse extension parses a formatted string into a number with units if possible.

var isParsec = document.GetUnits().TryParse(SpecTypeId.Length, "21031 mm", out var value); // 69

Label Extensions

ToLabel extension convert Enum to user-visible name.

var label = BuiltInCategory.OST_Walls.ToLabel(); // "Walls"
var label = BuiltInParameter.WALL_TOP_OFFSET.ToLabel(); // "Top Offset"
var label = BuiltInParameter.WALL_TOP_OFFSET.ToLabel(LanguageType.Russian); // "Смещение сверху"
var label = BuiltInParameterGroup.PG_LENGTH.ToLabel(); // "Length"
var label = DisplayUnitType.DUT_KILOWATTS.ToLabel(); // "Kilowatts"

ToLabel extension convert ForgeTypeId to user-visible name.

var label = ParameterType.Length.ToLabel(); // "Length"
var label = DisciplineTypeId.Hvac.ToLabel(); // "HVAC"
var label = GroupTypeId.Geometry.ToLabel(); // "Dimensions"
var label = ParameterTypeId.DoorCost.ToLabel(); // "Cost"
var label = SpecTypeId.SheetLength.ToLabel(); // "Sheet Length"
var label = SymbolTypeId.Hour.ToLabel(); // "h"
var label = UnitTypeId.Hertz.ToLabel(); // "Hertz"

ToDisciplineLabel extension convert ForgeTypeId to user-visible name a discipline.

var label = DisciplineTypeId.Hvac.ToDisciplineLabel(); // "HVAC"

ToGroupLabel extension converts ForgeTypeId to user-visible name for a built-in parameter group.

var label = GroupTypeId.Geometry.ToGroupLabel(); // "Dimensions"

ToParameterLabel extension converts ForgeTypeId to user-visible name for a built-in parameter.

var label = ParameterTypeId.DoorCost.ToParameterLabel(); // "Cost"

ToSpecLabel extension converts ForgeTypeId to user-visible name for a spec.

var label = SpecTypeId.SheetLength.ToSpecLabel(); // "Sheet Length"

ToSymbolLabel extension convert ForgeTypeId to user-visible name for a symbol.

var label = SymbolTypeId.Hour.ToSymbolLabel(); // "h"

ToUnitLabel extension converts ForgeTypeId to user-visible name for a unit.

var label = UnitTypeId.Hertz.ToUnitLabel(); // "Hertz"

Color extensions

ToHex extension returns a hexadecimal representation of a color.

var hex = color.ToHex();

ToHexInteger extension returns a hexadecimal integer representation of a color.

var hexInteger = color.ToHexInteger();

ToRgb extension returns an RGB representation of a color.

var rgb = color.ToRgb();

ToHsl extension returns a HSL representation of a color.

var hsl = color.ToHsl();

ToHsv extension returns a HSV representation of a color.

var hsv = color.ToHsv();

ToCmyk extension returns a CMYK representation of a color.

var cmyk = color.ToCmyk();

ToHsb extension returns a HSB representation of a color.

var hsb = color.ToHsb();

ToHsi extension returns a HSI representation of a color.

var hsi = color.ToHsi();

ToHwb extension returns a HWB representation of a color.

var hwb = color.ToHwb();

ToNCol extension returns a NCol representation of a color.

var ncol = color.ToNCol();

ToCielab extension returns a Cielab representation of a color.

var cielab = color.ToCielab();

ToCieXyz extension returns a CieXyz representation of a color.

var xyz = color.ToCieXyz();

ToFloat extension returns a Float representation of a color.

var float = color.ToFloat();

ToDecimal extension returns a Decimal representation of a color.

var decimal = color.ToDecimal();

Family extensions

CanConvertToFaceHostBased extension indicates whether the family can be converted to face host based.

var canConvert = family.CanConvertToFaceHostBased();

ConvertToFaceHostBased extension converts a family to be face host based.

family.ConvertToFaceHostBased();

HostObject extensions

GetBottomFaces extension returns the bottom faces for the host object.

floor.Cast<HostObject>().GetBottomFaces();

GetTopFaces extension returns the top faces for the host object.

floor.Cast<HostObject>().GetTopFaces();

GetSideFaces extension returns the major side faces for the host object.

wall.Cast<HostObject>().GetSideFaces(ShellLayerType.Interior);

Plumbing extensions

ConnectPipePlaceholdersAtElbow extension connects placeholders that looks like elbow connection.

var isConnected = connector1.ConnectPipePlaceholdersAtElbow(connector2);

ConnectPipePlaceholdersAtTee extension connects three placeholders that looks like Tee connection.

var isConnected = connector1.ConnectPipePlaceholdersAtTee(connector2, connector3);

ConnectPipePlaceholdersAtCross extension connects placeholders that looks like Cross connection.

var isConnected = connector1.ConnectPipePlaceholdersAtCross(connector2, connector3, connector4);

PlaceCapOnOpenEnds extension places caps on the open connectors of the pipe curve.

pipe.PlaceCapOnOpenEnds();
pipe.PlaceCapOnOpenEnds(typeId);

HasOpenConnector extension checks if there is open piping connector for the given pipe curve.

var hasOpenConnector = pipe.HasOpenConnector();

BreakCurve extension breaks the pipe curve into two parts at the given position.

var pipeCurve = pipe.BreakCurve(new XYZ(1, 1, 1));

Solid extensions

Clone extension creates a new Solid, which is a copy of the input Solid.

var clone = solid.Clone();

CreateTransformed extension creates a new Solid which is the transformation of the input Solid.

var transformed = solid.CreateTransformed(Transform.CreateRotationAtPoint());
var transformed = solid.CreateTransformed(Transform.CreateReflection());

SplitVolumes extension splits a solid geometry into several solids.

var solids = solid.SplitVolumes();

IsValidForTessellation extension tests if the input solid or shell is valid for tessellation.

var isValid = solid.IsValidForTessellation();

TessellateSolidOrShell extension facets (i.e., triangulates) a solid or an open shell.

var tesselation = solid.TessellateSolidOrShell();

FindAllEdgeEndPointsAtVertex extension finds all EdgeEndPoints at a vertex identified by the input EdgeEndPoint.

var point = edgeEndPoint.FindAllEdgeEndPointsAtVertex();

Element solid cut extensions

GetCuttingSolids extension gets all the solids which cut the input element.

var solids = element.GetCuttingSolids();

GetSolidsBeingCut extension gets all the solids which are cut by the input element.

var solids = element.GetSolidsBeingCut();

IsAllowedForSolidCut extension validates that the element is eligible for a solid-solid cut.

var isAllowed = element.IsAllowedForSolidCut();

IsElementFromAppropriateContext extension validates that the element is from an appropriate document.

var fromContext = element.IsElementFromAppropriateContext();

CanElementCutElement extension verifies if the cutting element can add a solid cut to the target element.

var canCut = element1.CanElementCutElement(element2, out var reason);

CutExistsBetweenElements extension checks that if there is a solid-solid cut between two elements.

var isCutExists = element1.CutExistsBetweenElements(element2, out var isFirstCuts);

AddCutBetweenSolids extension adds a solid-solid cut for the two elements.

element1.AddCutBetweenSolids(element2);

RemoveCutBetweenSolids extension removes the solid-solid cut between the two elements if it exists.

element1.RemoveCutBetweenSolids(element2);

SplitFacesOfCuttingSolid extension removes the solid-solid cut between the two elements if it exists.

element1.SplitFacesOfCuttingSolid(element2);

View extensions

GetTransformFromViewToView extension returns a transformation that is applied to elements when copying from one view to another view.

var transform = view1.GetTransformFromViewToView(view2);

View managers extensions

CreateSpatialFieldManager extension creates SpatialField for the given view.

var manager = view.CreateSpatialFieldManager(numberOfMeasurements: 69);

GetSpatialFieldManager extension retrieves SpatialField manager for the given view.

var manager = view.GetSpatialFieldManager();

Imperial Extensions

ToFraction extension converts a double value representing a measurement in feet to its string representation in the Imperial system, expressed as feet, inches, and fractional inches.

var imperial = 0.0123.ToFraction(); // 1/8"
var imperial = 12.011.ToFraction(); // 12'-1/8"
var imperial = 25.222.ToFraction(); // 25'-2 1/8"
var imperial = 0.0123.ToFraction(8); // 1/8"
var imperial = 12.006.ToFraction(16); // 12'-1/16"
var imperial = 25.222.ToFraction(32); // 25'-2 21/32"

FromFraction extension converts a string representation of a measurement in the Imperial system (feet and inches) to a double value.

var value = "17/64\"".FromFraction(); // 0.092
var value = "1'1.75".FromFraction(); // 1.145
var value = "-69'-69\"".FromFraction(); // -74.75
var value = "2'-1 15/64\"".FromFraction(); // 2.102

TryFromFraction extension converts the textual representation of the Imperial system number to number.

var converted = "1'".TryFromFraction(out var value); // true
var converted = "69\"".TryFromFraction(out var value); // true
var converted = "-2'-1 15/64\"".TryFromFraction(out var value); // true
var converted = "value".TryFromFraction(out var value); // false

System Extensions

Cast<T> extension casts an object to the specified type.

var width = element.Cast<Wall>().Width;
var location = element.Location.Cast<LocationCurve>().Curve;
var faces = element.Cast<HostObject>().GetSideFaces();

Round extension rounds the value to the specified precision or 1e-9 precision specified in Revit Api.

var rounded = 6.56170000000000000000000001.Round(); // 6.5617
var rounded = 6.56170000000000000000000001.Round(0); // 7

IsAlmostEqual extension compares two numbers within specified precision or 1e-9 precision specified in Revit Api.

var isRqual = 6.56170000000000000000000001.IsAlmostEqual(6.5617); // true
var isEqual = 6.56170000000000000000000001.IsAlmostEqual(6.6, 1e-1); // true

IsNullOrEmpty extension indicates whether the specified string is null or an empty string.

var isEmpty = "".IsNullOrEmpty(); // true
var isEmpty = null.IsNullOrEmpty(); // true

IsNullOrWhiteSpace extension indicates whether a specified string is null, empty, or consists only of white-space characters.

var isEmpty = " ".IsNullOrWhiteSpace(); // true
var isEmpty = null.IsNullOrWhiteSpace(); // true

AppendPath extension combines paths.

var path = "C:/Folder".AppendPath("AddIn"); // C:/Folder/AddIn
var path = "C:/Folder".AppendPath("AddIn", "file.txt"); // C:/Folder/AddIn/file.txt

Contains indicating whether a specified substring occurs within this string with StringComparison support.

Available only for .NET Framework builds. .NET Core has a built-in support for this method.

var isContains = "Revit extensions".Contains("Revit", StringComparison.OrdinalIgnoreCase); // true
var isContains = "Revit extensions".Contains("revit", StringComparison.OrdinalIgnoreCase); // true
var isContains = "Revit extensions".Contains("REVIT", StringComparison.OrdinalIgnoreCase); // true
var isContains = "Revit extensions".Contains("invalid", StringComparison.OrdinalIgnoreCase); // false

Show extension opens a window and returns without waiting for the newly opened window to close. Sets the owner of a child window. Applicable for modeless windows to be attached to Revit.

new RevitAddinView.Show(uiApplication.MainWindowHandle)
Product Compatible and additional computed target framework versions.
.NET Framework net48 is compatible.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Nice3point.Revit.Extensions:

Package Downloads
HcBimUtils

Package Description

HC.Tech.So.Revit.Templates

Templates for Revit plugin development

GitHub repositories (2)

Showing the top 2 popular GitHub repositories that depend on Nice3point.Revit.Extensions:

Repository Stars
jeremytammik/RevitLookup
Interactive Revit RFA and RVT project database exploration tool to view and navigate BIM element parameters, properties and relationships.
Nice3point/RevitTemplates
Templates for creating Revit add-ins
Version Downloads Last updated
2025.0.1-preview.2.1 358 10/15/2024
2025.0.1-preview.1.0 57 10/11/2024
2025.0.0 7,933 4/2/2024
2024.1.1-preview.2.1 345 10/15/2024
2024.1.1-preview.1.0 42 10/11/2024
2024.1.0 8,389 4/2/2024
2023.3.1-preview.2.1 355 10/15/2024
2023.3.1-preview.1.0 45 10/11/2024
2023.3.0 8,427 4/2/2024
2022.3.1-preview.2.1 201 10/15/2024
2022.3.1-preview.1.0 43 10/11/2024
2022.3.0 3,595 4/2/2024
2021.3.1-preview.2.1 217 10/15/2024
2021.3.1-preview.1.0 49 10/11/2024
2021.3.0 4,251 4/2/2024
2020.3.1-preview.2.1 231 10/15/2024
2020.3.1-preview.1.0 41 10/11/2024
2020.3.0 2,906 4/2/2024
2019.1.9 2,103 11/17/2022 2019.1.9 is deprecated because it is no longer maintained.

This update focuses on increased utility class coverage, new extensions for global parameter management, for ForgeTypeId handling, advanced geometry extensions, and many-many more.

## New Extensions

**Element Association Extensions**

- **IsAnalyticalElement:** Determines whether an element is an analytical element.
- **IsPhysicalElement:** Checks if an element is a physical one.

**Element Worksharing Extensions**

- **GetCheckoutStatus:** Retrieves the ownership status of an element, with an optional parameter to return the owner's name.
- **GetWorksharingTooltipInfo:** Provides worksharing information about an element for in-canvas tooltips.
- **GetModelUpdatesStatus:** Gets the status of an element in the central model.

**ElementId Extensions**

- **ToElements:** Retrieves a collection of Elements associated with the specified ElementIds.
- **ToElements<T>:** Retrieves a collection of Elements associated with the specified ElementIds as the specified type T.
- **ToOrderedElements:** Retrieves the Elements associated with the specified ElementIds in their original order.
- **ToOrderedElements<T>:** Retrieves the Elements associated with the specified ElementIds and casts them to the specified type T in their original order.

**ElementId Transform Extensions**

- **CanMirrorElements:** Verifies whether a set of elements can be mirrored.
- **MirrorElements:** Mirrors elements across a plane, with support for mirrored copies.
- **MoveElements:** Moves elements according to a specified transformation.
- **RotateElements:** Rotates elements around a given axis by a specified angle.
- **CopyElements:** Copies elements between views or within the same document, with options for translation and transformation.

**Document Extensions**

- **GetProfileSymbols:** Returns profile family symbols in the document.
- **RelinquishOwnership:** Allows relinquishment of ownership based on specified options.

**Document Managers Extensions**

- **GetTemporaryGraphicsManager:** Fetches a reference to the document’s temporary graphics manager.
- **GetAnalyticalToPhysicalAssociationManager:** Retrieves the manager for analytical-to-physical element associations.
- **GetLightGroupManager:** Creates or retrieves the light group manager for the document.

**Geometry Extensions**

- **Contains:** Determines if a point or another bounding box is contained within the bounding box, with strict mode available for more precise containment checks.
- **Overlaps:** Checks whether two bounding boxes overlap.
- **ComputeCentroid:** Calculates the geometric center of a bounding box.
- **ComputeVertices:** Returns the coordinates of the eight vertices of a bounding box.
- **ComputeVolume:** Computes the volume enclosed by the bounding box.
- **ComputeSurfaceArea:** Calculates the total surface area of the bounding box.

**Parameters Extensions**

- **IsBuiltInParameter:** Verifies if a parameter is a built-in parameter.

**Document Global Parameters Extensions**

- **FindGlobalParameter:** Locates a global parameter by name in the document.
- **GetAllGlobalParameters:** Returns all global parameters in the document.
- **GetGlobalParametersOrdered:** Retrieves ordered global parameters.
- **SortGlobalParameters:** Sorts global parameters in the specified order.
- **MoveUpOrder:** Moves a global parameter up in the order.
- **MoveDownOrder:** Moves a global parameter down in the order.
- **IsUniqueGlobalParameterName:** Checks if a global parameter name is unique.
- **IsValidGlobalParameter:** Validates if an ElementId is a global parameter.
- **AreGlobalParametersAllowed:** Checks if global parameters are permitted in the document.

**ForgeTypeId Extensions**

- **IsSpec:** Validates if a ForgeTypeId identifies a spec.
- **IsBuiltInGroup:** Determines whether a ForgeTypeId identifies a built-in parameter group.
- **IsBuiltInParameter:** Validates if a ForgeTypeId identifies a built-in parameter.
- **IsSymbol:** Checks if a ForgeTypeId identifies a symbol.
- **IsUnit:** Verifies if a ForgeTypeId identifies a unit.
- **IsValidDataType:** Determines if a ForgeTypeId identifies a valid parameter data type.
- **IsValidUnit:** Validates if a unit is valid for a measurable spec.
- **IsMeasurableSpec:** Checks if a ForgeTypeId represents a measurable spec.
- **GetBuiltInParameter:** Retrieves a BuiltInParameter from a ForgeTypeId.
- **GetParameterTypeId:** Fetches the ForgeTypeId corresponding to a BuiltInParameter.
- **GetDiscipline:** Gets the discipline for a measurable spec.
- **GetValidUnits:** Retrieves all valid units for a measurable spec.
- **GetTypeCatalogStringForSpec:** Fetches the type catalog string for a measurable spec.
- **GetTypeCatalogStringForUnit:** Retrieves the type catalog string for a unit.
- **DownloadCompanyName:** Downloads the owning company name for a parameter and records it in the document.
- **DownloadParameterOptions:** Fetches settings related to a parameter from the Parameters Service.
- **DownloadParameter:** Creates a shared parameter element in a document based on a downloaded parameter definition.

**Color Extensions**

- **ToHex:** Converts a color to its hexadecimal representation.
- **ToHexInteger:** Returns the hexadecimal integer representation of a color.
- **ToRgb:** Provides the RGB representation of a color.
- **ToHsl:** Converts a color to its HSL representation.
- **ToHsv:** Converts a color to its HSV representation.
- **ToCmyk:** Retrieves the CMYK representation of a color.
- **ToHsb:** Converts a color to HSB.
- **ToHsi:** Converts a color to HSI format.
- **ToHwb:** Provides the HWB representation of a color.
- **ToNCol:** Converts a color to NCol format.
- **ToCielab:** Retrieves the Cielab representation of a color.
- **ToCieXyz:** Converts a color to CieXyz format.
- **ToFloat:** Returns the float representation of a color.
- **ToDecimal:** Returns the decimal representation of a color.

**Family Extensions**

- **CanConvertToFaceHostBased:** Indicates whether a family can be converted to a face-hosted version.
- **ConvertToFaceHostBased:** Converts a family to be face-host based.

**Plumbing Extensions**

- **ConnectPipePlaceholdersAtElbow:** Connects pipe placeholders that form an elbow connection.
- **ConnectPipePlaceholdersAtTee:** Connects pipe placeholders to form a Tee connection.
- **ConnectPipePlaceholdersAtCross:** Connects pipe placeholders to form a Cross connection.
- **PlaceCapOnOpenEnds:** Places caps on open pipe connectors.
- **HasOpenConnector:** Checks if a pipe curve has an open piping connector.
- **BreakCurve:** Splits a pipe curve at a specified point.

**Element Solid Cut Extensions**

- **GetCuttingSolids:** Retrieves solids that cut a given element.
- **GetSolidsBeingCut:** Returns solids that are cut by the given element.
- **IsAllowedForSolidCut:** Verifies if the element can be involved in a solid-solid cut.
- **IsElementFromAppropriateContext:** Checks if the element belongs to a suitable context for solid cuts.
- **CanElementCutElement:** Determines whether a cutting element can create a solid cut on a target element.
- **CutExistsBetweenElements:** Checks if there is an existing solid-solid cut between two elements.
- **AddCutBetweenSolids:** Adds a solid-solid cut between two elements.
- **RemoveCutBetweenSolids:** Removes an existing solid cut between two elements.
- **SplitFacesOfCuttingSolid:** Splits the faces of a cutting solid element.

**View Extensions**

- **GetTransformFromViewToView:** Returns a transformation to copy elements between two views.

**View Managers Extensions**

- **CreateSpatialFieldManager:** Creates a SpatialField manager for a given view.
- **GetSpatialFieldManager:** Retrieves the SpatialField manager for a specific view.

**Ribbon Extensions**

- **AddStackPanel:** Adds a vertical stack panel to the specified Ribbon panel.
- **AddPushButton:** Adds a PushButton to the vertical stack panel.
- **AddPullDownButton:** Adds a PullDownButton to the vertical stack panel.
- **AddSplitButton:** Adds a SplitButton to the vertical stack panel.
- **AddComboBox:** Adds a ComboBox to the vertical stack panel.
- **AddTextBox:** Adds a TextBox to the vertical stack panel.

![verticalStack](https://github.com/user-attachments/assets/3cef1e86-89a3-4f9c-8a06-b7661c6f428f)

## Breaking changes

- **ToFraction:** Now uses 8 precision, instead of 32.
- **ToFraction:** Now suppress 0 for inches part.
- **SetAvailabilityController:** Now returns `PushButton` instead of `RibbonButton`.

**Readme** has been updated, you can find a detailed description and code samples in it.