public static void BuildPreview
        (
            DB.Element element, MeshingParameters meshingParameters, DB.ViewDetailLevel DetailLevel,
            out Rhino.Display.DisplayMaterial[] materials, out Mesh[] meshes, out Curve[] wires
        )
        {
            DB.Options options = null;
            using (var geometry = element?.GetGeometry(DetailLevel == DB.ViewDetailLevel.Undefined ? DB.ViewDetailLevel.Medium : DetailLevel, out options)) using (options)
                {
                    if (geometry is null)
                    {
                        materials = null;
                        meshes    = null;
                        wires     = null;
                    }
                    else
                    {
                        var categoryMaterial = element.Category?.Material.ToRhino(null);
                        var elementMaterial  = geometry.MaterialElement.ToRhino(categoryMaterial);

                        meshes    = geometry.GetPreviewMeshes(meshingParameters).Where(x => x is object).ToArray();
                        wires     = geometry.GetPreviewWires().Where(x => x is object).ToArray();
                        materials = geometry.GetPreviewMaterials(element.Document, elementMaterial).Where(x => x is object).ToArray();

                        foreach (var mesh in meshes)
                        {
                            mesh.Normals.ComputeNormals();
                        }
                    }
                }
        }
        public static void BuildPreview
        (
            DB.Element element, MeshingParameters meshingParameters, DB.ViewDetailLevel DetailLevel,
            out Rhino.Display.DisplayMaterial[] materials, out Mesh[] meshes, out Curve[] wires
        )
        {
            DB.Options options = null;
            using (var geometry = element?.GetGeometry(DetailLevel == DB.ViewDetailLevel.Undefined ? DB.ViewDetailLevel.Medium : DetailLevel, out options)) using (options)
                {
                    if (geometry is null)
                    {
                        materials = null;
                        meshes    = null;
                        wires     = null;
                    }
                    else
                    {
                        var categoryMaterial = element.Category?.Material.ToDisplayMaterial(null);
                        var elementMaterial  = geometry.MaterialElement.ToDisplayMaterial(categoryMaterial);

                        meshes    = geometry.GetPreviewMeshes(meshingParameters).Where(x => x is object).ToArray();
                        wires     = geometry.GetPreviewWires().Where(x => x is object).ToArray();
                        materials = geometry.GetPreviewMaterials(element.Document, elementMaterial).Where(x => x is object).ToArray();

                        if (meshes.Length == 0 && wires.Length == 0 && element.get_BoundingBox(null) is DB.BoundingBoxXYZ)
                        {
                            var subMeshes    = new List <Mesh>();
                            var subWires     = new List <Curve>();
                            var subMaterials = new List <Rhino.Display.DisplayMaterial>();

                            foreach (var dependent in element.GetDependentElements(null).Select(x => element.Document.GetElement(x)))
                            {
                                if (dependent.get_BoundingBox(null) is null)
                                {
                                    continue;
                                }

                                DB.Options dependentOptions = null;
                                using (var dependentGeometry = dependent?.GetGeometry(DetailLevel == DB.ViewDetailLevel.Undefined ? DB.ViewDetailLevel.Medium : DetailLevel, out dependentOptions)) using (dependentOptions)
                                    {
                                        if (dependentGeometry is object)
                                        {
                                            subMeshes.AddRange(dependentGeometry.GetPreviewMeshes(meshingParameters).Where(x => x is object));
                                            subWires.AddRange(dependentGeometry.GetPreviewWires().Where(x => x is object));
                                            subMaterials.AddRange(dependentGeometry.GetPreviewMaterials(element.Document, elementMaterial).Where(x => x is object));
                                        }
                                    }
                            }

                            meshes    = subMeshes.ToArray();
                            wires     = subWires.ToArray();
                            materials = subMaterials.ToArray();
                        }

                        foreach (var mesh in meshes)
                        {
                            mesh.Normals.ComputeNormals();
                        }
                    }
                }
        }