diff --git a/OpenMEPRevit/Geometry/Point.cs b/OpenMEPRevit/Geometry/Point.cs index c1e41848..43d6e457 100644 --- a/OpenMEPRevit/Geometry/Point.cs +++ b/OpenMEPRevit/Geometry/Point.cs @@ -1,4 +1,8 @@ -namespace OpenMEPRevit.Geometry; +using Autodesk.Revit.DB; +using Revit.GeometryConversion; +using RevitServices.Persistence; + +namespace OpenMEPRevit.Geometry; public class Point { @@ -6,4 +10,26 @@ private Point() { } + /// + /// Converts a point from the origin coordinate system to the shared coordinate system in Revit. + /// + /// The point in the origin coordinate system to be converted. + /// The converted point in the shared coordinate system. + public static Autodesk.DesignScript.Geometry.Point ConvertOriginToSharedCoordinate(Autodesk.DesignScript.Geometry.Point point) + { + Autodesk.Revit.DB.Document doc = DocumentManager.Instance.CurrentDBDocument; + XYZ ofPoint = doc.ActiveProjectLocation.GetTotalTransform().Inverse.OfPoint(point.ToXyz()); + return ofPoint.ToPoint(); + } + /// + /// Converts a point from the shared coordinate system to the origin coordinate system in Revit. + /// + /// The point in the shared coordinate system to be converted. + /// The converted point in the origin coordinate system. + public static Autodesk.DesignScript.Geometry.Point ConvertSharedCoordinateToOrigin(Autodesk.DesignScript.Geometry.Point point) + { + Autodesk.Revit.DB.Document doc = DocumentManager.Instance.CurrentDBDocument; + XYZ ofPoint = doc.ActiveProjectLocation.GetTotalTransform().OfPoint(point.ToXyz()); + return ofPoint.ToPoint(); + } } \ No newline at end of file