public override void RenderScene(DB.View dBView, Autodesk.Revit.DB.DisplayStyle displayStyle) { try { if (primitives == null) { if (rhinoObject is PointObject pointObject) { primitives = new Primitive[] { new ObjectPrimitive(pointObject, pointObject.PointGeometry) }; } else if (rhinoObject is PointCloudObject pointCloudObject) { AddPointCloudPreviews(pointCloudObject.PointCloudGeometry); } else if (rhinoObject is CurveObject curveObject) { primitives = new Primitive[] { new ObjectPrimitive(curveObject, curveObject.CurveGeometry) }; } else if (rhinoObject is MeshObject meshObject) { AddMeshPreviews(meshObject.MeshGeometry); } else if (rhinoObject.IsMeshable(MeshType.Render)) { var meshingParameters = rhinoObject.GetRenderMeshParameters(); if (rhinoObject.MeshCount(MeshType.Render, meshingParameters) == 0) { rhinoObject.CreateMeshes(MeshType.Render, meshingParameters, false); } var renderMeshes = rhinoObject.GetMeshes(MeshType.Render); if (renderMeshes?.Length > 0) { int vertexCount = renderMeshes.Select((x) => x.Vertices.Count).Sum(); if (vertexCount > VertexThreshold) { foreach (var m in renderMeshes) { AddMeshPreviews(m); } } else { var previewMesh = renderMeshes.Length == 1 ? renderMeshes[0] : null; if (previewMesh == null) { previewMesh = new Mesh(); previewMesh.Append(renderMeshes); } AddMeshPreviews(previewMesh); } } } } if (primitives != null) { DB3D.DrawContext.SetWorldTransform(Autodesk.Revit.DB.Transform.Identity.ScaleBasis(1.0 / Revit.ModelUnits)); foreach (var primitive in primitives) { if (DB3D.DrawContext.IsInterrupted()) { return; } primitive.Draw(displayStyle); } } } catch (Exception e) { Debug.Fail(e.Source, e.Message); } }