From c4be469c712e4d13bee48f18d92fb9e8274de46d Mon Sep 17 00:00:00 2001 From: Jeremy Tammik Date: Thu, 20 Jul 2017 10:29:42 +0200 Subject: [PATCH] tighter bounding box calculation using FamilyInstance information --- FamilyBoundingBox/Command.cs | 35 ++++++++++---------- FamilyBoundingBox/Properties/AssemblyInfo.cs | 10 ++++-- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/FamilyBoundingBox/Command.cs b/FamilyBoundingBox/Command.cs index 11b6afe..f1e31d8 100644 --- a/FamilyBoundingBox/Command.cs +++ b/FamilyBoundingBox/Command.cs @@ -218,9 +218,8 @@ BoundingBoxXYZ familyInstanceBoundingBox /// /// Compute the 'BoundingBoxXYZ' of . - /// - /// Required because 'FamilyInstance.get_BoundingBox( null )' does not give - /// a tight 'BoundingBoxXYZ'. + /// Required because 'FamilyInstance.get_BoundingBox( null )' + /// does not give a tight bounding box. /// /// The 'FamilyInstance' to compute the /// 'BoundingBoxXYZ' of. @@ -234,7 +233,9 @@ private static BoundingBoxXYZ ComputeFamilyInstanceBoundingBoxXyz( Options options = new Options(); GeometryElement geometryElement = familyInstance.get_Geometry( options ); - foreach ( GeometryInstance geometryInstance in geometryElement ) + + foreach ( GeometryInstance geometryInstance + in geometryElement ) { foreach ( GeometryObject geometryObject in geometryInstance.GetInstanceGeometry() ) @@ -272,7 +273,7 @@ private static BoundingBoxXYZ ComputeBoundingBoxXYZFromPoints( IEnumerable points) { BoundingBoxXYZ boundingBoxXYZ = null; - if ( points.Any() ) + if( points.Any() ) { double minX = Double.PositiveInfinity; double minY = Double.PositiveInfinity; @@ -299,27 +300,27 @@ private static BoundingBoxXYZ ComputeBoundingBoxXYZFromPoints( } /// - /// Merge and - /// into a new 'BoundingBoxXYZ'. + /// Merge and + /// into a new 'BoundingBoxXYZ'. /// - /// A 'BoundingBoxXYZ' to merge - /// A 'BoundingBoxXYZ' to merge + /// A 'BoundingBoxXYZ' to merge + /// A 'BoundingBoxXYZ' to merge /// The new merged 'BoundingBoxXYZ'. static BoundingBoxXYZ MergeBoundingBoxXyz( - BoundingBoxXYZ boundingBoxXyz0, - BoundingBoxXYZ boundingBoxXyz1 ) + BoundingBoxXYZ a, + BoundingBoxXYZ b ) { BoundingBoxXYZ mergedResult = new BoundingBoxXYZ(); mergedResult.Min = new XYZ( - Math.Min( boundingBoxXyz0.Min.X, boundingBoxXyz1.Min.X ), - Math.Min( boundingBoxXyz0.Min.Y, boundingBoxXyz1.Min.Y ), - Math.Min( boundingBoxXyz0.Min.Z, boundingBoxXyz1.Min.Z ) ); + Math.Min( a.Min.X, b.Min.X ), + Math.Min( a.Min.Y, b.Min.Y ), + Math.Min( a.Min.Z, b.Min.Z ) ); mergedResult.Max = new XYZ( - Math.Max( boundingBoxXyz0.Max.X, boundingBoxXyz1.Max.X ), - Math.Max( boundingBoxXyz0.Max.Y, boundingBoxXyz1.Max.Y ), - Math.Max( boundingBoxXyz0.Max.Z, boundingBoxXyz1.Max.Z ) ); + Math.Max( a.Max.X, b.Max.X ), + Math.Max( a.Max.Y, b.Max.Y ), + Math.Max( a.Max.Z, b.Max.Z ) ); return mergedResult; } diff --git a/FamilyBoundingBox/Properties/AssemblyInfo.cs b/FamilyBoundingBox/Properties/AssemblyInfo.cs index 38e3320..2675d06 100644 --- a/FamilyBoundingBox/Properties/AssemblyInfo.cs +++ b/FamilyBoundingBox/Properties/AssemblyInfo.cs @@ -32,5 +32,11 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion( "2017.0.0.0" )] -[assembly: AssemblyFileVersion( "2017.0.0.0" )] +// +// History: +// +// 2017-03-15 2017.0.0.0 initial implementation +// 2017-07-20 2017.0.0.1 tighter bounding box calculation using FamilyInstance information +// +[assembly: AssemblyVersion( "2017.0.0.1" )] +[assembly: AssemblyFileVersion( "2017.0.0.1" )]