How to transform LocationPoint to ProjectPosition

How to transform LocationPoint to ProjectPosition

Anonymous
Not applicable
1,642 Views
2 Replies
Message 1 of 3

How to transform LocationPoint to ProjectPosition

Anonymous
Not applicable

Hi, i am new in Revit, so sorry for my question if it stupid.

I trying to get the position created by function "Report shared coordinates". I found the function called GetProjectPosition but it still not working. The function return me LocationPoint values so the X,Y,Z was transformed in 'N/S', 'E/O', 'Elevation' but in the Revit i have the different result.
Here is my code:

 

XYZ location = ((LocationPoint)element.Location).Point;
this.CoordX = location.X;
this.CoordY = location.Y;
this.CoordZ = location.Z;
this.LocationType = null;

// Get the project location handle
ProjectLocation projectLocation = doc.ActiveProjectLocation;

// Show the information of current project location
ProjectPosition position = projectLocation.GetProjectPosition(location);
if (null == position)
{
throw new Exception("No project position in origin point.");
}

// Format the prompt string to show the message.
String prompt = "Current project location information:\n";
prompt += "\n\t\t" + "Elevation: " + position.Elevation;
prompt += "\n\t\t" + "North to South offset: " + position.NorthSouth;
prompt += "\n\t\t" + "East to West offset: " + position.EastWest;


So i expect to get values exactly the same like in picture below but instead i got  LocationPoint values (Elevation:17.48, N/S: -1.4, E/O: 11.20)  in the ProjectPosition class.

ProjectPosition.png

Here is my shared point created by function "Report shared coordinates", my LocationPoint is exactly the same (center of an Element).SharedPosition.png

Thank you in advance !

0 Likes
Accepted solutions (1)
1,643 Views
2 Replies
Replies (2)
Message 2 of 3

RPTHOMAS108
Mentor
Mentor
Accepted solution

Seems your numbers are basically correct you just need to convert from internal units (decimal feet) to the units you have set in the UI (metres). You can use the UnitUtils class within the API or multiple your number by 0.3048. Depending on if your desired unit is always going to be metres.

 

 

0 Likes
Message 3 of 3

Anonymous
Not applicable

It Works ! Thank you so much !

0 Likes