All the same formatting
This commit is contained in:
+11
-14
@@ -4,22 +4,19 @@ using System.Collections.Generic;
|
||||
using xUnitRevitUtils;
|
||||
|
||||
namespace SampleLibrary {
|
||||
public sealed class DocFixture : IDisposable
|
||||
{
|
||||
public Document Doc { get; set; }
|
||||
public IList<Element> Walls { get; set; }
|
||||
public sealed class DocFixture : IDisposable {
|
||||
public Document Doc { get; set; }
|
||||
public IList<Element> Walls { get; set; }
|
||||
|
||||
|
||||
public DocFixture()
|
||||
{
|
||||
var testModel = Utils.GetTestModel("walls.rvt");
|
||||
Doc = xru.OpenDoc(testModel);
|
||||
public DocFixture() {
|
||||
var testModel = Utils.GetTestModel("walls.rvt");
|
||||
Doc = xru.OpenDoc(testModel);
|
||||
|
||||
Walls = new FilteredElementCollector(Doc).WhereElementIsNotElementType().OfCategory(BuiltInCategory.OST_Walls).ToElements();
|
||||
Walls = new FilteredElementCollector(Doc).WhereElementIsNotElementType().OfCategory(BuiltInCategory.OST_Walls).ToElements();
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
|
||||
+60
-72
@@ -1,72 +1,60 @@
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB.IFC;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Xunit;
|
||||
using xUnitRevitUtils;
|
||||
|
||||
namespace SampleLibrary
|
||||
{
|
||||
public class SampleTest
|
||||
{
|
||||
/// <summary>
|
||||
/// Checks whether all walls in the model have a valid volume
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void WallsHaveVolume()
|
||||
{
|
||||
var testModel = Utils.GetTestModel("walls.rvt");
|
||||
var doc = xru.OpenDoc(testModel);
|
||||
|
||||
var walls = new FilteredElementCollector(doc).WhereElementIsNotElementType().OfCategory(BuiltInCategory.OST_Walls).ToElements();
|
||||
|
||||
foreach (var wall in walls)
|
||||
{
|
||||
var volumeParam = wall.get_Parameter(BuiltInParameter.HOST_VOLUME_COMPUTED);
|
||||
Assert.NotNull(volumeParam);
|
||||
Assert.True(volumeParam.AsDouble() > 0);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SampleFail()
|
||||
{
|
||||
#if pre2021
|
||||
var feet = UnitUtils.ConvertToInternalUnits(3000, DisplayUnitType.DUT_MILLIMETERS);
|
||||
#else
|
||||
var feet = UnitUtils.ConvertToInternalUnits(3000, UnitTypeId.Feet);
|
||||
#endif
|
||||
Assert.Equal(5, feet);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetWallGrossAreaAndRollBack()
|
||||
{
|
||||
var testModel = Utils.GetTestModel("walls.rvt");
|
||||
var doc = xru.OpenDoc(testModel);
|
||||
var walls = new FilteredElementCollector(doc).WhereElementIsNotElementType().OfCategory(BuiltInCategory.OST_Walls).ToElements();
|
||||
var wall = walls[0] as Wall;
|
||||
double grossArea = 0;
|
||||
|
||||
var inserts = wall.FindInserts(true, true, true, true);
|
||||
xru.Run(() =>
|
||||
{
|
||||
using (Transaction transaction = new Transaction(doc, "Temporary - only to get gross area"))
|
||||
{
|
||||
transaction.Start();
|
||||
foreach (ElementId insertId in inserts) { doc.Delete(insertId); }
|
||||
doc.Regenerate();
|
||||
var wallFaceReference = HostObjectUtils.GetSideFaces(wall, ShellLayerType.Exterior);
|
||||
var face = doc.GetElement(wallFaceReference.First()).GetGeometryObjectFromReference(wallFaceReference.First()) as PlanarFace;
|
||||
var wallFaceEdges = face.GetEdgesAsCurveLoops();
|
||||
grossArea = ExporterIFCUtils.ComputeAreaOfCurveLoops(wallFaceEdges);
|
||||
transaction.RollBack();
|
||||
}
|
||||
}, doc).Wait();
|
||||
Assert.True(grossArea > 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB.IFC;
|
||||
using System.Linq;
|
||||
using Xunit;
|
||||
using xUnitRevitUtils;
|
||||
|
||||
namespace SampleLibrary {
|
||||
public class SampleTest {
|
||||
/// <summary>
|
||||
/// Checks whether all walls in the model have a valid volume
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void WallsHaveVolume() {
|
||||
var testModel = Utils.GetTestModel("walls.rvt");
|
||||
var doc = xru.OpenDoc(testModel);
|
||||
|
||||
var walls = new FilteredElementCollector(doc).WhereElementIsNotElementType().OfCategory(BuiltInCategory.OST_Walls).ToElements();
|
||||
|
||||
foreach (var wall in walls) {
|
||||
var volumeParam = wall.get_Parameter(BuiltInParameter.HOST_VOLUME_COMPUTED);
|
||||
Assert.NotNull(volumeParam);
|
||||
Assert.True(volumeParam.AsDouble() > 0);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SampleFail() {
|
||||
#if pre2021
|
||||
var feet = UnitUtils.ConvertToInternalUnits(3000, DisplayUnitType.DUT_MILLIMETERS);
|
||||
#else
|
||||
var feet = UnitUtils.ConvertToInternalUnits(3000, UnitTypeId.Feet);
|
||||
#endif
|
||||
Assert.Equal(5, feet);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetWallGrossAreaAndRollBack() {
|
||||
var testModel = Utils.GetTestModel("walls.rvt");
|
||||
var doc = xru.OpenDoc(testModel);
|
||||
var walls = new FilteredElementCollector(doc).WhereElementIsNotElementType().OfCategory(BuiltInCategory.OST_Walls).ToElements();
|
||||
var wall = walls[0] as Wall;
|
||||
double grossArea = 0;
|
||||
|
||||
var inserts = wall.FindInserts(true, true, true, true);
|
||||
xru.Run(() => {
|
||||
using (Transaction transaction = new Transaction(doc, "Temporary - only to get gross area")) {
|
||||
transaction.Start();
|
||||
foreach (ElementId insertId in inserts) { doc.Delete(insertId); }
|
||||
doc.Regenerate();
|
||||
var wallFaceReference = HostObjectUtils.GetSideFaces(wall, ShellLayerType.Exterior);
|
||||
var face = doc.GetElement(wallFaceReference.First()).GetGeometryObjectFromReference(wallFaceReference.First()) as PlanarFace;
|
||||
var wallFaceEdges = face.GetEdgesAsCurveLoops();
|
||||
grossArea = ExporterIFCUtils.ComputeAreaOfCurveLoops(wallFaceEdges);
|
||||
transaction.RollBack();
|
||||
}
|
||||
}, doc).Wait();
|
||||
Assert.True(grossArea > 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,72 +1,61 @@
|
||||
using Autodesk.Revit.DB;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
using xUnitRevitUtils;
|
||||
|
||||
using Autodesk.Revit.DB;
|
||||
using System.Linq;
|
||||
using Xunit;
|
||||
using xUnitRevitUtils;
|
||||
|
||||
namespace SampleLibrary {
|
||||
public class TestWithFixture : IClassFixture<DocFixture>
|
||||
{
|
||||
DocFixture fixture;
|
||||
public TestWithFixture(DocFixture fixture)
|
||||
{
|
||||
this.fixture = fixture;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CountWalls()
|
||||
{
|
||||
Assert.Equal(4, fixture.Walls.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WallOffset()
|
||||
{
|
||||
var wall = fixture.Doc.GetElement(new ElementId(346573));
|
||||
var param = wall.get_Parameter(BuiltInParameter.WALL_BASE_OFFSET);
|
||||
|
||||
#if pre2021
|
||||
var baseOffset = UnitUtils.ConvertFromInternalUnits(param.AsDouble(), param.DisplayUnitType);
|
||||
#else
|
||||
var baseOffset = UnitUtils.ConvertFromInternalUnits(param.AsDouble(), param.GetUnitTypeId());
|
||||
#endif
|
||||
|
||||
Assert.Equal(2000, baseOffset);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MoveWallsUp()
|
||||
{
|
||||
var walls = fixture.Walls.Where(x => x.Id.IntegerValue != 346573);
|
||||
|
||||
xru.RunInTransaction(() =>
|
||||
{
|
||||
foreach(var wall in walls)
|
||||
{
|
||||
var param = wall.get_Parameter(BuiltInParameter.WALL_BASE_OFFSET);
|
||||
|
||||
#if pre2021
|
||||
var baseOffset = UnitUtils.ConvertToInternalUnits(2000, param.DisplayUnitType);
|
||||
#else
|
||||
var baseOffset = UnitUtils.ConvertToInternalUnits(2000, param.GetUnitTypeId());
|
||||
#endif
|
||||
param.Set(baseOffset);
|
||||
}
|
||||
}, fixture.Doc)
|
||||
.Wait(); // Important! Wait for action to finish
|
||||
|
||||
foreach (var wall in walls)
|
||||
{
|
||||
var param = wall.get_Parameter(BuiltInParameter.WALL_BASE_OFFSET);
|
||||
#if pre2021
|
||||
var baseOffset = UnitUtils.ConvertFromInternalUnits(param.AsDouble(), param.DisplayUnitType);
|
||||
#else
|
||||
var baseOffset = UnitUtils.ConvertFromInternalUnits(param.AsDouble(), param.GetUnitTypeId());
|
||||
#endif
|
||||
Assert.Equal(2000, baseOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public class TestWithFixture : IClassFixture<DocFixture> {
|
||||
DocFixture fixture;
|
||||
public TestWithFixture(DocFixture fixture) {
|
||||
this.fixture = fixture;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CountWalls() {
|
||||
Assert.Equal(4, fixture.Walls.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WallOffset() {
|
||||
var wall = fixture.Doc.GetElement(new ElementId(346573));
|
||||
var param = wall.get_Parameter(BuiltInParameter.WALL_BASE_OFFSET);
|
||||
|
||||
#if pre2021
|
||||
var baseOffset = UnitUtils.ConvertFromInternalUnits(param.AsDouble(), param.DisplayUnitType);
|
||||
#else
|
||||
var baseOffset = UnitUtils.ConvertFromInternalUnits(param.AsDouble(), param.GetUnitTypeId());
|
||||
#endif
|
||||
|
||||
Assert.Equal(2000, baseOffset);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MoveWallsUp() {
|
||||
var walls = fixture.Walls.Where(x => x.Id.IntegerValue != 346573);
|
||||
|
||||
xru.RunInTransaction(() => {
|
||||
foreach (var wall in walls) {
|
||||
var param = wall.get_Parameter(BuiltInParameter.WALL_BASE_OFFSET);
|
||||
|
||||
#if pre2021
|
||||
var baseOffset = UnitUtils.ConvertToInternalUnits(2000, param.DisplayUnitType);
|
||||
#else
|
||||
var baseOffset = UnitUtils.ConvertToInternalUnits(2000, param.GetUnitTypeId());
|
||||
#endif
|
||||
param.Set(baseOffset);
|
||||
}
|
||||
}, fixture.Doc)
|
||||
.Wait(); // Important! Wait for action to finish
|
||||
|
||||
foreach (var wall in walls) {
|
||||
var param = wall.get_Parameter(BuiltInParameter.WALL_BASE_OFFSET);
|
||||
#if pre2021
|
||||
var baseOffset = UnitUtils.ConvertFromInternalUnits(param.AsDouble(), param.DisplayUnitType);
|
||||
#else
|
||||
var baseOffset = UnitUtils.ConvertFromInternalUnits(param.AsDouble(), param.GetUnitTypeId());
|
||||
#endif
|
||||
Assert.Equal(2000, baseOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+16
-24
@@ -1,24 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SampleLibrary
|
||||
{
|
||||
public static class Utils
|
||||
{
|
||||
/// <summary>
|
||||
/// Utility method to get models from local folder rather than an absolute path
|
||||
/// </summary>
|
||||
/// <param name="filename"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetTestModel(string filename)
|
||||
{
|
||||
var path = Path.Combine(Directory.GetCurrentDirectory(), "..", "..", "TestModels", filename);
|
||||
return path;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.IO;
|
||||
|
||||
namespace SampleLibrary {
|
||||
public static class Utils {
|
||||
/// <summary>
|
||||
/// Utility method to get models from local folder rather than an absolute path
|
||||
/// </summary>
|
||||
/// <param name="filename"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetTestModel(string filename) {
|
||||
var path = Path.Combine(Directory.GetCurrentDirectory(), "..", "..", "TestModels", filename);
|
||||
return path;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user