RevitObjectsHelper 1.2.0

dotnet add package RevitObjectsHelper --version 1.2.0                
NuGet\Install-Package RevitObjectsHelper -Version 1.2.0                
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="RevitObjectsHelper" Version="1.2.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RevitObjectsHelper --version 1.2.0                
#r "nuget: RevitObjectsHelper, 1.2.0"                
#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 RevitObjectsHelper as a Cake Addin
#addin nuget:?package=RevitObjectsHelper&version=1.2.0

// Install RevitObjectsHelper as a Cake Tool
#tool nuget:?package=RevitObjectsHelper&version=1.2.0                

Revit object helper

Simple library for work with Revit objects in ORM style.

Instalation

PM> Install-Package RevitObjectsHelper

Usage

  //Create class representing Revit element
  [Instance] //Get all instaces of elements, if you want to get types set [Symbol]
  [Class(typeof(Wall))] //Get only walls, also you can set [Category(BuiltInCategory.Walls)]
  public class MyWall : DbObject
  {
    [BuiltInParameter(BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS)] //Bind Revit builtin parameter "Comments" to property Comments
    public string Comments { get; set; }

    [ParameterName("Length")] //Bind Revit parameter "Length" to property Length
    public double Length { get; set; }
  }

  // Create DbContext class
  public class MyContext : DbContext
  {
    //Create property what represents all walls
    public DbObjectSet<MyWall> Walls { get; set; }
  }

  //Use context in your command
  [Transaction(TransactionMode.Manual)]
  [Regeneration(RegenerationOption.Manual)]
  public class CmdCommand : IExternalCommand
  {
    public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
    {
      var uiApp = commandData.Application;
      var doc = uiApp.ActiveUIDocument.Document; //Get current document

      var context = DbContext.Create<MyContext>(doc); //Create context

      //Iterate walls
      foreach (var wall in context.Walls)
      {
        wall.Comments = "Hello!!!"; //Change comment
        wall.Save(); //Save it! It's generate transaction on each wall
      }

      //Or iterate walls
      foreach (var wall in context.Walls)
      {
        wall.Comments = "Hello!!!"; //Change comment
      }
      context.Walls.Save(); //Save all walls by one transaction

      return Result.Succeeded;
    }
  }
Product Compatible and additional computed target framework versions.
.NET Framework net is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.0 1,226 4/28/2018
1.1.1 875 3/15/2018
1.0.0 859 3/8/2018

Fix throwing exceptions. Added BuiltInParameter attribute for binding properties to builtin Revit parameters.