public static IList <GeometryObject> ToRevitType(this Autodesk.DesignScript.Geometry.Surface srf,
                                                         TessellatedShapeBuilderTarget target     = TessellatedShapeBuilderTarget.Mesh,
                                                         TessellatedShapeBuilderFallback fallback = TessellatedShapeBuilderFallback.Salvage,
                                                         ElementId MaterialId           = null,
                                                         bool performHostUnitConversion = true)
        {
            var rp = new DefaultRenderPackage();

            if (performHostUnitConversion)
            {
                var newSrf = srf.InHostUnits();
                newSrf.Tessellate(rp, new TessellationParameters());
                newSrf.Dispose();
            }
            else
            {
                srf.Tessellate(rp, new TessellationParameters());
            }

            var tsb = new TessellatedShapeBuilder()
            {
                Fallback = fallback, Target = target, GraphicsStyleId = ElementId.InvalidElementId
            };

            tsb.OpenConnectedFaceSet(false);

            var v = rp.MeshVertices.ToList();

            for (int i = 0; i < v.Count; i += 9)
            {
                var a = new XYZ(v[i], v[i + 1], v[i + 2]);
                var b = new XYZ(v[i + 3], v[i + 4], v[i + 5]);
                var c = new XYZ(v[i + 6], v[i + 7], v[i + 8]);

                var face = new TessellatedFace(new List <XYZ>()
                {
                    a, b, c
                }, MaterialId != null ? MaterialId : MaterialsManager.Instance.DynamoMaterialId);
                tsb.AddFace(face);
            }

            tsb.CloseConnectedFaceSet();
            tsb.Build();
            var result = tsb.GetBuildResult();

            return(result.GetGeometricalObjects());
        }