From e05e6c1c588489f3e5570d200d0f33e9fbd4355c Mon Sep 17 00:00:00 2001 From: Jonathon Broughton Date: Mon, 15 Jul 2024 13:22:36 +0100 Subject: [PATCH] For POC purposes - implements a fix - needs investigation --- .../PartialClasses/ConvertDirectShape.cs | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/Objects/Converters/ConverterRevit/ConverterRevitShared/PartialClasses/ConvertDirectShape.cs b/Objects/Converters/ConverterRevit/ConverterRevitShared/PartialClasses/ConvertDirectShape.cs index e71083bb48..f59a67d3b9 100644 --- a/Objects/Converters/ConverterRevit/ConverterRevitShared/PartialClasses/ConvertDirectShape.cs +++ b/Objects/Converters/ConverterRevit/ConverterRevitShared/PartialClasses/ConvertDirectShape.cs @@ -239,25 +239,35 @@ public ApplicationObject DirectShapeToNative(DirectShape speckleDs, ToNativeMesh return appObj; } - private DirectShape DirectShapeToSpeckle(DB.DirectShape revitAc) + private void ProcessGeometry(IEnumerable geometryObjects, Document revitDoc, List geometries) { - var cat = ((BuiltInCategory)revitAc.Category.Id.IntegerValue).ToString(); - var category = Categories.GetSchemaBuilderCategoryFromBuiltIn(cat); - var element = revitAc.get_Geometry(new Options()); - - var geometries = new List(); - foreach (var obj in element) + foreach (var obj in geometryObjects) { switch (obj) { case DB.Mesh mesh: - geometries.Add(MeshToSpeckle(mesh, revitAc.Document)); + geometries.Add(MeshToSpeckle(mesh, revitDoc)); break; case Solid solid: // TODO Should be replaced with 'BrepToSpeckle' when it works. - geometries.AddRange(ConvertSolidsByRenderMaterial(new[] { solid }, revitAc.Document)); + geometries.AddRange(ConvertSolidsByRenderMaterial(new[] { solid }, revitDoc)); + break; + case GeometryInstance gi: + var instanceGeometryElement = gi.GetSymbolGeometry(gi.Transform); + ProcessGeometry(instanceGeometryElement, revitDoc, geometries); break; } } + } + + private DirectShape DirectShapeToSpeckle(DB.DirectShape revitAc) + { + var cat = ((BuiltInCategory)revitAc.Category.Id.IntegerValue).ToString(); + var category = Categories.GetSchemaBuilderCategoryFromBuiltIn(cat); + var element = revitAc.get_Geometry(new Options()); + + var geometries = new List(); + + ProcessGeometry(element, revitAc.Document, geometries); var speckleAc = new DirectShape(revitAc.Name, category, geometries);