Skip to content

Commit

Permalink
fix(Revit): DirectShape Instances to Speckle Conversion support (#3572)
Browse files Browse the repository at this point in the history
For POC purposes - implements a fix - needs investigation
  • Loading branch information
jsdbroughton authored Jan 7, 2025
1 parent 63dbec0 commit 62009cb
Showing 1 changed file with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -240,25 +240,35 @@ public ApplicationObject DirectShapeToNative(DirectShape speckleDs, ToNativeMesh
return appObj;
}

private DirectShape DirectShapeToSpeckle(DB.DirectShape revitAc)
private void ProcessGeometry(IEnumerable<GeometryObject> geometryObjects, Document revitDoc, List<Base> 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<Base>();
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<Base>();

ProcessGeometry(element, revitAc.Document, geometries);

var speckleAc = new DirectShape(revitAc.Name, category, geometries);

Expand Down

0 comments on commit 62009cb

Please sign in to comment.