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): instance display mesh fix once and for all🤞 #2755

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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 @@ -41,9 +41,13 @@ public Base FamilyInstanceToSpeckle(DB.FamilyInstance revitFi, out List<string>
//if they are contained in 'subelements' then they have already been accounted for from a wall
//else if they are mullions then convert them as a generic family instance but add a isUGridLine prop
bool? isUGridLine = null;
if (@base == null &&
(revitFi.Category.Id.IntegerValue == (int)BuiltInCategory.OST_CurtainWallMullions
|| revitFi.Category.Id.IntegerValue == (int)BuiltInCategory.OST_CurtainWallPanels))
if (
@base == null
&& (
revitFi.Category.Id.IntegerValue == (int)BuiltInCategory.OST_CurtainWallMullions
|| revitFi.Category.Id.IntegerValue == (int)BuiltInCategory.OST_CurtainWallPanels
)
)
{
if (SubelementIds.Contains(revitFi.Id))
return null;
Expand Down Expand Up @@ -790,12 +794,7 @@ Transform parentTransform
// get the displayvalue of the family symbol
try
{
var meshes = GetElementDisplayValue(
instance,
new Options() { DetailLevel = ViewDetailLevel.Fine },
true,
instance.HasModifiedGeometry()
);
var meshes = GetElementDisplayValue(instance, new Options() { DetailLevel = ViewDetailLevel.Fine }, true);
symbol.displayValue = meshes;
}
catch (Exception e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ public partial class ConverterRevit
public List<Mesh> GetElementDisplayValue(
DB.Element element,
Options options = null,
bool isConvertedAsInstance = false,
bool hasModifiedInstanceGeometry = false
bool isConvertedAsInstance = false
)
{
var displayMeshes = new List<Mesh>();
Expand All @@ -45,12 +44,7 @@ public List<Mesh> GetElementDisplayValue(
{
foreach (var id in g.GetMemberIds())
{
var groupMeshes = GetElementDisplayValue(
element.Document.GetElement(id),
options,
isConvertedAsInstance,
hasModifiedInstanceGeometry
);
var groupMeshes = GetElementDisplayValue(element.Document.GetElement(id), options, isConvertedAsInstance);
displayMeshes.AddRange(groupMeshes);
}
return displayMeshes;
Expand Down Expand Up @@ -105,12 +99,10 @@ void SortGeometry(GeometryElement geom, Transform inverseTransform = null)
}
break;
case GeometryInstance instance:
var instanceGeo =
isConvertedAsInstance && !hasModifiedInstanceGeometry
? instance.GetSymbolGeometry()
: instance.GetInstanceGeometry();
inverseTransform =
isConvertedAsInstance && hasModifiedInstanceGeometry ? instance.Transform.Inverse : null;
var instanceGeo = !isConvertedAsInstance // this seems counter-intuitive, but in order to retrieve the fully modified instance geo, we need to get the instance geo and then untransform it
? instance.GetSymbolGeometry() // this is not reliable for retrieving definition meshes
: instance.GetInstanceGeometry();
inverseTransform = isConvertedAsInstance ? instance.Transform.Inverse : null;
SortGeometry(instanceGeo, inverseTransform);
break;
case GeometryElement element:
Expand All @@ -121,8 +113,8 @@ void SortGeometry(GeometryElement geom, Transform inverseTransform = null)
}

// convert meshes and solids
displayMeshes.AddRange(ConvertMeshesByRenderMaterial(meshes, element.Document, isConvertedAsInstance));
displayMeshes.AddRange(ConvertSolidsByRenderMaterial(solids, element.Document, isConvertedAsInstance));
displayMeshes.AddRange(ConvertMeshesByRenderMaterial(meshes, element.Document));
displayMeshes.AddRange(ConvertSolidsByRenderMaterial(solids, element.Document));

return displayMeshes;
}
Expand Down