public static DB.GeometryObject ToGeometryObject(this GeometryBase geometry, double scaleFactor) { switch (geometry) { case Point point: return(point.ToPoint(scaleFactor)); case Curve curve: return(curve.ToCurve(scaleFactor)); case Brep brep: return(brep.ToSolid(scaleFactor)); case Mesh mesh: return(mesh.ToMesh(scaleFactor)); case Extrusion extrusion: { var brep = extrusion.ToBrep(); if (BrepEncoder.EncodeRaw(ref brep, scaleFactor)) { return(BrepEncoder.ToSolid(brep)); } } break; case SubD subD: { var brep = subD.ToBrep(); if (BrepEncoder.EncodeRaw(ref brep, scaleFactor)) { return(BrepEncoder.ToSolid(brep)); } } break; default: if (geometry.HasBrepForm) { var brepForm = Brep.TryConvertBrep(geometry); if (BrepEncoder.EncodeRaw(ref brepForm, scaleFactor)) { return(BrepEncoder.ToSolid(brepForm)); } } break; } throw new ConversionException($"Unable to convert {geometry} to Autodesk.Revit.DB.GeometryObject"); }
public static DB.GeometryObject[] ToShape(this GeometryBase geometry, double factor) { switch (geometry) { case Point point: return(new DB.GeometryObject[] { point.ToPoint(factor) }); case PointCloud pointCloud: return(pointCloud.ToPoints(factor)); case Curve curve: return(curve.ToCurveMany(factor).SelectMany(x => x.ToBoundedCurves()).OfType <DB.GeometryObject>().ToArray()); case Brep brep: return(ToGeometryObjectMany(BrepEncoder.ToRawBrep(brep, factor)).OfType <DB.GeometryObject>().ToArray()); case Extrusion extrusion: return(ToGeometryObjectMany(ExtrusionEncoder.ToRawBrep(extrusion, factor)).OfType <DB.GeometryObject>().ToArray()); case SubD subD: return(ToGeometryObjectMany(SubDEncoder.ToRawBrep(subD, factor)).OfType <DB.GeometryObject>().ToArray());; case Mesh mesh: return(new DB.GeometryObject[] { MeshEncoder.ToMesh(MeshEncoder.ToRawMesh(mesh, factor)) }); default: if (geometry.HasBrepForm) { var brepForm = Brep.TryConvertBrep(geometry); if (BrepEncoder.EncodeRaw(ref brepForm, factor)) { return(ToGeometryObjectMany(brepForm).OfType <DB.GeometryObject>().ToArray()); } } return(new DB.GeometryObject[0]); } }
internal static Brep ToRawBrep(/*const*/ SubD subD, double scaleFactor) { var brep = subD.ToBrep(); return(BrepEncoder.EncodeRaw(ref brep, scaleFactor) ? brep : default);
internal static Brep ToRawBrep(/*const*/ Extrusion extrusion, double scaleFactor) { var brep = extrusion.ToBrep(); return(BrepEncoder.EncodeRaw(ref brep, scaleFactor) ? brep : default);