Skip to content

Commit

Permalink
Hotfix(Revit) : change detail level settings via advanced settings (#…
Browse files Browse the repository at this point in the history
…3002)

* change detail level settings via advanced settings

* add some line breaks in tooltip

---------

Co-authored-by: Connor Ivy <connor@speckle.systems>
  • Loading branch information
connorivy and Connor Ivy authored Oct 25, 2023
1 parent 9244b7f commit bd36417
Show file tree
Hide file tree
Showing 22 changed files with 56 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ public partial class ConnectorBindingsRevit
public const string DsFallbackAways = "Always";
public const string DsFallbackNever = "Never";

const string DetailLevelCoarse = "Coarse";
const string DetailLevelMedium = "Medium";
const string DetailLevelFine = "Fine";

public override List<ISetting> GetSettings()
{
List<string> referencePoints = new List<string>() { InternalOrigin };
Expand Down Expand Up @@ -120,6 +124,15 @@ public override List<ISetting> GetSettings()
Selection = forNewTypes,
Description = "Determines when the missing types dialog is shown\n\nNever: the dialog is never shown\nAlways: the dialog is always shown, useful to edit existing mappings\nFor New Types: the dialog is only shown if there are new unmapped types\n\nNOTE: no dialog is shown if Fallback to DirectShape is set to Always"
},
new ListBoxSetting
{
Slug = "detail-level",
Name = "Mesh Export Detail Level (alpha)",
Icon = "Link",
Values = new List<string>() { DetailLevelCoarse, DetailLevelMedium, DetailLevelFine },
Selection = DetailLevelFine,
Description = "Determines the level of detail in which meshes are sent to Speckle. \n\nThis feature is in alpha because primitive objects such as curves, \nwhich are commonly found in coarse or medium detail level element representations, are not supported yet."
},
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,25 @@ public void SetContextDocument(object doc)
}
}

const string DetailLevelCoarse = "Coarse";
const string DetailLevelMedium = "Medium";
const string DetailLevelFine = "Fine";
public ViewDetailLevel DetailLevelSetting => GetDetailLevelSetting() ?? ViewDetailLevel.Fine;
private ViewDetailLevel? GetDetailLevelSetting()
{
if (!Settings.TryGetValue("detail-level", out string detailLevel))
{
return null;
}
return detailLevel switch
{
DetailLevelCoarse => ViewDetailLevel.Coarse,
DetailLevelMedium => ViewDetailLevel.Medium,
DetailLevelFine => ViewDetailLevel.Fine,
_ => null
};
}

//NOTE: not all objects come from Revit, so their applicationId might be null, in this case we fall back on the Id
//this fallback is only needed for a couple of ToNative conversions such as Floor, Ceiling, and Roof
public void SetContextObjects(List<ApplicationObject> objects)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private AdaptiveComponent AdaptiveComponentToSpeckle(DB.FamilyInstance revitAc)

speckleAc.basePoints = GetAdaptivePoints(revitAc);
speckleAc.flipped = AdaptiveComponentInstanceUtils.IsInstanceFlipped(revitAc);
speckleAc.displayValue = GetElementDisplayValue(revitAc, SolidDisplayValueOptions);
speckleAc.displayValue = GetElementDisplayValue(revitAc);

GetAllRevitParamsAndIds(speckleAc, revitAc);
Report.Log($"Converted AdaptiveComponent {revitAc.Id}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ private Element2D AnalyticalSurfaceToSpeckle(AnalyticalModelSurface revitSurface
}

speckleElement2D.topology = edgeNodes;
speckleElement2D.displayValue = GetElementDisplayValue(revitSurface, new Options() { DetailLevel = ViewDetailLevel.Fine });
speckleElement2D.displayValue = GetElementDisplayValue(revitSurface);

var voidNodes = new List<List<Node>> { };
var voidLoops = revitSurface.GetLoops(AnalyticalLoopType.Void);
Expand Down Expand Up @@ -281,9 +281,6 @@ private Element2D AnalyticalSurfaceToSpeckle(AnalyticalModelSurface revitSurface

GetAllRevitParamsAndIds(speckleElement2D, revitSurface);

//speckleElement2D.displayMesh = GetElementDisplayMesh(Doc.GetElement(revitSurface.GetElementId()),
// new Options() { DetailLevel = ViewDetailLevel.Fine, ComputeReferences = false });

return speckleElement2D;
}
#else
Expand Down Expand Up @@ -322,7 +319,7 @@ private Element2D AnalyticalSurfaceToSpeckle(AnalyticalPanel revitSurface)
{
var physicalElementId = analyticalToPhysicalManager.GetAssociatedElementId(revitSurface.Id);
var physicalElement = Doc.GetElement(physicalElementId);
speckleElement2D.displayValue = GetElementDisplayValue(physicalElement, new Options() { DetailLevel = ViewDetailLevel.Fine });
speckleElement2D.displayValue = GetElementDisplayValue(physicalElement);
}

speckleElement2D.openings = GetOpenings(revitSurface);
Expand Down Expand Up @@ -360,9 +357,6 @@ private Element2D AnalyticalSurfaceToSpeckle(AnalyticalPanel revitSurface)

GetAllRevitParamsAndIds(speckleElement2D, revitSurface);

//speckleElement2D.displayMesh = GetElementDisplayMesh(Doc.GetElement(revitSurface.GetElementId()),
// new Options() { DetailLevel = ViewDetailLevel.Fine, ComputeReferences = false });

return speckleElement2D;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ private Base BeamToSpeckle(DB.FamilyInstance revitBeam, out List<string> notes)
speckleBeam.baseLine = baseLine;
speckleBeam.level = ConvertAndCacheLevel(revitBeam, BuiltInParameter.INSTANCE_REFERENCE_LEVEL_PARAM);

speckleBeam.displayValue = GetElementDisplayValue(revitBeam, SolidDisplayValueOptions);
speckleBeam.displayValue = GetElementDisplayValue(revitBeam);

GetAllRevitParamsAndIds(speckleBeam, revitBeam);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ private BuildingPad BuildingPadToSpeckle(DB.BuildingPad revitPad)

GetAllRevitParamsAndIds(specklePad, revitPad, new List<string> { "LEVEL_PARAM" });

specklePad.displayValue = GetElementDisplayValue(revitPad, new Options() { DetailLevel = ViewDetailLevel.Fine });
specklePad.displayValue = GetElementDisplayValue(revitPad);

return specklePad;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public BuiltElements.CableTray CableTrayToSpeckle(DB.Electrical.CableTray revitC
width = GetParamValue<double>(revitCableTray, BuiltInParameter.RBS_CABLETRAY_WIDTH_PARAM),
length = GetParamValue<double>(revitCableTray, BuiltInParameter.CURVE_ELEM_LENGTH),
level = ConvertAndCacheLevel(revitCableTray, BuiltInParameter.RBS_START_LEVEL_PARAM),
displayValue = GetElementDisplayValue(revitCableTray, SolidDisplayValueOptions)
displayValue = GetElementDisplayValue(revitCableTray)
};

GetAllRevitParamsAndIds(speckleCableTray, revitCableTray,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ private RevitCeiling CeilingToSpeckle(DB.Ceiling revitCeiling, out List<string>
GetHostedElements(speckleCeiling, revitCeiling, out List<string> hostedNotes);
if (hostedNotes.Any()) notes.AddRange(hostedNotes); //TODO: what are we doing here?

speckleCeiling.displayValue = GetElementDisplayValue(revitCeiling, new Options() { DetailLevel = ViewDetailLevel.Fine });
speckleCeiling.displayValue = GetElementDisplayValue(revitCeiling);

return speckleCeiling;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public Base ColumnToSpeckle(DB.FamilyInstance revitColumn, out List<string> note
if (revitColumn.Location is LocationPoint)
speckleColumn.rotation = ((LocationPoint)revitColumn.Location).Rotation;

speckleColumn.displayValue = GetElementDisplayValue(revitColumn, SolidDisplayValueOptions);
speckleColumn.displayValue = GetElementDisplayValue(revitColumn);

return speckleColumn;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public BuiltElements.Conduit ConduitToSpeckle(Conduit revitConduit)
diameter = GetParamValue<double>(revitConduit, BuiltInParameter.RBS_CONDUIT_DIAMETER_PARAM),
length = GetParamValue<double>(revitConduit, BuiltInParameter.CURVE_ELEM_LENGTH),
level = ConvertAndCacheLevel(revitConduit, BuiltInParameter.RBS_START_LEVEL_PARAM),
displayValue = GetElementDisplayValue(revitConduit, new Options() { DetailLevel = ViewDetailLevel.Fine, ComputeReferences = true })
displayValue = GetElementDisplayValue(revitConduit)
};

GetAllRevitParamsAndIds(speckleConduit, revitConduit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public BuiltElements.Duct DuctToSpeckle(DB.Mechanical.Duct revitDuct, out List<s
length = GetParamValue<double>(revitDuct, BuiltInParameter.CURVE_ELEM_LENGTH),
velocity = GetParamValue<double>(revitDuct, BuiltInParameter.RBS_VELOCITY),
level = ConvertAndCacheLevel(revitDuct, BuiltInParameter.RBS_START_LEVEL_PARAM),
displayValue = GetElementDisplayValue(revitDuct, SolidDisplayValueOptions)
displayValue = GetElementDisplayValue(revitDuct)
};

if (revitDuct.MEPSystem != null)
Expand Down Expand Up @@ -168,7 +168,7 @@ public BuiltElements.Duct DuctToSpeckle(FlexDuct revitDuct)
endTangent = VectorToSpeckle(revitDuct.EndTangent, revitDuct.Document),
velocity = GetParamValue<double>(revitDuct, BuiltInParameter.RBS_VELOCITY),
level = ConvertAndCacheLevel(revitDuct, BuiltInParameter.RBS_START_LEVEL_PARAM),
displayValue = GetElementDisplayValue(revitDuct, SolidDisplayValueOptions)
displayValue = GetElementDisplayValue(revitDuct)
};

if (revitDuct.MEPSystem != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -821,9 +821,8 @@ Transform parentTransform
{
var meshes = GetElementDisplayValue(
instance,
new Options() { DetailLevel = ViewDetailLevel.Fine },
true,
parentTransform
isConvertedAsInstance: true,
transform: parentTransform
);
symbol.displayValue = meshes;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,7 @@ private RevitFloor FloorToSpeckle(DB.Floor revitFloor, out List<string> notes)
}
}

speckleFloor.displayValue = GetElementDisplayValue(
revitFloor,
new Options() { DetailLevel = ViewDetailLevel.Fine });
speckleFloor.displayValue = GetElementDisplayValue(revitFloor);

GetHostedElements(speckleFloor, revitFloor, out List<string> hostedNotes);
if (hostedNotes.Any())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ namespace Objects.Converter.Revit
{
public partial class ConverterRevit
{
public Options SolidDisplayValueOptions = new Options()
{
DetailLevel = ViewDetailLevel.Fine,
ComputeReferences = true
};

public Options ViewSpecificOptions { get; set; }

/// <summary>
Expand Down Expand Up @@ -55,7 +49,7 @@ public List<Mesh> GetElementDisplayValue(
return displayMeshes;
}

options = ViewSpecificOptions ?? options ?? new Options();
options = ViewSpecificOptions ?? options ?? new Options() { DetailLevel = DetailLevelSetting };

GeometryElement geom = null;
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public BuiltElements.Pipe PipeToSpeckle(DB.Plumbing.Pipe revitPipe)
diameter = GetParamValue<double>(revitPipe, BuiltInParameter.RBS_PIPE_DIAMETER_PARAM),
length = GetParamValue<double>(revitPipe, BuiltInParameter.CURVE_ELEM_LENGTH),
level = ConvertAndCacheLevel(revitPipe, BuiltInParameter.RBS_START_LEVEL_PARAM),
displayValue = GetElementDisplayValue(revitPipe, SolidDisplayValueOptions)
displayValue = GetElementDisplayValue(revitPipe)
};

var material = ConverterRevit.GetMEPSystemMaterial(revitPipe);
Expand Down Expand Up @@ -192,7 +192,7 @@ public BuiltElements.Pipe PipeToSpeckle(DB.Plumbing.FlexPipe revitPipe)
startTangent = VectorToSpeckle(revitPipe.StartTangent, revitPipe.Document),
endTangent = VectorToSpeckle(revitPipe.EndTangent, revitPipe.Document),
level = ConvertAndCacheLevel(revitPipe, BuiltInParameter.RBS_START_LEVEL_PARAM),
displayValue = GetElementDisplayValue(revitPipe, SolidDisplayValueOptions)
displayValue = GetElementDisplayValue(revitPipe)
};

var material = ConverterRevit.GetMEPSystemMaterial(revitPipe);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,7 @@ private RevitRailing RailingToSpeckle(Railing revitRailing)

GetAllRevitParamsAndIds(speckleRailing, revitRailing, new List<string> { "STAIRS_RAILING_BASE_LEVEL_PARAM" });

speckleRailing.displayValue = GetElementDisplayValue(
revitRailing,
new Options() { DetailLevel = ViewDetailLevel.Fine }
);
speckleRailing.displayValue = GetElementDisplayValue(revitRailing);

if (revitRailing.TopRail != ElementId.InvalidElementId)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,7 @@ public RevitElement RevitElementToSpeckle(Element revitElement, out List<string>

GetHostedElements(speckleElement, revitElement, out notes);

// get the displayValue of this revit element
using var options = new Options();
options.DetailLevel = ViewDetailLevel.Fine;

var displayValue = GetElementDisplayValue(revitElement, options);
var displayValue = GetElementDisplayValue(revitElement);

if (!displayValue.Any())
notes.Add(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,7 @@ private Roof RoofToSpeckle(DB.RoofBase revitRoof, out List<string> notes)
GetAllRevitParamsAndIds(speckleRoof, revitRoof,
new List<string> { "ROOF_CONSTRAINT_LEVEL_PARAM", "ROOF_BASE_LEVEL_PARAM", "ROOF_UPTO_LEVEL_PARAM", "EXTRUSION_START_PARAM", "EXTRUSION_END_PARAM", "ROOF_SLOPE" });

speckleRoof.displayValue = GetElementDisplayValue(
revitRoof,
new Options() { DetailLevel = ViewDetailLevel.Fine }
);
speckleRoof.displayValue = GetElementDisplayValue(revitRoof);

GetHostedElements(speckleRoof, revitRoof, out List<string> hostedNotes);
if (hostedNotes.Any()) notes.AddRange(hostedNotes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ private RevitStair StairToSpeckle(Stairs revitStair)

GetAllRevitParamsAndIds(speckleStair, revitStair, new List<string> { "STAIRS_BASE_LEVEL_PARAM", "STAIRS_TOP_LEVEL_PARAM" });

speckleStair.displayValue = GetElementDisplayValue(revitStair, new Options() { DetailLevel = ViewDetailLevel.Fine });
speckleStair.displayValue = GetElementDisplayValue(revitStair);

return speckleStair;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ private RevitTopRail TopRailToSpeckle(TopRail revitTopRail)
var speckleTopRail = new RevitTopRail
{
type = topRailType.Name,
displayValue = GetElementDisplayValue(revitTopRail, new Options() { DetailLevel = ViewDetailLevel.Fine })
displayValue = GetElementDisplayValue(revitTopRail)
};

GetAllRevitParamsAndIds(speckleTopRail, revitTopRail, new List<string> { });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public ApplicationObject TopographyToNative(Topography speckleSurface)
public RevitTopography TopographyToSpeckle(TopographySurface revitTopo)
{
var speckleTopo = new RevitTopography();
speckleTopo.displayValue = GetElementDisplayValue(revitTopo, SolidDisplayValueOptions);
speckleTopo.displayValue = GetElementDisplayValue(revitTopo);
GetAllRevitParamsAndIds(speckleTopo, revitTopo);
return speckleTopo;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,7 @@ public Base WallToSpeckle(DB.Wall revitWall, out List<string> notes)
speckleWall.elements.Add(WallToSpeckle(wall, out List<string> stackedWallNotes));
}

speckleWall.displayValue = GetElementDisplayValue(
revitWall,
new Options() { DetailLevel = ViewDetailLevel.Fine, ComputeReferences = false }
);
speckleWall.displayValue = GetElementDisplayValue(revitWall);
}
else
{
Expand Down

0 comments on commit bd36417

Please sign in to comment.