RevitObjectsHelper 1.1.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package RevitObjectsHelper --version 1.1.1                
NuGet\Install-Package RevitObjectsHelper -Version 1.1.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="RevitObjectsHelper" Version="1.1.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RevitObjectsHelper --version 1.1.1                
#r "nuget: RevitObjectsHelper, 1.1.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 RevitObjectsHelper as a Cake Addin
#addin nuget:?package=RevitObjectsHelper&version=1.1.1

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

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
  {
    [ParameterName("Comments")] //Bind Revit 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,221 4/28/2018
1.1.1 872 3/15/2018
1.0.0 856 3/8/2018

Fix creation of context. Added view option to collect elements only from it