Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Revit): DirectShape Instances to Speckle Conversion support #3572

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -239,25 +239,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