Example #1
0
        public static IEnumerable <GeometryBase> ToRhino(this DB.GeometryObject geometry)
        {
            var scaleFactor = Revit.ModelUnits;

            switch (geometry)
            {
            case DB.GeometryElement element:
                foreach (var g in element.SelectMany(x => x.ToRhino()))
                {
                    yield return(g);
                }

                break;

            case DB.GeometryInstance instance:
                var xform = instance.Transform.ToRhino().ChangeUnits(scaleFactor);
                foreach (var g in instance.SymbolGeometry.ToRhino())
                {
                    g?.Transform(xform);
                    yield return(g);
                }
                break;

            case DB.Mesh mesh:
                var m = mesh.ToRhino();

                yield return(m?.ChangeUnits(scaleFactor));

                break;

            case DB.Solid solid:
                var s = solid.ToRhino();

                yield return(s?.ChangeUnits(scaleFactor));

                break;

            case DB.Curve curve:
                var c = curve.ToRhino();

                yield return(c?.ChangeUnits(scaleFactor));

                break;

            case DB.PolyLine polyline:
                var p = new PolylineCurve(polyline.GetCoordinates().ToRhino());

                yield return(p?.ChangeUnits(scaleFactor));

                break;
            }
        }