Skip to content

Commit

Permalink
support coordinate convert
Browse files Browse the repository at this point in the history
  • Loading branch information
chuongmep committed Mar 25, 2024
1 parent 0cc3af3 commit 26739dd
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion OpenMEPRevit/Geometry/Point.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,35 @@
namespace OpenMEPRevit.Geometry;
using Autodesk.Revit.DB;
using Revit.GeometryConversion;
using RevitServices.Persistence;

namespace OpenMEPRevit.Geometry;

public class Point
{
private Point()
{

}
/// <summary>
/// Converts a point from the origin coordinate system to the shared coordinate system in Revit.
/// </summary>
/// <param name="point">The point in the origin coordinate system to be converted.</param>
/// <returns>The converted point in the shared coordinate system.</returns>
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();
}
/// <summary>
/// Converts a point from the shared coordinate system to the origin coordinate system in Revit.
/// </summary>
/// <param name="point">The point in the shared coordinate system to be converted.</param>
/// <returns>The converted point in the origin coordinate system.</returns>
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();
}
}

0 comments on commit 26739dd

Please sign in to comment.