From 775fbcfcf1bfb3d9f31fa58d6c2719e1ba3e4afa Mon Sep 17 00:00:00 2001 From: salaros Date: Fri, 8 Jun 2018 15:16:29 +0300 Subject: [PATCH] improving README file --- README.md | 94 ++++++++++++++++++++++++++++--- tests/SharedParameterFileTests.cs | 17 +++--- 2 files changed, 97 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index cb2c2f3..c49aed3 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,95 @@ -Revit Toolkit +Revit(less) Toolkit ============= -A cross-platform toolkit for processing .rfa, .rvt etc without Revit +A cross-platform **Revit-less** toolkit for processing .rfa, .rvt and other files without [Revit](https://en.wikipedia.org/wiki/Autodesk_Revit) -[![Revit API level](https://img.shields.io/badge/Revit%20API%20Level-2017-447788.svg)](http://www.revitapidocs.com/2017/) -[![NuGet version](https://img.shields.io/nuget/v/CodeCave.Revit.Toolkit.svg)](https://www.nuget.org/packages/CodeCave.Revit.Toolkit/) +[![Revit API](https://img.shields.io/badge/Revit%20API-2017-447788.svg)](http://www.revitapidocs.com/2017/) +[![NuGet version](https://img.shields.io/nuget/v/CodeCave.Revit.Toolkit.svg?label=NuGet)](https://www.nuget.org/packages/CodeCave.Revit.Toolkit/) +[![License](https://img.shields.io/github/license/codecavepro/revit-toolkit.svg)](https://github.com/CodeCavePro/revit-toolkit/blob/master/LICENSE.txt) [![NuGet downloads](https://img.shields.io/nuget/dt/CodeCave.Revit.Toolkit.svg?label=NuGet%20downloads)](https://www.nuget.org/packages/CodeCave.Revit.Toolkit/) [![GitHub downloads](https://img.shields.io/github/downloads/CodeCavePro/revit-toolkit/total.svg?label=GitHub%20downloads)](https://github.com/CodeCavePro/revit-toolkit/releases) -[![License](https://img.shields.io/github/license/codecavepro/revit-toolkit.svg)](https://github.com/CodeCavePro/revit-toolkit/blob/master/LICENSE.txt) [![AppVeyor build status](https://img.shields.io/appveyor/ci/salaros/revit-toolkit/master.svg?logo=appveyor)](https://ci.appveyor.com/project/salaros/revit-toolkit/history) -[![AppVeyor tests](https://img.shields.io/appveyor/tests/salaros/revit-toolkit.svg)]() -[![.Net Status (GitHub)](https://img.shields.io/dotnetstatus/gh/codecavepro/revit-toolkit/API.svg)]() +[![AppVeyor tests](https://img.shields.io/appveyor/tests/salaros/revit-toolkit.svg)](https://ci.appveyor.com/project/salaros/revit-toolkit/build/tests) [![Read the Docs (version)](https://img.shields.io/readthedocs/revit-toolkit/latest.svg)](http://revit-toolkit.readthedocs.io/en/latest/) + +Installation +============ + +**Revit Toolkit** can be installed via [NuGet](https://www.nuget.org/packages?q=CodeCave.Revit) +by using Package Manager in your IDE, `dotnet` binary or Package Console + +```bash +# Add the CodeCave.Revit package to a project named [] +dotnet add [] package CodeCave.Revit +``` + +or Visual Studio's Package Console + +```powershell +# Add the CodeCave.Revit package to the default project +Install-Package CodeCave.Revit + +# Add the CodeCave.Revit package to a project named [] +Install-Package Elmah -ProjectName [] +``` + +Usage +===== + +**Revit Toolkit** provides various tools, you can easily find the full list by browsing the [documentation](http://revit-toolkit.readthedocs.io/en/latest/). + +## Shared parameter file + +```cs +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 { { "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 we've just added parameters with a group object having the same name + ParameterType.NumberOfPoles +); + +// Write out shared parameters file to disk +sharedParamFile.Save("path/new/shared/file.txt"); +``` \ No newline at end of file diff --git a/tests/SharedParameterFileTests.cs b/tests/SharedParameterFileTests.cs index 594d09c..41d6fa8 100644 --- a/tests/SharedParameterFileTests.cs +++ b/tests/SharedParameterFileTests.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.IO; using System.Linq; using System.Text.RegularExpressions; @@ -219,29 +220,31 @@ public void FileIsSerializedProperly() var simpleSharedFromDisk = File .ReadAllText(SharedParameterFiles.FirstOrDefault(f => f.EndsWith(@"SimpleShared_1.txt"))); - var simpleSharedFromBuilt = new SharedParameterFile(); + var simpleSharedFromBuilt = new SharedParameterFile(new Dictionary { { "Identity Data", 100 } } ); #region Identity Data - var identityDataGroup = new SharedParameterFile.Group("Identity Data", 100); simpleSharedFromBuilt.Parameters.Add( - new Guid("61ff3d56-09d7-4049-8c78-4abe745e4e5a"), "EquipmentName", - identityDataGroup, ParameterType.Text + new Guid("61ff3d56-09d7-4049-8c78-4abe745e4e5a"),"EquipmentName", + "Identity Data", // Passing group by name + ParameterType.Text ); simpleSharedFromBuilt.Parameters.Add( new Guid("758c97dc-6b88-4fbd-9570-4affdc32f08d"), "EquipmentNumber", - identityDataGroup, ParameterType.Text + simpleSharedFromBuilt.Groups.FirstOrDefault(g => "Identity Data".Equals(g.Name)), // Finding group dynamically + ParameterType.Text ); simpleSharedFromBuilt.Parameters.Add( new Guid("b5a53ea4-55d9-497c-8488-6607faa11e5f"), "EquipmentServed", - identityDataGroup, ParameterType.Text + new SharedParameterFile.Group("Identity Data", 100), // Creating group as object + ParameterType.Text ); simpleSharedFromBuilt.Parameters.Add( new Guid("d4fa8765-86f3-4472-860c-a906aff18593"), "EquipmentType", - identityDataGroup, ParameterType.Text + "Identity Data", ParameterType.Text ); #endregion