-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test get pros from clash test report
- Loading branch information
Showing
2 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using Autodesk.Navisworks.Api; | ||
using Autodesk.Navisworks.Api.Clash; | ||
using Test.Helpers; | ||
|
||
namespace Test; | ||
|
||
public class GetPropertiesFromClashTest : INavisCommand | ||
{ | ||
List<string> Categories = new List<string>(); | ||
public override void Action() | ||
{ | ||
GetPropertysFromClashTest(); | ||
IEnumerable<string> distinct = Categories.Distinct(); | ||
Logger.WriteLine("========================================================="); | ||
Logger.WriteLine("Result Report:"); | ||
Logger.WriteLine($"Total Categories:{distinct.Count()}"); | ||
Logger.WriteLine($"Categorys:{string.Join(",", distinct)}"); | ||
Logger.Open(); | ||
} | ||
|
||
/// <summary> | ||
/// case user want get all properties full from clash | ||
/// </summary> | ||
void GetPropertysFromClashTest() | ||
{ | ||
StringBuilder sb = new StringBuilder(); | ||
Document doc = Application.ActiveDocument; | ||
DocumentClash documentClash = doc.GetClash(); | ||
foreach (SavedItem savedItem in documentClash.TestsData.Tests) | ||
{ | ||
ClashTest clashTest = (ClashTest) savedItem; | ||
SavedItemCollection savedItemCollection = clashTest.Children; | ||
foreach (SavedItem item in savedItemCollection) | ||
{ | ||
ClashResult clashResult = item as ClashResult; | ||
if (clashResult != null) | ||
{ | ||
PropertyCategoryCollection categories = clashResult.CompositeItem1.PropertyCategories; | ||
foreach (PropertyCategory category in categories) | ||
{ | ||
GetPropertiesClashTest(category); | ||
} | ||
PropertyCategoryCollection categories2 = clashResult.CompositeItem2.PropertyCategories; | ||
foreach (PropertyCategory category in categories2) | ||
{ | ||
GetPropertiesClashTest(category); | ||
} | ||
//Only test for one clash result | ||
break; | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
} | ||
void GetPropertiesClashTest(PropertyCategory propertyCategory) | ||
{ | ||
Logger.WriteLine(propertyCategory.DisplayName); | ||
Categories.Add(propertyCategory.DisplayName); | ||
foreach (DataProperty dataProperty in propertyCategory.Properties) | ||
{ | ||
Logger.Write($"Name:{dataProperty.Name}"); | ||
Logger.Write($"║ DisplayName:{dataProperty.DisplayName}"); | ||
Logger.Write($"║ Value:{dataProperty.Value.ToVarDisplayString()}"); | ||
Logger.Write($"║ CombinedName:{dataProperty.CombinedName}"); | ||
Logger.WriteLine(""); | ||
|
||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using Autodesk.Navisworks.Api; | ||
|
||
namespace Test.Helpers; | ||
|
||
public static class VariantDataUtils | ||
{ | ||
public static dynamic ToVarDisplayString(this VariantData variantData) | ||
{ | ||
if (!variantData.IsDisplayString) return variantData.ToString(); | ||
switch (variantData.DataType) | ||
{ | ||
case VariantDataType.None: | ||
return variantData.ToString(); | ||
case VariantDataType.Double: | ||
return variantData.ToDouble(); | ||
case VariantDataType.Int32: | ||
return variantData.ToInt32(); | ||
case VariantDataType.Boolean: | ||
return variantData.ToBoolean(); | ||
case VariantDataType.DisplayString: | ||
return variantData.ToDisplayString(); | ||
case VariantDataType.DateTime: | ||
return variantData.ToDateTime(); | ||
case VariantDataType.DoubleLength: | ||
return variantData.ToDoubleLength(); | ||
case VariantDataType.DoubleAngle: | ||
return variantData.ToDoubleAngle(); | ||
case VariantDataType.NamedConstant: | ||
return variantData.ToNamedConstant(); | ||
case VariantDataType.IdentifierString: | ||
return variantData.ToIdentifierString(); | ||
case VariantDataType.DoubleArea: | ||
return variantData.ToDoubleArea(); | ||
case VariantDataType.DoubleVolume: | ||
return variantData.ToDoubleVolume(); | ||
case VariantDataType.Point3D: | ||
return variantData.ToPoint3D(); | ||
case VariantDataType.Point2D: | ||
return variantData.ToPoint2D(); | ||
default: | ||
return variantData.ToString(); | ||
} | ||
} | ||
} |